From 1fd2f1687c6483fd3386f838c30332215c3f32b2 Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Mon, 25 Feb 2019 16:44:04 +0100 Subject: [PATCH 01/20] Have all methods of Filter and FilterMap use internal iteration --- src/libcore/iter/adapters/mod.rs | 37 ++++++-------------------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs index bca1b76dbb975..d4ad22c16bbfa 100644 --- a/src/libcore/iter/adapters/mod.rs +++ b/src/libcore/iter/adapters/mod.rs @@ -681,12 +681,7 @@ impl Iterator for Filter where P: FnMut(&I::Item) -> bool #[inline] fn next(&mut self) -> Option { - for x in &mut self.iter { - if (self.predicate)(&x) { - return Some(x); - } - } - None + self.try_for_each(Err).err() } #[inline] @@ -707,12 +702,9 @@ impl Iterator for Filter where P: FnMut(&I::Item) -> bool // Using the branchless version will also simplify the LLVM byte code, thus // leaving more budget for LLVM optimizations. #[inline] - fn count(mut self) -> usize { - let mut count = 0; - for x in &mut self.iter { - count += (self.predicate)(&x) as usize; - } - count + fn count(self) -> usize { + let mut predicate = self.predicate; + self.iter.map(|x| predicate(&x) as usize).sum() } #[inline] @@ -746,12 +738,7 @@ impl DoubleEndedIterator for Filter { #[inline] fn next_back(&mut self) -> Option { - for x in self.iter.by_ref().rev() { - if (self.predicate)(&x) { - return Some(x); - } - } - None + self.try_rfold((), |_, x| Err(x)).err() } #[inline] @@ -820,12 +807,7 @@ impl Iterator for FilterMap #[inline] fn next(&mut self) -> Option { - for x in self.iter.by_ref() { - if let Some(y) = (self.f)(x) { - return Some(y); - } - } - None + self.try_for_each(Err).err() } #[inline] @@ -863,12 +845,7 @@ impl DoubleEndedIterator for FilterMap { #[inline] fn next_back(&mut self) -> Option { - for x in self.iter.by_ref().rev() { - if let Some(y) = (self.f)(x) { - return Some(y); - } - } - None + self.try_rfold((), |_, x| Err(x)).err() } #[inline] From 88847718f0cca57124cbd1bce12fc938c5bde088 Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Wed, 27 Feb 2019 11:44:30 +0100 Subject: [PATCH 02/20] Add relevant benchmarks --- src/libcore/benches/iter.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/libcore/benches/iter.rs b/src/libcore/benches/iter.rs index fe852e42b5cd3..5cc2bce846d87 100644 --- a/src/libcore/benches/iter.rs +++ b/src/libcore/benches/iter.rs @@ -306,3 +306,31 @@ fn bench_skip_then_zip(b: &mut Bencher) { assert_eq!(s, 2009900); }); } + +#[bench] +fn bench_filter_count(b: &mut Bencher) { + b.iter(|| { + (0i64..1000000).map(black_box).filter(|x| x % 3 == 0).count() + }) +} + +#[bench] +fn bench_filter_ref_count(b: &mut Bencher) { + b.iter(|| { + (0i64..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count() + }) +} + +#[bench] +fn bench_filter_chain_count(b: &mut Bencher) { + b.iter(|| { + (0i64..1000000).chain(0..1000000).map(black_box).filter(|x| x % 3 == 0).count() + }) +} + +#[bench] +fn bench_filter_chain_ref_count(b: &mut Bencher) { + b.iter(|| { + (0i64..1000000).chain(0..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count() + }) +} \ No newline at end of file From ec2e4ba919a65a972019925b5b33d0f309f467fc Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Wed, 27 Feb 2019 11:46:37 +0100 Subject: [PATCH 03/20] Improve existing benchmarks to prevent extreme optimizations --- src/libcore/benches/iter.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/benches/iter.rs b/src/libcore/benches/iter.rs index 5cc2bce846d87..4f3d6f379022b 100644 --- a/src/libcore/benches/iter.rs +++ b/src/libcore/benches/iter.rs @@ -185,13 +185,13 @@ bench_sums! { bench_sums! { bench_filter_sum, bench_filter_ref_sum, - (0i64..1000000).filter(|x| x % 2 == 0) + (0i64..1000000).filter(|x| x % 3 == 0) } bench_sums! { bench_filter_chain_sum, bench_filter_chain_ref_sum, - (0i64..1000000).chain(0..1000000).filter(|x| x % 2 == 0) + (0i64..1000000).chain(0..1000000).filter(|x| x % 3 == 0) } bench_sums! { From 88bd624a88692dd4bbda5f3f324f0035dc041534 Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Wed, 27 Feb 2019 13:22:18 +0100 Subject: [PATCH 04/20] Add trailing newline --- src/libcore/benches/iter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/benches/iter.rs b/src/libcore/benches/iter.rs index 4f3d6f379022b..1dd2bd3ee78aa 100644 --- a/src/libcore/benches/iter.rs +++ b/src/libcore/benches/iter.rs @@ -333,4 +333,4 @@ fn bench_filter_chain_ref_count(b: &mut Bencher) { b.iter(|| { (0i64..1000000).chain(0..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count() }) -} \ No newline at end of file +} From 4e7d4c7778a00371ba707fb8f9022bcbb443bb29 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 27 Feb 2019 15:32:32 +0100 Subject: [PATCH 05/20] ManuallyDrop != MaybeUninit --- src/libcore/mem.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index f41d293e80ad3..6b1b91d00faa7 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -900,10 +900,16 @@ pub fn discriminant(v: &T) -> Discriminant { } } +// FIXME: Reference `MaybeUninit` from these docs, once that is stable. /// A wrapper to inhibit compiler from automatically calling `T`’s destructor. /// /// This wrapper is 0-cost. /// +/// `ManuallyDrop` is subject to the same layout optimizations as `T`. +/// As a consequence, it has *no effect* on the assumptions that the compiler makes +/// about all values being initialized at their type. In particular, initializing +/// a `ManuallyDrop<&T>` with [`mem::zeroed`] is undefined behavior. +/// /// # Examples /// /// This wrapper helps with explicitly documenting the drop order dependencies between fields of @@ -935,6 +941,8 @@ pub fn discriminant(v: &T) -> Discriminant { /// } /// } /// ``` +/// +/// [`mem::zeroed']: fn.zeroed.html #[stable(feature = "manually_drop", since = "1.20.0")] #[lang = "manually_drop"] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] From b70a9532a9d3e2ae4b9bf7bc4a4a0bfc7dbe134b Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Wed, 20 Feb 2019 15:11:22 +0100 Subject: [PATCH 06/20] Replace `s` with `self` in docs for str methods taking self. --- src/libcore/str/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 8b51d8465141a..53334adadb856 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -3965,7 +3965,7 @@ impl str { me.make_ascii_lowercase() } - /// Return an iterator that escapes each char in `s` with [`char::escape_debug`]. + /// Return an iterator that escapes each char in `self` with [`char::escape_debug`]. /// /// Note: only extended grapheme codepoints that begin the string will be /// escaped. @@ -4013,7 +4013,7 @@ impl str { } } - /// Return an iterator that escapes each char in `s` with [`char::escape_default`]. + /// Return an iterator that escapes each char in `self` with [`char::escape_default`]. /// /// [`char::escape_default`]: ../std/primitive.char.html#method.escape_default /// @@ -4051,7 +4051,7 @@ impl str { EscapeDefault { inner: self.chars().flat_map(CharEscapeDefault) } } - /// Return an iterator that escapes each char in `s` with [`char::escape_unicode`]. + /// Return an iterator that escapes each char in `self` with [`char::escape_unicode`]. /// /// [`char::escape_unicode`]: ../std/primitive.char.html#method.escape_unicode /// From f92c20426ea5f5ddcc6dcf73dbe0739d3d76b614 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 27 Feb 2019 18:58:19 +0100 Subject: [PATCH 07/20] improve readability --- src/libcore/mem.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 6b1b91d00faa7..f78213ba9f672 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -908,7 +908,7 @@ pub fn discriminant(v: &T) -> Discriminant { /// `ManuallyDrop` is subject to the same layout optimizations as `T`. /// As a consequence, it has *no effect* on the assumptions that the compiler makes /// about all values being initialized at their type. In particular, initializing -/// a `ManuallyDrop<&T>` with [`mem::zeroed`] is undefined behavior. +/// a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined behavior. /// /// # Examples /// From a998b1f425bc13d891ed5b28f1b708970f9db4b4 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 27 Feb 2019 10:56:58 -0500 Subject: [PATCH 08/20] allow specifying attributes for tool lints --- src/librustc/lint/mod.rs | 20 +++++++++++++------ .../ui-fulldeps/auxiliary/lint_tool_test.rs | 6 +++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index dd003e44bea09..496ff568b31b4 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -132,14 +132,22 @@ macro_rules! declare_lint { #[macro_export] macro_rules! declare_tool_lint { - ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr) => ( - declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, false} + ( + $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr + ) => ( + declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false} ); - ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr, - report_in_external_macro: $rep: expr) => ( - declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, $rep} + ( + $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr, + report_in_external_macro: $rep:expr + ) => ( + declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep} ); - ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr, $external: expr) => ( + ( + $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr, + $external:expr + ) => ( + $(#[$attr])* $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { name: &concat!(stringify!($tool), "::", stringify!($NAME)), default_level: $crate::lint::$Level, diff --git a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs index 1a9bd9e66dbac..d25a5ea374627 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs @@ -13,7 +13,11 @@ use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, use rustc_plugin::Registry; use syntax::ast; declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff"); -declare_tool_lint!(pub clippy::TEST_GROUP, Warn, "Warn about other stuff"); +declare_tool_lint!( + /// Some docs + pub clippy::TEST_GROUP, + Warn, "Warn about other stuff" +); struct Pass; From fbdece47c84aa1161b01c86457ee193dd434387d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 28 Feb 2019 19:10:43 +1100 Subject: [PATCH 09/20] Ensure `record_layout_for_printing()` is inlined. This reduces instruction counts for the `ctfe-stress-2` benchmark by about 1%. --- src/librustc/ty/layout.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 6c507c0015d7b..7d2b21b9aecda 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1176,14 +1176,20 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { /// This is invoked by the `layout_raw` query to record the final /// layout of each type. - #[inline] + #[inline(always)] fn record_layout_for_printing(&self, layout: TyLayout<'tcx>) { - // If we are running with `-Zprint-type-sizes`, record layouts for - // dumping later. Ignore layouts that are done with non-empty - // environments or non-monomorphic layouts, as the user only wants - // to see the stuff resulting from the final codegen session. + // If we are running with `-Zprint-type-sizes`, maybe record layouts + // for dumping later. + if self.tcx.sess.opts.debugging_opts.print_type_sizes { + self.record_layout_for_printing_outlined(layout) + } + } + + fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) { + // Ignore layouts that are done with non-empty environments or + // non-monomorphic layouts, as the user only wants to see the stuff + // resulting from the final codegen session. if - !self.tcx.sess.opts.debugging_opts.print_type_sizes || layout.ty.has_param_types() || layout.ty.has_self_ty() || !self.param_env.caller_bounds.is_empty() @@ -1191,10 +1197,6 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { return; } - self.record_layout_for_printing_outlined(layout) - } - - fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) { // (delay format until we actually need it) let record = |kind, packed, opt_discr_size, variants| { let type_desc = format!("{:?}", layout.ty); From 0c1a38ce3b281ce23b9ba84312f58ba6ac82af57 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 28 Feb 2019 09:24:35 +0100 Subject: [PATCH 10/20] Update src/libcore/mem.rs Co-Authored-By: RalfJung --- src/libcore/mem.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index f78213ba9f672..94f342e7e8efc 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -942,7 +942,7 @@ pub fn discriminant(v: &T) -> Discriminant { /// } /// ``` /// -/// [`mem::zeroed']: fn.zeroed.html +/// [`mem::zeroed`]: fn.zeroed.html #[stable(feature = "manually_drop", since = "1.20.0")] #[lang = "manually_drop"] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] From 96be181c7ed004b2892addc22c285b321e029fd9 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 28 Feb 2019 16:34:03 -0500 Subject: [PATCH 11/20] Fixed a syntax error in the pin docs --- src/libcore/pin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index f9f20dcea9e2e..835357b4e017c 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -215,7 +215,7 @@ //! had a method `fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T>`. //! Then we could do the following: //! ```compile_fail -//! fn exploit_ref_cell(rc: Pin<&mut RefCell) { +//! fn exploit_ref_cell(rc: Pin<&mut RefCell>) { //! { let p = rc.as_mut().get_pin_mut(); } // Here we get pinned access to the `T`. //! let rc_shr: &RefCell = rc.into_ref().get_ref(); //! let b = rc_shr.borrow_mut(); From 3391f6ce8083ea860009caa99b415b402feeddd1 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 1 Mar 2019 10:14:09 +0100 Subject: [PATCH 12/20] tidy: deny(rust_2018_idioms) --- src/tools/tidy/src/deps.rs | 12 ++++++------ src/tools/tidy/src/features.rs | 2 +- src/tools/tidy/src/lib.rs | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 94dd5478e5297..0169725fa2968 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -49,13 +49,13 @@ const EXCEPTIONS: &[&str] = &[ ]; /// Which crates to check against the whitelist? -const WHITELIST_CRATES: &[CrateVersion] = &[ +const WHITELIST_CRATES: &[CrateVersion<'_>] = &[ CrateVersion("rustc", "0.0.0"), CrateVersion("rustc_codegen_llvm", "0.0.0"), ]; /// Whitelist of crates rustc is allowed to depend on. Avoid adding to the list if possible. -const WHITELIST: &[Crate] = &[ +const WHITELIST: &[Crate<'_>] = &[ Crate("adler32"), Crate("aho-corasick"), Crate("arrayvec"), @@ -183,7 +183,7 @@ struct Crate<'a>(&'a str); // (name) #[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Hash)] struct CrateVersion<'a>(&'a str, &'a str); // (name, version) -impl<'a> Crate<'a> { +impl Crate<'_> { pub fn id_str(&self) -> String { format!("{} ", self.0) } @@ -330,10 +330,10 @@ fn get_deps(path: &Path, cargo: &Path) -> Resolve { /// Checks the dependencies of the given crate from the given cargo metadata to see if they are on /// the whitelist. Returns a list of illegal dependencies. -fn check_crate_whitelist<'a, 'b>( - whitelist: &'a HashSet, +fn check_crate_whitelist<'a>( + whitelist: &'a HashSet>, resolve: &'a Resolve, - visited: &'b mut BTreeSet>, + visited: &mut BTreeSet>, krate: CrateVersion<'a>, must_be_on_whitelist: bool, ) -> BTreeSet> { diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 7126c0c2f6ecf..1eab217027c8a 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -22,7 +22,7 @@ pub enum Status { } impl fmt::Display for Status { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let as_str = match *self { Status::Stable => "stable", Status::Unstable => "unstable", diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 022c53f909c75..c4a1246ffdf55 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -3,7 +3,8 @@ //! This library contains the tidy lints and exposes it //! to be used by tools. -extern crate serde; +#![deny(rust_2018_idioms)] + extern crate serde_json; #[macro_use] extern crate serde_derive; From 805145f2f96545600f7fec0a9a7b9edfb7bd9c38 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Fri, 1 Mar 2019 10:41:25 +0100 Subject: [PATCH 13/20] Revert "Auto merge of #58597 - pietroalbini:appveyor-gce, r=alexcrichton" This reverts commit fd42f24b0129b32d66f174510518c083cdcec3eb, reversing changes made to 0e25a6829c66302dc06c351bb494774e3d075f77. --- appveyor.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3a0cb8b4fceea..d70ad54b1c812 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,11 +5,6 @@ environment: # server goes down presumably. See #43333 for more info CARGO_HTTP_CHECK_REVOKE: false - # Execute the builds on GCE instead of Hyper-V. Those builders have a 3-4 - # minute startup overhead, but AppVeyor support recommended this as a - # possible solution for #58160 (spurious 259 exit codes) - appveyor_build_worker_cloud: gce - matrix: # 32/64 bit MSVC tests - MSYS_BITS: 64 From 260b0917b074b00960672a5308edee5c023e44f4 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 1 Mar 2019 11:15:22 +0100 Subject: [PATCH 14/20] tools/rustbook: deny(rust_2018_idioms) --- src/tools/rustbook/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 5a6246347cc03..cfc1bc6d414e4 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -1,4 +1,5 @@ -// +#![deny(rust_2018_idioms)] + use clap::{crate_version}; use std::env; @@ -68,7 +69,7 @@ fn main() { } // Build command implementation -pub fn build_1(args: &ArgMatches) -> Result1<()> { +pub fn build_1(args: &ArgMatches<'_>) -> Result1<()> { let book_dir = get_book_dir(args); let mut book = MDBook1::load(&book_dir)?; @@ -85,7 +86,7 @@ pub fn build_1(args: &ArgMatches) -> Result1<()> { } // Build command implementation -pub fn build_2(args: &ArgMatches) -> Result2<()> { +pub fn build_2(args: &ArgMatches<'_>) -> Result2<()> { let book_dir = get_book_dir(args); let mut book = MDBook2::load(&book_dir)?; @@ -101,7 +102,7 @@ pub fn build_2(args: &ArgMatches) -> Result2<()> { Ok(()) } -fn get_book_dir(args: &ArgMatches) -> PathBuf { +fn get_book_dir(args: &ArgMatches<'_>) -> PathBuf { if let Some(dir) = args.value_of("dir") { // Check if path is relative from current dir, or absolute... let p = Path::new(dir); From c259489209449a49d136dab4f09f7fcadd8f078c Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 1 Mar 2019 11:23:25 +0100 Subject: [PATCH 15/20] tools/remote-test-{client,server}: deny(rust_2018_idioms) --- src/tools/remote-test-client/src/main.rs | 4 +++- src/tools/remote-test-server/src/main.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/remote-test-client/src/main.rs b/src/tools/remote-test-client/src/main.rs index cb9dac27ce491..f42de44176787 100644 --- a/src/tools/remote-test-client/src/main.rs +++ b/src/tools/remote-test-client/src/main.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms)] + /// This is a small client program intended to pair with `remote-test-server` in /// this repository. This client connects to the server over TCP and is used to /// push artifacts and run tests on the server instead of locally. @@ -15,7 +17,7 @@ use std::process::{Command, Stdio}; use std::thread; use std::time::Duration; -const REMOTE_ADDR_ENV: &'static str = "TEST_DEVICE_ADDR"; +const REMOTE_ADDR_ENV: &str = "TEST_DEVICE_ADDR"; macro_rules! t { ($e:expr) => (match $e { diff --git a/src/tools/remote-test-server/src/main.rs b/src/tools/remote-test-server/src/main.rs index 750eea3a28aef..e1270489d315f 100644 --- a/src/tools/remote-test-server/src/main.rs +++ b/src/tools/remote-test-server/src/main.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms)] + /// This is a small server which is intended to run inside of an emulator or /// on a remote test device. This server pairs with the `remote-test-client` /// program in this repository. The `remote-test-client` connects to this @@ -120,7 +122,7 @@ struct RemoveOnDrop<'a> { inner: &'a Path, } -impl<'a> Drop for RemoveOnDrop<'a> { +impl Drop for RemoveOnDrop<'_> { fn drop(&mut self) { t!(fs::remove_dir_all(self.inner)); } From 670a4d65d577cfc59eefe8eb0b73d5b027ea0038 Mon Sep 17 00:00:00 2001 From: Jens Hausdorf Date: Fri, 1 Mar 2019 13:19:00 +0100 Subject: [PATCH 16/20] Fix typo in Vec#resize_with documentation --- src/liballoc/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 229dafc5fdc3a..947ce354ae711 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1260,7 +1260,7 @@ impl Vec { /// This method uses a closure to create new values on every push. If /// you'd rather [`Clone`] a given value, use [`resize`]. If you want /// to use the [`Default`] trait to generate values, you can pass - /// [`Default::default()`] as the second argument.. + /// [`Default::default()`] as the second argument. /// /// # Examples /// From c3aab1448070e7c039c204889fe59a1d00456db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 1 Mar 2019 15:06:14 +0100 Subject: [PATCH 17/20] Forbid duplicating Cargo as a dependency --- src/tools/tidy/src/deps.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 94dd5478e5297..fbc4730bc1d6e 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -378,7 +378,7 @@ fn check_crate_duplicate(resolve: &Resolve, bad: &mut bool) { // to accidentally sneak into our dependency graph, in order to ensure we keep our CI times // under control. - // "cargo", // FIXME(#53005) + "cargo", "rustc-ap-syntax", ]; let mut name_to_id: HashMap<_, Vec<_>> = HashMap::new(); From a7d17bfcd537c89908b59d86f4af1d6137974845 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 1 Mar 2019 10:34:08 -0800 Subject: [PATCH 18/20] Update toolchain to build NetBSD release This allows us to remove the "allow old toolchains" flag we pass to LLVM, ensuring that we'll be up to date when LLVM needs us to be! --- src/ci/docker/dist-x86_64-netbsd/Dockerfile | 20 ++----------------- .../build-netbsd-toolchain.sh | 12 +++++------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/ci/docker/dist-x86_64-netbsd/Dockerfile b/src/ci/docker/dist-x86_64-netbsd/Dockerfile index 4fe7e2cca2b60..44b1aaa24b19d 100644 --- a/src/ci/docker/dist-x86_64-netbsd/Dockerfile +++ b/src/ci/docker/dist-x86_64-netbsd/Dockerfile @@ -3,23 +3,8 @@ FROM ubuntu:16.04 COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh -# Ubuntu 16.04 (this container) ships with make 4, but something in the -# toolchains we build below chokes on that, so go back to make 3 -COPY scripts/make3.sh /scripts/ -RUN sh /scripts/make3.sh - -COPY scripts/crosstool-ng.sh /scripts/ -RUN sh /scripts/crosstool-ng.sh - -COPY scripts/rustbuild-setup.sh /scripts/ -RUN sh /scripts/rustbuild-setup.sh -USER rustbuild -WORKDIR /tmp - COPY dist-x86_64-netbsd/build-netbsd-toolchain.sh /tmp/ -RUN ./build-netbsd-toolchain.sh - -USER root +RUN /tmp/build-netbsd-toolchain.sh COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh @@ -33,6 +18,5 @@ ENV \ ENV HOSTS=x86_64-unknown-netbsd -ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs \ - --set llvm.allow-old-toolchain +ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh index ac92d68a1f501..b5377c64b1f54 100755 --- a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh +++ b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh @@ -28,15 +28,15 @@ mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror # Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz -curl $URL/2017-03-17-netbsd-src.tgz | tar xzf - -curl $URL/2017-03-17-netbsd-gnusrc.tgz | tar xzf - -curl $URL/2017-03-17-netbsd-sharesrc.tgz | tar xzf - -curl $URL/2017-03-17-netbsd-syssrc.tgz | tar xzf - +curl $URL/2018-03-01-netbsd-src.tgz | tar xzf - +curl $URL/2018-03-01-netbsd-gnusrc.tgz | tar xzf - +curl $URL/2018-03-01-netbsd-sharesrc.tgz | tar xzf - +curl $URL/2018-03-01-netbsd-syssrc.tgz | tar xzf - # Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/amd64/binary/sets/*.tgz -curl $URL/2017-03-17-netbsd-base.tgz | \ +curl $URL/2018-03-01-netbsd-base.tgz | \ tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib -curl $URL/2017-03-17-netbsd-comp.tgz | \ +curl $URL/2018-03-01-netbsd-comp.tgz | \ tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib cd usr/src From 04d0a8cb83e713f71848c4afeba72d7e776acc6a Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Sat, 2 Mar 2019 03:14:29 +0000 Subject: [PATCH 19/20] Fix C-variadic function printing There is no longer a need to append the string `", ..."` to a functions args as `...` is parsed as an argument and will appear in the functions arguments. --- src/libsyntax/print/pprust.rs | 3 --- src/test/pretty/fn-variadic.rs | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/test/pretty/fn-variadic.rs diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 942bd96939173..49e3fad4af0ff 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2814,9 +2814,6 @@ impl<'a> State<'a> { -> io::Result<()> { self.popen()?; self.commasep(Inconsistent, &decl.inputs, |s, arg| s.print_arg(arg, false))?; - if decl.c_variadic { - self.s.word(", ...")?; - } self.pclose()?; self.print_fn_output(decl) diff --git a/src/test/pretty/fn-variadic.rs b/src/test/pretty/fn-variadic.rs new file mode 100644 index 0000000000000..d3b193a3e1814 --- /dev/null +++ b/src/test/pretty/fn-variadic.rs @@ -0,0 +1,15 @@ +// Check that `fn foo(x: i32, ...)` does not print as `fn foo(x: i32, ..., ...)`. +// See issue #58853. +// +// pp-exact +#![feature(c_variadic)] + +extern "C" { + pub fn foo(x: i32, ...); +} + +pub unsafe extern "C" fn bar(_: i32, mut ap: ...) -> usize { + ap.arg::() +} + +fn main() { } From 379cd29d1c9ce06aa48fdd49208cfd7ffd3e5c07 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 2 Mar 2019 15:16:36 +0000 Subject: [PATCH 20/20] Nit --- src/test/pretty/fn-variadic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/pretty/fn-variadic.rs b/src/test/pretty/fn-variadic.rs index d3b193a3e1814..d499be424603b 100644 --- a/src/test/pretty/fn-variadic.rs +++ b/src/test/pretty/fn-variadic.rs @@ -1,6 +1,6 @@ // Check that `fn foo(x: i32, ...)` does not print as `fn foo(x: i32, ..., ...)`. // See issue #58853. -// + // pp-exact #![feature(c_variadic)]