From 11f69796ee967b39c68a766eb49a9eaed205ff8b Mon Sep 17 00:00:00 2001 From: Surya Midatala Date: Sun, 16 Aug 2020 19:43:42 +0530 Subject: [PATCH 01/12] Move to intra-doc links for task.rs and vec.rs --- library/alloc/src/task.rs | 4 +-- library/alloc/src/vec.rs | 51 ++++++++++++++------------------------- 2 files changed, 19 insertions(+), 36 deletions(-) diff --git a/library/alloc/src/task.rs b/library/alloc/src/task.rs index 252e04a410548..5edc579605669 100644 --- a/library/alloc/src/task.rs +++ b/library/alloc/src/task.rs @@ -13,11 +13,9 @@ use crate::sync::Arc; /// /// This trait is a memory-safe and ergonomic alternative to constructing a /// [`RawWaker`]. It supports the common executor design in which the data used -/// to wake up a task is stored in an [`Arc`][arc]. Some executors (especially +/// to wake up a task is stored in an [`Arc`]. Some executors (especially /// those for embedded systems) cannot use this API, which is why [`RawWaker`] /// exists as an alternative for those systems. -/// -/// [arc]: ../../std/sync/struct.Arc.html #[unstable(feature = "wake_trait", issue = "69912")] pub trait Wake { /// Wake this task. diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index 8ca0a0883cb16..f8e009a973627 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -50,12 +50,9 @@ //! v[1] = v[1] + 5; //! ``` //! -//! [`Vec`]: ../../std/vec/struct.Vec.html -//! [`new`]: ../../std/vec/struct.Vec.html#method.new -//! [`push`]: ../../std/vec/struct.Vec.html#method.push -//! [`Index`]: ../../std/ops/trait.Index.html -//! [`IndexMut`]: ../../std/ops/trait.IndexMut.html -//! [`vec!`]: ../../std/macro.vec.html +//! [`Vec`]: Vec +//! [`new`]: Vec::new +//! [`push`]: Vec::push #![stable(feature = "rust1", since = "1.0.0")] @@ -278,22 +275,18 @@ use crate::raw_vec::RawVec; /// `Vec` does not currently guarantee the order in which elements are dropped. /// The order has changed in the past and may change again. /// -/// [`vec!`]: ../../std/macro.vec.html /// [`get`]: ../../std/vec/struct.Vec.html#method.get /// [`get_mut`]: ../../std/vec/struct.Vec.html#method.get_mut -/// [`Index`]: ../../std/ops/trait.Index.html -/// [`String`]: ../../std/string/struct.String.html -/// [`&str`]: ../../std/primitive.str.html -/// [`Vec::with_capacity`]: ../../std/vec/struct.Vec.html#method.with_capacity -/// [`Vec::new`]: ../../std/vec/struct.Vec.html#method.new -/// [`shrink_to_fit`]: ../../std/vec/struct.Vec.html#method.shrink_to_fit -/// [`capacity`]: ../../std/vec/struct.Vec.html#method.capacity -/// [`mem::size_of::`]: ../../std/mem/fn.size_of.html -/// [`len`]: ../../std/vec/struct.Vec.html#method.len -/// [`push`]: ../../std/vec/struct.Vec.html#method.push -/// [`insert`]: ../../std/vec/struct.Vec.html#method.insert -/// [`reserve`]: ../../std/vec/struct.Vec.html#method.reserve -/// [owned slice]: ../../std/boxed/struct.Box.html +/// [`String`]: crate::string::String +/// [`&str`]: type@str +/// [`shrink_to_fit`]: Vec::shrink_to_fit +/// [`capacity`]: Vec::capacity +/// [`mem::size_of::`]: core::mem::size_of +/// [`len`]: Vec::len +/// [`push`]: Vec::push +/// [`insert`]: Vec::insert +/// [`reserve`]: Vec::reserve +/// [owned slice]: Box #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "vec_type")] pub struct Vec { @@ -430,8 +423,8 @@ impl Vec { /// that nothing else uses the pointer after calling this /// function. /// - /// [`String`]: ../../std/string/struct.String.html - /// [`dealloc`]: ../../alloc/alloc/trait.GlobalAlloc.html#tymethod.dealloc + /// [`String`]: crate::string::String + /// [`dealloc`]: crate::alloc::GlobalAlloc::dealloc /// /// # Examples /// @@ -658,7 +651,7 @@ impl Vec { /// /// Note that this will drop any excess capacity. /// - /// [owned slice]: ../../std/boxed/struct.Box.html + /// [owned slice]: Box /// /// # Examples /// @@ -867,7 +860,7 @@ impl Vec { /// /// [`truncate`]: #method.truncate /// [`resize`]: #method.resize - /// [`extend`]: ../../std/iter/trait.Extend.html#tymethod.extend + /// [`extend`]: Extend::extend /// [`clear`]: #method.clear /// /// # Safety @@ -1214,8 +1207,6 @@ impl Vec { /// Removes the last element from a vector and returns it, or [`None`] if it /// is empty. /// - /// [`None`]: ../../std/option/enum.Option.html#variant.None - /// /// # Examples /// /// ``` @@ -1480,7 +1471,6 @@ impl Vec { /// ``` /// /// [`resize`]: #method.resize - /// [`Clone`]: ../../std/clone/trait.Clone.html #[stable(feature = "vec_resize_with", since = "1.33.0")] pub fn resize_with(&mut self, new_len: usize, f: F) where @@ -1590,8 +1580,6 @@ impl Vec { /// assert_eq!(vec, [1, 2]); /// ``` /// - /// [`Clone`]: ../../std/clone/trait.Clone.html - /// [`Default`]: ../../std/default/trait.Default.html /// [`resize_with`]: #method.resize_with #[stable(feature = "vec_resize", since = "1.5.0")] pub fn resize(&mut self, new_len: usize, value: T) { @@ -1655,9 +1643,7 @@ impl Vec { /// ``` /// /// [`resize`]: #method.resize - /// [`Default::default()`]: ../../std/default/trait.Default.html#tymethod.default - /// [`Default`]: ../../std/default/trait.Default.html - /// [`Clone`]: ../../std/clone/trait.Clone.html + /// [`Default::default()`]: Default::default #[unstable(feature = "vec_resize_default", issue = "41758")] #[rustc_deprecated( reason = "This is moving towards being removed in favor \ @@ -2338,7 +2324,6 @@ impl Vec { /// Note that `drain_filter` also lets you mutate every element in the filter closure, /// regardless of whether you choose to keep or remove it. /// - /// /// # Examples /// /// Splitting an array into evens and odds, reusing the original allocation: From 6a80b1387fe01b6a350d123a7ad0c7a8130827cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Wed, 19 Aug 2020 00:00:00 +0000 Subject: [PATCH 02/12] Enable stack-overflow detection on musl for non-main threads --- library/std/src/sys/unix/thread.rs | 27 +++++++++++++++++++++------ src/test/ui/abi/stack-probes.rs | 1 - src/test/ui/out-of-stack.rs | 1 - 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index c1bda6b430e13..04da9812ddc45 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -213,7 +213,7 @@ impl Drop for Thread { } #[cfg(all( - not(all(target_os = "linux", not(target_env = "musl"))), + not(target_os = "linux"), not(target_os = "freebsd"), not(target_os = "macos"), not(all(target_os = "netbsd", not(target_vendor = "rumprun"))), @@ -233,7 +233,7 @@ pub mod guard { } #[cfg(any( - all(target_os = "linux", not(target_env = "musl")), + target_os = "linux", target_os = "freebsd", target_os = "macos", all(target_os = "netbsd", not(target_vendor = "rumprun")), @@ -333,9 +333,7 @@ pub mod guard { let page_size = os::page_size(); PAGE_SIZE.store(page_size, Ordering::Relaxed); - let stackaddr = get_stack_start_aligned()?; - - if cfg!(target_os = "linux") { + if cfg!(all(target_os = "linux", not(target_env = "musl"))) { // Linux doesn't allocate the whole stack right away, and // the kernel has its own stack-guard mechanism to fault // when growing too close to an existing mapping. If we map @@ -346,8 +344,15 @@ pub mod guard { // Instead, we'll just note where we expect rlimit to start // faulting, so our handler can report "stack overflow", and // trust that the kernel's own stack guard will work. + let stackaddr = get_stack_start_aligned()?; let stackaddr = stackaddr as usize; Some(stackaddr - page_size..stackaddr) + } else if cfg!(all(target_os = "linux", target_env = "musl")) { + // For the main thread, the musl's pthread_attr_getstack + // returns the current stack size, rather than maximum size + // it can eventually grow to. It cannot be used to determine + // the position of kernel's stack guard. + None } else { // Reallocate the last page of the stack. // This ensures SIGBUS will be raised on @@ -357,6 +362,7 @@ pub mod guard { // than the initial mmap() used, so we mmap() here with // read/write permissions and only then mprotect() it to // no permissions at all. See issue #50313. + let stackaddr = get_stack_start_aligned()?; let result = mmap( stackaddr, page_size, @@ -406,7 +412,14 @@ pub mod guard { let mut guardsize = 0; assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0); if guardsize == 0 { - panic!("there is no guard page"); + if cfg!(all(target_os = "linux", target_env = "musl")) { + // musl versions before 1.1.19 always reported guard + // size obtained from pthread_attr_get_np as zero. + // Use page size as a fallback. + guardsize = PAGE_SIZE.load(Ordering::Relaxed); + } else { + panic!("there is no guard page"); + } } let mut stackaddr = crate::ptr::null_mut(); let mut size = 0; @@ -419,6 +432,8 @@ pub mod guard { Some(guardaddr - PAGE_SIZE.load(Ordering::Relaxed)..guardaddr) } else if cfg!(target_os = "netbsd") { Some(stackaddr - guardsize..stackaddr) + } else if cfg!(all(target_os = "linux", target_env = "musl")) { + Some(stackaddr - guardsize..stackaddr) } else if cfg!(all(target_os = "linux", target_env = "gnu")) { // glibc used to include the guard area within the stack, as noted in the BUGS // section of `man pthread_attr_getguardsize`. This has been corrected starting diff --git a/src/test/ui/abi/stack-probes.rs b/src/test/ui/abi/stack-probes.rs index 1d5b362e29dfe..a52c285f9f0b4 100644 --- a/src/test/ui/abi/stack-probes.rs +++ b/src/test/ui/abi/stack-probes.rs @@ -11,7 +11,6 @@ // ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes -// ignore-musl FIXME #31506 use std::mem::MaybeUninit; use std::process::Command; diff --git a/src/test/ui/out-of-stack.rs b/src/test/ui/out-of-stack.rs index d04b0c1a6303e..6beafc0732ba3 100644 --- a/src/test/ui/out-of-stack.rs +++ b/src/test/ui/out-of-stack.rs @@ -3,7 +3,6 @@ #![allow(unused_must_use)] #![allow(unconditional_recursion)] // ignore-android: FIXME (#20004) -// ignore-musl // ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes From 632db79ad68de5b793d56757f54898134af91aa3 Mon Sep 17 00:00:00 2001 From: Surya Midatala Date: Wed, 19 Aug 2020 10:29:31 +0530 Subject: [PATCH 03/12] Apply suggestions from code review --- library/alloc/src/vec.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index f8e009a973627..30b4bb51eb70e 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -368,7 +368,7 @@ impl Vec { /// into a `Vec` with the [`from_raw_parts`] function, allowing /// the destructor to perform the cleanup. /// - /// [`from_raw_parts`]: #method.from_raw_parts + /// [`from_raw_parts`]: Vec::from_raw_parts /// /// # Examples /// @@ -722,8 +722,8 @@ impl Vec { /// assert_eq!(vec, []); /// ``` /// - /// [`clear`]: #method.clear - /// [`drain`]: #method.drain + /// [`clear`]: Vec::clear + /// [`drain`]: Vec::drain #[stable(feature = "rust1", since = "1.0.0")] pub fn truncate(&mut self, len: usize) { // This is safe because: @@ -802,7 +802,7 @@ impl Vec { /// } /// ``` /// - /// [`as_mut_ptr`]: #method.as_mut_ptr + /// [`as_mut_ptr`]: Vec::as_mut_ptr #[stable(feature = "vec_as_ptr", since = "1.37.0")] #[inline] pub fn as_ptr(&self) -> *const T { @@ -858,17 +858,17 @@ impl Vec { /// is done using one of the safe operations instead, such as /// [`truncate`], [`resize`], [`extend`], or [`clear`]. /// - /// [`truncate`]: #method.truncate - /// [`resize`]: #method.resize + /// [`truncate`]: Vec::truncate + /// [`resize`]: Vec::resize /// [`extend`]: Extend::extend - /// [`clear`]: #method.clear + /// [`clear`]: Vec::clear /// /// # Safety /// /// - `new_len` must be less than or equal to [`capacity()`]. /// - The elements at `old_len..new_len` must be initialized. /// - /// [`capacity()`]: #method.capacity + /// [`capacity()`]: Vec::capacity /// /// # Examples /// @@ -1470,7 +1470,7 @@ impl Vec { /// assert_eq!(vec, [2, 4, 8, 16]); /// ``` /// - /// [`resize`]: #method.resize + /// [`resize`]: Vec::resize #[stable(feature = "vec_resize_with", since = "1.33.0")] pub fn resize_with(&mut self, new_len: usize, f: F) where @@ -1521,7 +1521,7 @@ impl Vec { /// reading from a file) before marking the data as initialized using the /// [`set_len`] method. /// - /// [`set_len`]: #method.set_len + /// [`set_len`]: Vec::set_len /// /// # Examples /// @@ -1580,7 +1580,7 @@ impl Vec { /// assert_eq!(vec, [1, 2]); /// ``` /// - /// [`resize_with`]: #method.resize_with + /// [`resize_with`]: Vec::resize_with #[stable(feature = "vec_resize", since = "1.5.0")] pub fn resize(&mut self, new_len: usize, value: T) { let len = self.len(); @@ -1642,8 +1642,7 @@ impl Vec { /// assert_eq!(vec, [1, 2]); /// ``` /// - /// [`resize`]: #method.resize - /// [`Default::default()`]: Default::default + /// [`resize`]: Vec::resize #[unstable(feature = "vec_resize_default", issue = "41758")] #[rustc_deprecated( reason = "This is moving towards being removed in favor \ From 46f2b410e0871587dde5e4375d23ebe332ec1176 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 19 Aug 2020 14:22:52 +0200 Subject: [PATCH 04/12] Clean up E0759 explanation --- src/librustc_error_codes/error_codes/E0759.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0759.md b/src/librustc_error_codes/error_codes/E0759.md index a74759bdf634b..2daaeba82f067 100644 --- a/src/librustc_error_codes/error_codes/E0759.md +++ b/src/librustc_error_codes/error_codes/E0759.md @@ -5,14 +5,11 @@ Erroneous code examples: ```compile_fail,E0759 use std::fmt::Debug; -fn foo(x: &i32) -> impl Debug { +fn foo(x: &i32) -> impl Debug { // error! x } -``` -```compile_fail,E0759 -# use std::fmt::Debug; -fn bar(x: &i32) -> Box { +fn bar(x: &i32) -> Box { // error! Box::new(x) } ``` @@ -21,14 +18,11 @@ These examples have the same semantics as the following: ```compile_fail,E0759 # use std::fmt::Debug; -fn foo(x: &i32) -> impl Debug + 'static { +fn foo(x: &i32) -> impl Debug + 'static { // ok! x } -``` -```compile_fail,E0759 -# use std::fmt::Debug; -fn bar(x: &i32) -> Box { +fn bar(x: &i32) -> Box { // ok! Box::new(x) } ``` From ccb049387afae7772ca16c1ff876d38a9d0c53c9 Mon Sep 17 00:00:00 2001 From: ThibsG Date: Wed, 19 Aug 2020 12:05:32 +0200 Subject: [PATCH 05/12] Fix bad printing of const-eval queries --- src/librustc_middle/mir/interpret/mod.rs | 11 ++++++++++ src/librustc_middle/query/mod.rs | 4 ++-- .../defaults-cyclic-fail.stderr | 2 +- .../const-eval/const-eval-query-stack.rs | 20 +++++++++++++++++++ .../const-eval/const-eval-query-stack.stderr | 18 +++++++++++++++++ 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/consts/const-eval/const-eval-query-stack.rs create mode 100644 src/test/ui/consts/const-eval/const-eval-query-stack.stderr diff --git a/src/librustc_middle/mir/interpret/mod.rs b/src/librustc_middle/mir/interpret/mod.rs index fb7269f648f03..0dc3d6e344a7e 100644 --- a/src/librustc_middle/mir/interpret/mod.rs +++ b/src/librustc_middle/mir/interpret/mod.rs @@ -143,6 +143,17 @@ pub struct GlobalId<'tcx> { pub promoted: Option, } +impl GlobalId<'tcx> { + pub fn display(self, tcx: TyCtxt<'tcx>) -> String { + let instance_name = tcx.def_path_str(self.instance.def.def_id()); + if let Some(promoted) = self.promoted { + format!("{}::{:?}", instance_name, promoted) + } else { + instance_name + } + } +} + /// Input argument for `tcx.lit_to_const`. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, HashStable)] pub struct LitToConstInput<'tcx> { diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index d874edf627472..f5029eb740455 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -679,7 +679,7 @@ rustc_queries! { -> ConstEvalRawResult<'tcx> { desc { |tcx| "const-evaluating `{}`", - tcx.def_path_str(key.value.instance.def.def_id()) + key.value.display(tcx) } } @@ -695,7 +695,7 @@ rustc_queries! { -> ConstEvalResult<'tcx> { desc { |tcx| "const-evaluating + checking `{}`", - tcx.def_path_str(key.value.instance.def.def_id()) + key.value.display(tcx) } cache_on_disk_if(_, opt_result) { // Only store results without errors diff --git a/src/test/ui/associated-const/defaults-cyclic-fail.stderr b/src/test/ui/associated-const/defaults-cyclic-fail.stderr index 6b2fbe5be4e30..e6075f745776a 100644 --- a/src/test/ui/associated-const/defaults-cyclic-fail.stderr +++ b/src/test/ui/associated-const/defaults-cyclic-fail.stderr @@ -32,7 +32,7 @@ note: ...which requires const-evaluating `Tr::B`... LL | const B: u8 = Self::A; | ^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires normalizing `<() as Tr>::A`, completing the cycle -note: cycle used when const-evaluating `main` +note: cycle used when const-evaluating `main::promoted[2]` --> $DIR/defaults-cyclic-fail.rs:14:1 | LL | fn main() { diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.rs b/src/test/ui/consts/const-eval/const-eval-query-stack.rs new file mode 100644 index 0000000000000..aae8233665aaa --- /dev/null +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.rs @@ -0,0 +1,20 @@ +// compile-flags: -Ztreat-err-as-bug +// build-fail +// failure-status: 101 +// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" +// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" +// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" +// normalize-stderr-test "note: compiler flags.*\n\n" -> "" +// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "thread.*panicked.*\n" -> "" +// normalize-stderr-test "stack backtrace:\n" -> "" +// normalize-stderr-test " \d{1,}: .*\n" -> "" +// normalize-stderr-test ".*note: Some details.*\n" -> "" + +#![allow(unconditional_panic)] + +fn main() { + let x: &'static i32 = &(1 / 0); + //~^ ERROR reaching this expression at runtime will panic or abort [const_err] + println!("x={}", x); +} diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr new file mode 100644 index 0000000000000..44b3c56b39363 --- /dev/null +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -0,0 +1,18 @@ +error: reaching this expression at runtime will panic or abort + --> $DIR/const-eval-query-stack.rs:17:28 + | +LL | let x: &'static i32 = &(1 / 0); + | -^^^^^^^ + | | + | dividing by zero + | + = note: `#[deny(const_err)]` on by default + +query stack during panic: +#0 [const_eval_raw] const-evaluating `main::promoted[1]` +#1 [const_eval_validated] const-evaluating + checking `main::promoted[1]` +#2 [const_eval_validated] const-evaluating + checking `main::promoted[1]` +#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]` +#4 [optimized_mir] optimizing MIR for `main` +#5 [collect_and_partition_mono_items] collect_and_partition_mono_items +end of query stack From f3585a93fea7b7e82e9a488b364fa6edfc2dd214 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 19 Aug 2020 11:22:24 -0700 Subject: [PATCH 06/12] Upgrade Emscripten on CI to 1.39.20 This Emscripten version was the first to be cut after the LLVM 11 release branch was created, so it should be the most compatible with LLVM 11. The old version we were using was incompatible with LLVM 11 because its wasm-ld did not understand all the relocations that LLVM 11 emits. --- src/ci/docker/scripts/emscripten.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/scripts/emscripten.sh b/src/ci/docker/scripts/emscripten.sh index 9f6a7f2e5db44..9481ee95399db 100644 --- a/src/ci/docker/scripts/emscripten.sh +++ b/src/ci/docker/scripts/emscripten.sh @@ -19,5 +19,5 @@ exit 1 git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable cd /emsdk-portable -hide_output ./emsdk install 1.38.47-upstream -./emsdk activate 1.38.47-upstream +hide_output ./emsdk install 1.39.20 +./emsdk activate 1.39.20 From 2932d4e63493378710bb0aa27187e8dd33260c4a Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Thu, 20 Aug 2020 15:20:46 +0800 Subject: [PATCH 07/12] Remove duplicated alloc vec bench push_all_move push_all_move is the same as extend --- library/alloc/benches/vec.rs | 49 ------------------------------------ 1 file changed, 49 deletions(-) diff --git a/library/alloc/benches/vec.rs b/library/alloc/benches/vec.rs index a3da9e80cd0fc..b91138818e556 100644 --- a/library/alloc/benches/vec.rs +++ b/library/alloc/benches/vec.rs @@ -262,55 +262,6 @@ fn bench_push_all_1000_1000(b: &mut Bencher) { do_bench_push_all(b, 1000, 1000) } -fn do_bench_push_all_move(b: &mut Bencher, dst_len: usize, src_len: usize) { - let dst: Vec<_> = FromIterator::from_iter(0..dst_len); - let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len); - - b.bytes = src_len as u64; - - b.iter(|| { - let mut dst = dst.clone(); - dst.extend(src.clone()); - assert_eq!(dst.len(), dst_len + src_len); - assert!(dst.iter().enumerate().all(|(i, x)| i == *x)); - }); -} - -#[bench] -fn bench_push_all_move_0000_0000(b: &mut Bencher) { - do_bench_push_all_move(b, 0, 0) -} - -#[bench] -fn bench_push_all_move_0000_0010(b: &mut Bencher) { - do_bench_push_all_move(b, 0, 10) -} - -#[bench] -fn bench_push_all_move_0000_0100(b: &mut Bencher) { - do_bench_push_all_move(b, 0, 100) -} - -#[bench] -fn bench_push_all_move_0000_1000(b: &mut Bencher) { - do_bench_push_all_move(b, 0, 1000) -} - -#[bench] -fn bench_push_all_move_0010_0010(b: &mut Bencher) { - do_bench_push_all_move(b, 10, 10) -} - -#[bench] -fn bench_push_all_move_0100_0100(b: &mut Bencher) { - do_bench_push_all_move(b, 100, 100) -} - -#[bench] -fn bench_push_all_move_1000_1000(b: &mut Bencher) { - do_bench_push_all_move(b, 1000, 1000) -} - fn do_bench_clone(b: &mut Bencher, src_len: usize) { let src: Vec = FromIterator::from_iter(0..src_len); From bd716753f400faa2651f6a81e38e04ee64a8624a Mon Sep 17 00:00:00 2001 From: ThibsG Date: Thu, 20 Aug 2020 09:20:57 +0200 Subject: [PATCH 08/12] Set RUST_BACKTRACE env variable --- src/test/ui/consts/const-eval/const-eval-query-stack.rs | 1 + src/test/ui/consts/const-eval/const-eval-query-stack.stderr | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.rs b/src/test/ui/consts/const-eval/const-eval-query-stack.rs index aae8233665aaa..6962ccdec73ee 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.rs +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.rs @@ -1,6 +1,7 @@ // compile-flags: -Ztreat-err-as-bug // build-fail // failure-status: 101 +// rustc-env:RUST_BACKTRACE=1 // normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" // normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index 44b3c56b39363..32233a0f6eeb7 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -1,5 +1,5 @@ error: reaching this expression at runtime will panic or abort - --> $DIR/const-eval-query-stack.rs:17:28 + --> $DIR/const-eval-query-stack.rs:18:28 | LL | let x: &'static i32 = &(1 / 0); | -^^^^^^^ From 4f2e182c5f12811689541eaed2d68014aab29eb1 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Thu, 20 Aug 2020 19:04:52 +0800 Subject: [PATCH 09/12] Liballoc bench rename push_all extend_from_slice --- library/alloc/benches/vec.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/library/alloc/benches/vec.rs b/library/alloc/benches/vec.rs index b91138818e556..4e71eec03e5bf 100644 --- a/library/alloc/benches/vec.rs +++ b/library/alloc/benches/vec.rs @@ -213,7 +213,7 @@ fn bench_extend_1000_1000(b: &mut Bencher) { do_bench_extend(b, 1000, 1000) } -fn do_bench_push_all(b: &mut Bencher, dst_len: usize, src_len: usize) { +fn do_bench_extend_from_slice(b: &mut Bencher, dst_len: usize, src_len: usize) { let dst: Vec<_> = FromIterator::from_iter(0..dst_len); let src: Vec<_> = FromIterator::from_iter(dst_len..dst_len + src_len); @@ -228,38 +228,38 @@ fn do_bench_push_all(b: &mut Bencher, dst_len: usize, src_len: usize) { } #[bench] -fn bench_push_all_0000_0000(b: &mut Bencher) { - do_bench_push_all(b, 0, 0) +fn bench_extend_from_slice_0000_0000(b: &mut Bencher) { + do_bench_extend_from_slice(b, 0, 0) } #[bench] -fn bench_push_all_0000_0010(b: &mut Bencher) { - do_bench_push_all(b, 0, 10) +fn bench_extend_from_slice_0000_0010(b: &mut Bencher) { + do_bench_extend_from_slice(b, 0, 10) } #[bench] -fn bench_push_all_0000_0100(b: &mut Bencher) { - do_bench_push_all(b, 0, 100) +fn bench_extend_from_slice_0000_0100(b: &mut Bencher) { + do_bench_extend_from_slice(b, 0, 100) } #[bench] -fn bench_push_all_0000_1000(b: &mut Bencher) { - do_bench_push_all(b, 0, 1000) +fn bench_extend_from_slice_0000_1000(b: &mut Bencher) { + do_bench_extend_from_slice(b, 0, 1000) } #[bench] -fn bench_push_all_0010_0010(b: &mut Bencher) { - do_bench_push_all(b, 10, 10) +fn bench_extend_from_slice_0010_0010(b: &mut Bencher) { + do_bench_extend_from_slice(b, 10, 10) } #[bench] -fn bench_push_all_0100_0100(b: &mut Bencher) { - do_bench_push_all(b, 100, 100) +fn bench_extend_from_slice_0100_0100(b: &mut Bencher) { + do_bench_extend_from_slice(b, 100, 100) } #[bench] -fn bench_push_all_1000_1000(b: &mut Bencher) { - do_bench_push_all(b, 1000, 1000) +fn bench_extend_from_slice_1000_1000(b: &mut Bencher) { + do_bench_extend_from_slice(b, 1000, 1000) } fn do_bench_clone(b: &mut Bencher, src_len: usize) { From 7f55c834873cd9363bbdfa199f3d0dbadce99592 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Aug 2020 15:25:35 +0200 Subject: [PATCH 10/12] Apply review comments --- src/librustc_error_codes/error_codes/E0759.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0759.md b/src/librustc_error_codes/error_codes/E0759.md index 2daaeba82f067..6d525310f75c3 100644 --- a/src/librustc_error_codes/error_codes/E0759.md +++ b/src/librustc_error_codes/error_codes/E0759.md @@ -1,4 +1,4 @@ -A `'static` requirement in a return type involving a trait is not fulfilled. +Return type involving a trait did not require `'static` lifetime. Erroneous code examples: @@ -14,7 +14,7 @@ fn bar(x: &i32) -> Box { // error! } ``` -These examples have the same semantics as the following: +Add `'static` requirement to fix them: ```compile_fail,E0759 # use std::fmt::Debug; From 52992979c5a336335408be9f21d24037f6017e98 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 20 Aug 2020 13:51:39 +0000 Subject: [PATCH 11/12] Rename rustc_lexer::TokenKind::Not to Bang All other tokens are named by the punctuation they use, rather than by semantics operation they stand for. `!` is the only exception to the rule, let's fix it. --- src/librustc_lexer/src/lib.rs | 4 ++-- src/librustc_parse/lexer/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_lexer/src/lib.rs b/src/librustc_lexer/src/lib.rs index 7949a232b9b35..f94466b03ed1e 100644 --- a/src/librustc_lexer/src/lib.rs +++ b/src/librustc_lexer/src/lib.rs @@ -103,7 +103,7 @@ pub enum TokenKind { /// "=" Eq, /// "!" - Not, + Bang, /// "<" Lt, /// ">" @@ -378,7 +378,7 @@ impl Cursor<'_> { ':' => Colon, '$' => Dollar, '=' => Eq, - '!' => Not, + '!' => Bang, '<' => Lt, '>' => Gt, '-' => Minus, diff --git a/src/librustc_parse/lexer/mod.rs b/src/librustc_parse/lexer/mod.rs index 675cfa41f1048..398e23a6ff727 100644 --- a/src/librustc_parse/lexer/mod.rs +++ b/src/librustc_parse/lexer/mod.rs @@ -290,7 +290,7 @@ impl<'a> StringReader<'a> { rustc_lexer::TokenKind::Colon => token::Colon, rustc_lexer::TokenKind::Dollar => token::Dollar, rustc_lexer::TokenKind::Eq => token::Eq, - rustc_lexer::TokenKind::Not => token::Not, + rustc_lexer::TokenKind::Bang => token::Not, rustc_lexer::TokenKind::Lt => token::Lt, rustc_lexer::TokenKind::Gt => token::Gt, rustc_lexer::TokenKind::Minus => token::BinOp(token::Minus), From d97bbd3a2182f6199287601fed993d2d20e1f568 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 20 Aug 2020 03:43:17 +0000 Subject: [PATCH 12/12] Suppress ty::Float in MIR comments of ty::Const Already covered by MIR constant comments --- src/librustc_mir/util/pretty.rs | 2 +- src/test/mir-opt/deaggregator_test.bar.Deaggregator.diff | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 958e5188fed04..2a9cbc7fc0e37 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -406,7 +406,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> { self.super_const(constant); let ty::Const { ty, val, .. } = constant; match ty.kind { - ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {} + ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_) => {} // Unit type ty::Tuple(tys) if tys.is_empty() => {} ty::FnDef(..) => {} diff --git a/src/test/mir-opt/deaggregator_test.bar.Deaggregator.diff b/src/test/mir-opt/deaggregator_test.bar.Deaggregator.diff index ebe76e8e270cd..e60a1f3e75f9f 100644 --- a/src/test/mir-opt/deaggregator_test.bar.Deaggregator.diff +++ b/src/test/mir-opt/deaggregator_test.bar.Deaggregator.diff @@ -12,9 +12,6 @@ - _0 = Baz { x: move _2, y: const 0f32, z: const false }; // scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35 + (_0.0: usize) = move _2; // scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35 + (_0.1: f32) = const 0f32; // scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35 - // ty::Const - // + ty: f32 - // + val: Value(Scalar(0x00000000)) // mir::Constant // + span: $DIR/deaggregator_test.rs:9:20: 9:23 // + literal: Const { ty: f32, val: Value(Scalar(0x00000000)) }