From 1a183368082ad357b1fef0f55038becc9ac14b7b Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 30 Jan 2019 15:12:41 +0100 Subject: [PATCH 01/30] proc_macro: make `TokenStream::from_streams` pre-allocate its vector. This requires a pre-pass over the input streams. But that is cheap compared to the quadratic blowup associated with reallocating the accumulating vector on-the-fly. --- src/libsyntax/tokenstream.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index f5d2d6f18ee87..7d6ffceb2c0d4 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -255,7 +255,13 @@ impl TokenStream { 0 => TokenStream::empty(), 1 => streams.pop().unwrap(), _ => { - let mut vec = vec![]; + // rust-lang/rust#57735: pre-allocate vector to avoid + // quadratic blow-up due to on-the-fly reallocations. + let tree_count = streams.iter() + .map(|ts| match &ts.0 { None => 0, Some(s) => s.len() }) + .sum(); + let mut vec = Vec::with_capacity(tree_count); + for stream in streams { match stream.0 { None => {}, From f832a809bbb08bc2bb08b012cee8ee6b2178d26d Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Sun, 3 Feb 2019 21:43:09 +0900 Subject: [PATCH 02/30] Transition remote-test-client to 2018 edition --- src/tools/remote-test-client/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/remote-test-client/Cargo.toml b/src/tools/remote-test-client/Cargo.toml index 54739101f1eff..1a4b24bd5b34c 100644 --- a/src/tools/remote-test-client/Cargo.toml +++ b/src/tools/remote-test-client/Cargo.toml @@ -2,5 +2,6 @@ name = "remote-test-client" version = "0.1.0" authors = ["The Rust Project Developers"] +edition = "2018" [dependencies] From d17b2ec0e3830a5b673907aa2e9f8347df4c4cf4 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Sun, 3 Feb 2019 21:44:21 +0900 Subject: [PATCH 03/30] Transition remote-test-server to 2018 edition --- src/tools/remote-test-server/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/remote-test-server/Cargo.toml b/src/tools/remote-test-server/Cargo.toml index 8704296289e83..5906c76c01d9f 100644 --- a/src/tools/remote-test-server/Cargo.toml +++ b/src/tools/remote-test-server/Cargo.toml @@ -2,5 +2,6 @@ name = "remote-test-server" version = "0.1.0" authors = ["The Rust Project Developers"] +edition = "2018" [dependencies] From 3a133f20887b9a9677ac9af8fa56d75e4d3b6e89 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Sun, 3 Feb 2019 21:37:08 +0900 Subject: [PATCH 04/30] Transition linkchecker to 2018 edition --- src/tools/linkchecker/Cargo.toml | 1 + src/tools/linkchecker/main.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tools/linkchecker/Cargo.toml b/src/tools/linkchecker/Cargo.toml index d6b7dafea40e0..0994cd2066246 100644 --- a/src/tools/linkchecker/Cargo.toml +++ b/src/tools/linkchecker/Cargo.toml @@ -2,6 +2,7 @@ name = "linkchecker" version = "0.1.0" authors = ["Alex Crichton "] +edition = "2018" [[bin]] name = "linkchecker" diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 2cf0fcfd34cd6..af704ce260dc4 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -14,6 +14,8 @@ //! A few whitelisted exceptions are allowed as there's known bugs in rustdoc, //! but this should catch the majority of "broken link" cases. +#![deny(rust_2018_idioms)] + use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use std::env; @@ -21,7 +23,7 @@ use std::fs; use std::path::{Path, PathBuf, Component}; use std::rc::Rc; -use Redirect::*; +use crate::Redirect::*; macro_rules! t { ($e:expr) => (match $e { From 39394c8126dcea8570dc2108f0918478bfb6962e Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 18:18:39 +0100 Subject: [PATCH 05/30] libfmt_macros => 2018 --- src/libfmt_macros/Cargo.toml | 1 + src/libfmt_macros/lib.rs | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libfmt_macros/Cargo.toml b/src/libfmt_macros/Cargo.toml index b3f4d2deae2fc..50779a2d9ad08 100644 --- a/src/libfmt_macros/Cargo.toml +++ b/src/libfmt_macros/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "fmt_macros" version = "0.0.0" +edition = "2018" [lib] name = "fmt_macros" diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 4f516f18bbfdd..7bfe2377cea9e 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -10,14 +10,15 @@ html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] -#![feature(nll)] +#![deny(rust_2018_idioms)] + #![feature(rustc_private)] -pub use self::Piece::*; -pub use self::Position::*; -pub use self::Alignment::*; -pub use self::Flag::*; -pub use self::Count::*; +pub use Piece::*; +pub use Position::*; +pub use Alignment::*; +pub use Flag::*; +pub use Count::*; use std::str; use std::string; From 7f41ed62e5cb9a5af7f742f9c4515a6d3a9530c0 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 18:29:08 +0100 Subject: [PATCH 06/30] libgraphviz => 2018 --- src/libgraphviz/Cargo.toml | 1 + src/libgraphviz/lib.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libgraphviz/Cargo.toml b/src/libgraphviz/Cargo.toml index 76ef3a1d188ce..a6a3c1a249d64 100644 --- a/src/libgraphviz/Cargo.toml +++ b/src/libgraphviz/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "graphviz" version = "0.0.0" +edition = "2018" [lib] name = "graphviz" diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 164dec97b8fdb..f05f6e6651f83 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -276,10 +276,11 @@ html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(allow(unused_variables), deny(warnings))))] -#![feature(nll)] +#![deny(rust_2018_idioms)] + #![feature(str_escape)] -use self::LabelText::*; +use LabelText::*; use std::borrow::Cow; use std::io::prelude::*; @@ -548,12 +549,12 @@ impl<'a> LabelText<'a> { } /// Puts `prefix` on a line above this label, with a blank line separator. - pub fn prefix_line(self, prefix: LabelText) -> LabelText<'static> { + pub fn prefix_line(self, prefix: LabelText<'_>) -> LabelText<'static> { prefix.suffix_line(self) } /// Puts `suffix` on a line below this label, with a blank line separator. - pub fn suffix_line(self, suffix: LabelText) -> LabelText<'static> { + pub fn suffix_line(self, suffix: LabelText<'_>) -> LabelText<'static> { let mut prefix = self.pre_escaped_content().into_owned(); let suffix = suffix.pre_escaped_content(); prefix.push_str(r"\n\n"); @@ -686,7 +687,7 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G, #[cfg(test)] mod tests { - use self::NodeLabels::*; + use NodeLabels::*; use super::{Id, Labeller, Nodes, Edges, GraphWalk, render, Style}; use super::LabelText::{self, LabelStr, EscStr, HtmlStr}; use std::io; From 46c2c274f27df759a7947fc4804780bda7e3432c Mon Sep 17 00:00:00 2001 From: Denys Zariaiev Date: Sun, 3 Feb 2019 15:47:15 +0100 Subject: [PATCH 07/30] Add NVPTX target into `build-manifest` --- src/tools/build-manifest/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 4ca285b9b1db1..91cfa0981ac3d 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -78,6 +78,7 @@ static TARGETS: &'static [&'static str] = &[ "mips64el-unknown-linux-gnuabi64", "mipsel-unknown-linux-gnu", "mipsel-unknown-linux-musl", + "nvptx64-nvidia-cuda", "powerpc-unknown-linux-gnu", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", From 09275b5cb540e3a8431877321c72684df8ad8b07 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 18:42:38 +0100 Subject: [PATCH 08/30] libpanic_abort => 2018 --- src/libpanic_abort/Cargo.toml | 1 + src/libpanic_abort/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libpanic_abort/Cargo.toml b/src/libpanic_abort/Cargo.toml index e304e61c32936..2bee0b716c750 100644 --- a/src/libpanic_abort/Cargo.toml +++ b/src/libpanic_abort/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "panic_abort" version = "0.0.0" +edition = "2018" [lib] path = "lib.rs" diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index f6306d23c30c0..daa1998d29d72 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -10,11 +10,12 @@ html_root_url = "https://doc.rust-lang.org/nightly/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] #![panic_runtime] + #![allow(unused_features)] +#![deny(rust_2018_idioms)] #![feature(core_intrinsics)] #![feature(libc)] -#![feature(nll)] #![feature(panic_runtime)] #![feature(staged_api)] #![feature(rustc_attrs)] @@ -46,7 +47,6 @@ pub unsafe extern fn __rust_start_panic(_payload: usize) -> u32 { #[cfg(any(unix, target_os = "cloudabi"))] unsafe fn abort() -> ! { - extern crate libc; libc::abort(); } From 582bbcc161169591d7e8a9de70e9a4c844dd9321 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 3 Feb 2019 03:58:25 +0100 Subject: [PATCH 09/30] librustc_privacy => 2018 --- src/librustc_privacy/Cargo.toml | 1 + src/librustc_privacy/lib.rs | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml index dfc4e5b5db45d..5bf8024c56911 100644 --- a/src/librustc_privacy/Cargo.toml +++ b/src/librustc_privacy/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_privacy" version = "0.0.0" +edition = "2018" [lib] name = "rustc_privacy" diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 1bdc22b37d73b..dda8cabc4f2f4 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -2,18 +2,15 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] -#![feature(nll)] +#![deny(rust_2018_idioms)] + #![feature(rustc_diagnostic_macros)] #![recursion_limit="256"] -#[macro_use] extern crate rustc; #[macro_use] extern crate syntax; -#[macro_use] extern crate log; -extern crate rustc_typeck; -extern crate syntax_pos; -extern crate rustc_data_structures; +use rustc::bug; use rustc::hir::{self, Node, PatKind, AssociatedItemKind}; use rustc::hir::def::Def; use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, CrateNum, DefId}; @@ -1541,7 +1538,7 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> { let ret = self.required_visibility == ty::Visibility::Public && self.private_crates.contains(&item_id.krate); - debug!("leaks_private_dep(item_id={:?})={}", item_id, ret); + log::debug!("leaks_private_dep(item_id={:?})={}", item_id, ret); return ret; } } @@ -1705,7 +1702,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { privacy_access_levels, check_mod_privacy, From b5ca255cd45c3a73fcdbf97b6101f1119ff2932e Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Mon, 4 Feb 2019 00:34:55 +0900 Subject: [PATCH 10/30] Transition tidy and unstable-book-gento 2018 edition --- src/tools/tidy/src/main.rs | 1 + src/tools/tidy/src/unstable_book.rs | 2 +- src/tools/unstable-book-gen/Cargo.toml | 1 + src/tools/unstable-book-gen/src/main.rs | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 81b7b2a7731ae..6622403826665 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -4,6 +4,7 @@ //! etc. This is run by default on `make check` and as part of the auto //! builders. +#![deny(rust_2018_idioms)] #![deny(warnings)] extern crate tidy; diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs index bd3b1f033c761..e5f81ba29d8d3 100644 --- a/src/tools/tidy/src/unstable_book.rs +++ b/src/tools/tidy/src/unstable_book.rs @@ -1,7 +1,7 @@ use std::collections::BTreeSet; use std::fs; use std::path; -use features::{collect_lang_features, collect_lib_features, Features, Status}; +use crate::features::{collect_lang_features, collect_lib_features, Features, Status}; pub const PATH_STR: &str = "doc/unstable-book/src"; diff --git a/src/tools/unstable-book-gen/Cargo.toml b/src/tools/unstable-book-gen/Cargo.toml index 2839f93f8e279..3209de09aeb68 100644 --- a/src/tools/unstable-book-gen/Cargo.toml +++ b/src/tools/unstable-book-gen/Cargo.toml @@ -4,6 +4,7 @@ authors = ["est31 ", name = "unstable-book-gen" version = "0.1.0" license = "MIT/Apache-2.0" +edition = "2018" [dependencies] tidy = { path = "../tidy" } diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index df12eaf0cb028..427014ce7fe55 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -1,8 +1,9 @@ //! Auto-generate stub docs for the unstable book +#![deny(rust_2018_idioms)] #![deny(warnings)] -extern crate tidy; + use tidy::features::{Feature, Features, collect_lib_features, collect_lang_features}; use tidy::unstable_book::{collect_unstable_feature_names, collect_unstable_book_section_file_names, From 9851a296885cc745eccbc33858915d08e839eadc Mon Sep 17 00:00:00 2001 From: topecongiro Date: Mon, 4 Feb 2019 00:35:12 +0900 Subject: [PATCH 11/30] Add the span of attributes of the lhs to the span of the assignment expression --- src/libsyntax/parse/parser.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 514b2952c5036..1c02a80df4683 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3455,6 +3455,14 @@ impl<'a> Parser<'a> { }), }?; + // Make sure that the span of the parent node is larger than the span of lhs and rhs, + // including the attributes. + let lhs_span = lhs + .attrs + .iter() + .filter(|a| a.style == AttrStyle::Outer) + .next() + .map_or(lhs_span, |a| a.span); let span = lhs_span.to(rhs.span); lhs = match op { AssocOp::Add | AssocOp::Subtract | AssocOp::Multiply | AssocOp::Divide | From d11d1afa64ca2c29747074bce0f7bb2278b5ae66 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Mon, 4 Feb 2019 00:45:42 +0900 Subject: [PATCH 12/30] Transition rustdoc-theme to 2018 edition --- src/tools/rustdoc-themes/Cargo.toml | 1 + src/tools/rustdoc-themes/main.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/tools/rustdoc-themes/Cargo.toml b/src/tools/rustdoc-themes/Cargo.toml index c0e2f527301be..c12a20fd56c7b 100644 --- a/src/tools/rustdoc-themes/Cargo.toml +++ b/src/tools/rustdoc-themes/Cargo.toml @@ -2,6 +2,7 @@ name = "rustdoc-themes" version = "0.1.0" authors = ["Guillaume Gomez "] +edition = "2018" [[bin]] name = "rustdoc-themes" diff --git a/src/tools/rustdoc-themes/main.rs b/src/tools/rustdoc-themes/main.rs index 616b5444832c1..63432a6585a84 100644 --- a/src/tools/rustdoc-themes/main.rs +++ b/src/tools/rustdoc-themes/main.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms)] + use std::env::args; use std::fs::read_dir; use std::path::Path; From 5440149229068ef202af1b59846d123a24e4c62f Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 4 Feb 2019 06:00:16 +0900 Subject: [PATCH 13/30] libunwind => 2018 --- src/libunwind/Cargo.toml | 1 + src/libunwind/lib.rs | 4 ++-- src/libunwind/libunwind.rs | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libunwind/Cargo.toml b/src/libunwind/Cargo.toml index 2577d6dd31d8f..2378b0a315a16 100644 --- a/src/libunwind/Cargo.toml +++ b/src/libunwind/Cargo.toml @@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"] name = "unwind" version = "0.0.0" build = "build.rs" +edition = "2018" [lib] name = "unwind" diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs index 5f9c82431b786..b9a9929ef8b87 100644 --- a/src/libunwind/lib.rs +++ b/src/libunwind/lib.rs @@ -1,8 +1,9 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] +#![deny(rust_2018_idioms)] + #![feature(link_cfg)] -#![feature(nll)] #![feature(staged_api)] #![feature(unwind_attributes)] #![feature(static_nobundle)] @@ -18,7 +19,6 @@ cfg_if! { } else if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] { // no unwinder on the system! } else { - extern crate libc; mod libunwind; pub use libunwind::*; } diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 31e806c8fb656..339b554ed6abd 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -21,7 +21,7 @@ pub enum _Unwind_Reason_Code { _URC_CONTINUE_UNWIND = 8, _URC_FAILURE = 9, // used only by ARM EHABI } -pub use self::_Unwind_Reason_Code::*; +pub use _Unwind_Reason_Code::*; pub type _Unwind_Exception_Class = u64; pub type _Unwind_Word = uintptr_t; @@ -94,7 +94,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm _UA_FORCE_UNWIND = 8, _UA_END_OF_STACK = 16, } - pub use self::_Unwind_Action::*; + pub use _Unwind_Action::*; extern "C" { pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word; @@ -118,7 +118,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm _US_FORCE_UNWIND = 8, _US_END_OF_STACK = 16, } - pub use self::_Unwind_State::*; + pub use _Unwind_State::*; #[repr(C)] enum _Unwind_VRS_Result { @@ -134,7 +134,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm _UVRSC_WMMXD = 3, _UVRSC_WMMXC = 4, } - use self::_Unwind_VRS_RegClass::*; + use _Unwind_VRS_RegClass::*; #[repr(C)] enum _Unwind_VRS_DataRepresentation { _UVRSD_UINT32 = 0, @@ -144,7 +144,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm _UVRSD_FLOAT = 4, _UVRSD_DOUBLE = 5, } - use self::_Unwind_VRS_DataRepresentation::*; + use _Unwind_VRS_DataRepresentation::*; pub const UNWIND_POINTER_REG: c_int = 12; pub const UNWIND_IP_REG: c_int = 15; From 526a398c77e7be8b437ea4b7cae06e0f3a026155 Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Mon, 4 Feb 2019 18:04:33 +0900 Subject: [PATCH 14/30] Fix #58101 --- src/librustc/middle/stability.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 3717ee7143c55..c726885337ea8 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -765,7 +765,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } EvalResult::Unmarked => { - span_bug!(span, "encountered unmarked API: {:?}", def_id); + // The API could be uncallable for other reasons, for example when a private module + // was referenced. + self.sess.delay_span_bug(span, &format!("encountered unmarked API: {:?}", def_id)); } } } From e3bbd67110e977a0f17b5d9009b86563826e5df4 Mon Sep 17 00:00:00 2001 From: lukaslueg Date: Mon, 4 Feb 2019 11:21:39 +0100 Subject: [PATCH 15/30] Remove weasel word in docs for iter's take_while() The phrase "... or some similar thing." is very vague and contributes nothing to understanding the example. Simply removed. --- src/libcore/iter/traits/iterator.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index 9dfa83f473baf..218c7199f35a6 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -952,8 +952,7 @@ pub trait Iterator { /// ``` /// /// The `3` is no longer there, because it was consumed in order to see if - /// the iteration should stop, but wasn't placed back into the iterator or - /// some similar thing. + /// the iteration should stop, but wasn't placed back into the iterator. #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn take_while

(self, predicate: P) -> TakeWhile where From 652f2c753aed97261f5d988f0a2b50aa6508964c Mon Sep 17 00:00:00 2001 From: ishitatsuyuki Date: Mon, 4 Feb 2019 19:26:46 +0900 Subject: [PATCH 16/30] Add test --- src/test/ui/stability-in-private-module.rs | 4 ++++ src/test/ui/stability-in-private-module.stderr | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/test/ui/stability-in-private-module.rs create mode 100644 src/test/ui/stability-in-private-module.stderr diff --git a/src/test/ui/stability-in-private-module.rs b/src/test/ui/stability-in-private-module.rs new file mode 100644 index 0000000000000..f12e9198b0d7c --- /dev/null +++ b/src/test/ui/stability-in-private-module.rs @@ -0,0 +1,4 @@ +fn main() { + let _ = std::thread::thread_info::current_thread(); + //~^ERROR module `thread_info` is private +} diff --git a/src/test/ui/stability-in-private-module.stderr b/src/test/ui/stability-in-private-module.stderr new file mode 100644 index 0000000000000..c3edd62a15eda --- /dev/null +++ b/src/test/ui/stability-in-private-module.stderr @@ -0,0 +1,9 @@ +error[E0603]: module `thread_info` is private + --> $DIR/stability-in-private-module.rs:2:26 + | +LL | let _ = std::thread::thread_info::current_thread(); + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. From 82df9d7434c949b4357fb4c80c36961404226f93 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Mon, 4 Feb 2019 16:02:54 +0530 Subject: [PATCH 17/30] Remove stray FIXME --- src/libstd/sys/sgx/rwlock.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libstd/sys/sgx/rwlock.rs b/src/libstd/sys/sgx/rwlock.rs index 43ceae7d33b8d..33163a556c16d 100644 --- a/src/libstd/sys/sgx/rwlock.rs +++ b/src/libstd/sys/sgx/rwlock.rs @@ -19,9 +19,6 @@ unsafe fn rw_lock_size_assert(r: RWLock) { mem::transmute::(r); } -//unsafe impl Send for RWLock {} -//unsafe impl Sync for RWLock {} // FIXME - impl RWLock { pub const fn new() -> RWLock { RWLock { From 4847c097b46265963bbf9cd8006456b3ff31169b Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 4 Feb 2019 22:41:39 +0900 Subject: [PATCH 18/30] Add #[must_use] to core::task::Poll --- src/libcore/task/poll.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/task/poll.rs b/src/libcore/task/poll.rs index 27b1139e15c79..ac656153519e1 100644 --- a/src/libcore/task/poll.rs +++ b/src/libcore/task/poll.rs @@ -7,6 +7,7 @@ use result::Result; /// Indicates whether a value is available or if the current task has been /// scheduled to receive a wakeup instead. +#[must_use = "this `Poll` may be a `Pending` variant, which should be handled"] #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum Poll { /// Represents that a value is immediately ready. From 927614ff3ea38014549e24152fd3198532919b2c Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 4 Feb 2019 11:09:32 +0100 Subject: [PATCH 19/30] hir: more HirId methods --- src/librustc/hir/map/mod.rs | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 977ab05b20932..d35306ba353a3 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -401,6 +401,12 @@ impl<'hir> Map<'hir> { } } + // FIXME(@ljedrz): replace the NodeId variant + pub fn describe_def_by_hir_id(&self, hir_id: HirId) -> Option { + let node_id = self.hir_to_node_id(hir_id); + self.describe_def(node_id) + } + fn entry_count(&self) -> usize { self.map.len() } @@ -445,6 +451,12 @@ impl<'hir> Map<'hir> { } } + // FIXME(@ljedrz): replace the NodeId variant + pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option { + let node_id = self.hir_to_node_id(hir_id); + self.fn_decl(node_id) + } + /// Returns the `NodeId` that corresponds to the definition of /// which this is the body of, i.e., a `fn`, `const` or `static` /// item (possibly associated), a closure, or a `hir::AnonConst`. @@ -855,6 +867,12 @@ impl<'hir> Map<'hir> { self.local_def_id(self.get_parent(id)) } + // FIXME(@ljedrz): replace the NodeId variant + pub fn get_parent_did_by_hir_id(&self, id: HirId) -> DefId { + let node_id = self.hir_to_node_id(id); + self.get_parent_did(node_id) + } + pub fn get_foreign_abi(&self, id: NodeId) -> Abi { let parent = self.get_parent(id); if let Some(entry) = self.find_entry(parent) { @@ -868,6 +886,12 @@ impl<'hir> Map<'hir> { bug!("expected foreign mod or inlined parent, found {}", self.node_to_string(parent)) } + // FIXME(@ljedrz): replace the NodeId variant + pub fn get_foreign_abi_by_hir_id(&self, id: HirId) -> Abi { + let node_id = self.hir_to_node_id(id); + self.get_foreign_abi(node_id) + } + pub fn expect_item(&self, id: NodeId) -> &'hir Item { match self.find(id) { // read recorded by `find` Some(Node::Item(item)) => item, @@ -888,6 +912,18 @@ impl<'hir> Map<'hir> { } } + // FIXME(@ljedrz): replace the NodeId variant + pub fn expect_impl_item_by_hir_id(&self, id: HirId) -> &'hir ImplItem { + let node_id = self.hir_to_node_id(id); + self.expect_impl_item(node_id) + } + + // FIXME(@ljedrz): replace the NodeId variant + pub fn expect_trait_item_by_hir_id(&self, id: HirId) -> &'hir TraitItem { + let node_id = self.hir_to_node_id(id); + self.expect_trait_item(node_id) + } + pub fn expect_trait_item(&self, id: NodeId) -> &'hir TraitItem { match self.find(id) { Some(Node::TraitItem(item)) => item, @@ -931,6 +967,12 @@ impl<'hir> Map<'hir> { } } + // FIXME(@ljedrz): replace the NodeId variant + pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr { + let node_id = self.hir_to_node_id(id); + self.expect_expr(node_id) + } + /// Returns the name associated with the given NodeId's AST. pub fn name(&self, id: NodeId) -> Name { match self.get(id) { @@ -948,6 +990,12 @@ impl<'hir> Map<'hir> { } } + // FIXME(@ljedrz): replace the NodeId variant + pub fn name_by_hir_id(&self, id: HirId) -> Name { + let node_id = self.hir_to_node_id(id); + self.name(node_id) + } + /// Given a node ID, get a list of attributes associated with the AST /// corresponding to the Node ID pub fn attrs(&self, id: NodeId) -> &'hir [ast::Attribute] { @@ -970,6 +1018,12 @@ impl<'hir> Map<'hir> { attrs.unwrap_or(&[]) } + // FIXME(@ljedrz): replace the NodeId variant + pub fn attrs_by_hir_id(&self, id: HirId) -> &'hir [ast::Attribute] { + let node_id = self.hir_to_node_id(id); + self.attrs(node_id) + } + /// Returns an iterator that yields the node id's with paths that /// match `parts`. (Requires `parts` is non-empty.) /// @@ -1019,6 +1073,12 @@ impl<'hir> Map<'hir> { } } + // FIXME(@ljedrz): replace the NodeId variant + pub fn span_by_hir_id(&self, id: HirId) -> Span { + let node_id = self.hir_to_node_id(id); + self.span(node_id) + } + pub fn span_if_local(&self, id: DefId) -> Option { self.as_local_node_id(id).map(|id| self.span(id)) } From 59ea75b51ce3100d8e176551b41ec99330b8e011 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 4 Feb 2019 19:27:43 +0100 Subject: [PATCH 20/30] add more debugging code to track down appveyor 259 exit code --- appveyor.yml | 5 ++++- src/ci/run.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d70ad54b1c812..0ec4210af98b2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -207,7 +207,10 @@ test_script: - sh src/ci/init_repo.sh . /c/cache/rustsrc - set SRC=. - set NO_CCACHE=1 - - sh src/ci/run.sh + # Added this debugging code to try tracking down https://github.com/rust-lang/rust/issues/58160 + # Replace it with the commented line below after the issue with AppVeyor is fixed + - "sh src/ci/run.sh & set ret=%errorlevel% & echo exit code in appveyor.yml: %ret% & exit %ret%" +# - sh src/ci/run.sh on_failure: # Dump crash log diff --git a/src/ci/run.sh b/src/ci/run.sh index 0f2517c7d1f55..b8b1052c41c12 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -127,7 +127,7 @@ if [ ! -z "$SCRIPT" ]; then set +e sh -x -c "$SCRIPT" ret=$? - echo "script exited with $ret" + echo "exit code in src/ci/run.sh: $ret" exit $ret else do_make() { From 57c4c2863d4e1a18d668fdd79cab210105deb13c Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 4 Feb 2019 14:43:30 -0700 Subject: [PATCH 21/30] Update contributor name in .mailmap --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index a928606b693e5..d265f45c5cafa 100644 --- a/.mailmap +++ b/.mailmap @@ -155,6 +155,7 @@ Matt Brubeck Matthew Auld Matthew McPherrin Matthijs Hofstra +Melody Horn Michael Williams Michael Woerister Mickaƫl Raybaud-Roig m-r-r From 75b19579fb22b91ded35cdda3c381b17faa63798 Mon Sep 17 00:00:00 2001 From: garyemerson Date: Mon, 4 Feb 2019 15:26:33 -0800 Subject: [PATCH 22/30] update split docs Some confusion about split popped up at https://news.ycombinator.com/item?id=19080931 since the docs sorta sound like `&str`, `char` and closures are the only types that can be patterns. cc @steveklabnik --- src/libcore/str/mod.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 130142103a9ba..e9190cc3ddf1b 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -2961,8 +2961,8 @@ impl str { /// An iterator over substrings of this string slice, separated by /// characters matched by a pattern. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines the - /// split. + /// The pattern can be any type that implements the Pattern trait. Notable + /// examples are `&str`, [`char`], and closures that determines the split. /// /// # Iterator behavior /// @@ -3078,8 +3078,8 @@ impl str { /// An iterator over substrings of the given string slice, separated by /// characters matched by a pattern and yielded in reverse order. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines the - /// split. + /// The pattern can be any type that implements the Pattern trait. Notable + /// examples are `&str`, [`char`], and closures that determines the split. /// /// # Iterator behavior /// @@ -3128,8 +3128,8 @@ impl str { /// An iterator over substrings of the given string slice, separated by /// characters matched by a pattern. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines the - /// split. + /// The pattern can be any type that implements the Pattern trait. Notable + /// examples are `&str`, [`char`], and closures that determines the split. /// /// Equivalent to [`split`], except that the trailing substring /// is skipped if empty. @@ -3175,8 +3175,8 @@ impl str { /// An iterator over substrings of `self`, separated by characters /// matched by a pattern and yielded in reverse order. /// - /// The pattern can be a simple `&str`, [`char`], or a closure that - /// determines the split. + /// The pattern can be any type that implements the Pattern trait. Notable + /// examples are `&str`, [`char`], and closures that determines the split. /// Additional libraries might provide more complex patterns like /// regular expressions. /// @@ -3222,8 +3222,8 @@ impl str { /// If `n` substrings are returned, the last substring (the `n`th substring) /// will contain the remainder of the string. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines the - /// split. + /// The pattern can be any type that implements the Pattern trait. Notable + /// examples are `&str`, [`char`], and closures that determines the split. /// /// # Iterator behavior /// @@ -3275,8 +3275,8 @@ impl str { /// If `n` substrings are returned, the last substring (the `n`th substring) /// will contain the remainder of the string. /// - /// The pattern can be a `&str`, [`char`], or a closure that - /// determines the split. + /// The pattern can be any type that implements the Pattern trait. Notable + /// examples are `&str`, [`char`], and closures that determines the split. /// /// # Iterator behavior /// @@ -3319,8 +3319,8 @@ impl str { /// An iterator over the disjoint matches of a pattern within the given string /// slice. /// - /// The pattern can be a `&str`, [`char`], or a closure that - /// determines if a character matches. + /// The pattern can be any type that implements the Pattern trait. Notable + /// examples are `&str`, [`char`], and closures that determines the split. /// /// # Iterator behavior /// From 5d9eed4191c3edae4704737a95706dcf714334f8 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Mon, 4 Feb 2019 00:05:53 +0900 Subject: [PATCH 23/30] Transition build-manifest to 2018 edition --- src/tools/build-manifest/Cargo.toml | 1 + src/tools/build-manifest/src/main.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index 844b7aad72fde..0fda887ea61fe 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -2,6 +2,7 @@ name = "build-manifest" version = "0.1.0" authors = ["Alex Crichton "] +edition = "2018" [dependencies] toml = "0.4" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 4ca285b9b1db1..5e8559725f134 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -1,4 +1,6 @@ -extern crate toml; +#![deny(rust_2018_idioms)] + +use toml; #[macro_use] extern crate serde_derive; From 212533afbe352e74c6c8bb64c2d8b526cfa15350 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Tue, 5 Feb 2019 01:11:08 +0900 Subject: [PATCH 24/30] Remove macro_use --- src/tools/build-manifest/src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 5e8559725f134..9d88ac8dd0498 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -1,8 +1,7 @@ #![deny(rust_2018_idioms)] use toml; -#[macro_use] -extern crate serde_derive; +use serde_derive::Serialize; use std::collections::BTreeMap; use std::env; From 6904fac6d915b9bb3538ac2e6fbd31ad301a64c8 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Tue, 5 Feb 2019 10:51:47 +0900 Subject: [PATCH 25/30] Use derive feature of serde --- src/tools/build-manifest/Cargo.toml | 2 +- src/tools/build-manifest/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index 0fda887ea61fe..93d0f61e1d9f0 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -6,5 +6,5 @@ edition = "2018" [dependencies] toml = "0.4" -serde = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_derive = "1.0" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 9d88ac8dd0498..335cd617759a9 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -1,7 +1,7 @@ #![deny(rust_2018_idioms)] use toml; -use serde_derive::Serialize; +use serde::Serialize; use std::collections::BTreeMap; use std::env; From 47a587fb2b8f654aa165e2f87e533bc99b1546fd Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Tue, 5 Feb 2019 10:59:18 +0900 Subject: [PATCH 26/30] Remove unncessary return statement --- src/tools/build-manifest/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 335cd617759a9..a51eb4b4a10ad 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -469,7 +469,7 @@ impl Builder { } manifest.pkg.insert("rust".to_string(), pkg); - return manifest; + manifest } fn profile(&mut self, From 2bfb4b336fc8fcd499c36dbc997dd18c7a5e62cf Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 5 Feb 2019 08:47:52 +0100 Subject: [PATCH 27/30] add even more debugging code to track down appveyor 259 exit code --- src/ci/run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ci/run.sh b/src/ci/run.sh index b8b1052c41c12..0841e70a6ed29 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -128,6 +128,12 @@ if [ ! -z "$SCRIPT" ]; then sh -x -c "$SCRIPT" ret=$? echo "exit code in src/ci/run.sh: $ret" + + echo "tasklist:" + tasklist + echo -n "location of sh: " + where sh + exit $ret else do_make() { From 4c8c0fc1e2145b520ef31d1bf5e4d3fa1050c579 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Tue, 5 Feb 2019 16:19:05 +0530 Subject: [PATCH 28/30] SGX target: handle empty user buffers correctly --- src/libstd/sys/sgx/abi/usercalls/alloc.rs | 7 ++++++- src/libstd/sys/sgx/abi/usercalls/mod.rs | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index 8d0013a235ac7..2efbaa9b1487a 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -537,7 +537,12 @@ impl UserRef { pub fn copy_user_buffer(&self) -> Vec { unsafe { let buf = self.to_enclave(); - User::from_raw_parts(buf.data as _, buf.len).to_enclave() + if buf.len > 0 { + User::from_raw_parts(buf.data as _, buf.len).to_enclave() + } else { + // Mustn't look at `data` or call `free` if `len` is `0`. + Vec::with_capacity(0) + } } } } diff --git a/src/libstd/sys/sgx/abi/usercalls/mod.rs b/src/libstd/sys/sgx/abi/usercalls/mod.rs index 58903761ebe40..511d6e9e9273a 100644 --- a/src/libstd/sys/sgx/abi/usercalls/mod.rs +++ b/src/libstd/sys/sgx/abi/usercalls/mod.rs @@ -22,7 +22,8 @@ pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult { #[unstable(feature = "sgx_platform", issue = "56975")] pub fn read_alloc(fd: Fd) -> IoResult> { unsafe { - let mut userbuf = alloc::User::::uninitialized(); + let userbuf = ByteBuffer { data: ::ptr::null_mut(), len: 0 }; + let mut userbuf = alloc::User::new_from_enclave(&userbuf); raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?; Ok(userbuf.copy_user_buffer()) } From d89ebdd475ceaa35173e7d39dfdf23f8b7318745 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Tue, 5 Feb 2019 16:19:20 +0530 Subject: [PATCH 29/30] Expose correct items in `os::fortanix_sgx::usercalls::alloc` --- src/libstd/os/fortanix_sgx/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/os/fortanix_sgx/mod.rs b/src/libstd/os/fortanix_sgx/mod.rs index 810965fc1b85a..f536c5d04e6ee 100644 --- a/src/libstd/os/fortanix_sgx/mod.rs +++ b/src/libstd/os/fortanix_sgx/mod.rs @@ -16,7 +16,7 @@ pub mod usercalls { /// Primitives for allocating memory in userspace as well as copying data /// to and from user memory. pub mod alloc { - pub use sys::abi::usercalls::alloc; + pub use sys::abi::usercalls::alloc::*; } /// Lowest-level interfaces to usercalls and usercall ABI type definitions. From 014ffa3ac9e499fc0c3f03b7e902be6d819d02f3 Mon Sep 17 00:00:00 2001 From: liv Date: Tue, 5 Feb 2019 15:32:59 +0100 Subject: [PATCH 30/30] Add Rustlings to the doc index --- src/doc/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/doc/index.md b/src/doc/index.md index 7a240ac0a42a5..0a2a80e8fd6e2 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -52,6 +52,12 @@ If reading multiple hundreds of pages about a language isn't your style, then a lot of words, RBE shows off a bunch of code, and keeps the talking to a minimum. It also includes exercises! +## Rustlings + +[Rustlings](https://github.com/rust-lang/rustlings) guides you through downloading and setting up the Rust toolchain, +and teaches you the basics of reading and writing Rust syntax. It's an +alternative to Rust by Example that works with your own environment. + # Use Rust Once you've gotten familiar with the language, these resources can help you