From 64cf7ad75fe90ed293f443c13062e8a74b755f8d Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Wed, 24 Mar 2021 06:15:03 +0100 Subject: [PATCH 1/7] Update RELEASES.md - `Div` and `Rem` by their `NonZero` variant is now implemented for all unsigned integers. - stabilization of `deque_range` - deprecation of `spin_loop_hint` --- RELEASES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 3cd253afbcd3b..21aef444a47cb 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -50,6 +50,8 @@ Libraries - [`io::Empty` now implements `io::Seek`.][78044] - [`rc::Weak` and `sync::Weak`'s methods such as `as_ptr` are now implemented for `T: ?Sized` types.][80764] +- [`Div` and `Rem` by their `NonZero` variant is now implemented for all unsigned integers.][79134] + Stabilized APIs --------------- @@ -72,6 +74,8 @@ Stabilized APIs - [`str::split_inclusive`] - [`sync::OnceState`] - [`task::Wake`] +- [`VecDeque::range`] +- [`VecDeque::range_mut`] Cargo ----- @@ -115,6 +119,7 @@ Compatibility Notes - `thumbv7neon-unknown-linux-gnueabihf` - `armv7-unknown-linux-gnueabi` - `x86_64-unknown-linux-gnux32` +- [`atomic::spin_loop_hint` has been deprecated.][80966] It's recommended to use `hint::spin_loop` instead. Internal Only ------------- @@ -145,6 +150,8 @@ Internal Only [80764]: https://github.com/rust-lang/rust/pull/80764 [80749]: https://github.com/rust-lang/rust/pull/80749 [80662]: https://github.com/rust-lang/rust/pull/80662 +[79134]: https://github.com/rust-lang/rust/pull/79134 +[80966]: https://github.com/rust-lang/rust/pull/80966 [cargo/8997]: https://github.com/rust-lang/cargo/pull/8997 [cargo/9112]: https://github.com/rust-lang/cargo/pull/9112 [feature-resolver@2.0]: https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2 @@ -166,6 +173,8 @@ Internal Only [`Seek::stream_position`]: https://doc.rust-lang.org/nightly/std/io/trait.Seek.html#method.stream_position [`Peekable::next_if`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if [`Peekable::next_if_eq`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if_eq +[`VecDeque::range`]: https://doc.rust-lang.org/nightly/std/collections/struct.VecDeque.html#method.range +[`VecDeque::range_mut`]: https://doc.rust-lang.org/nightly/std/collections/struct.VecDeque.html#method.range_mut Version 1.50.0 (2021-02-11) ============================ From 58218f6c27843f57a26fb861ca9b4c3e006cb285 Mon Sep 17 00:00:00 2001 From: Jacob Hughes Date: Wed, 31 Mar 2021 12:11:36 -0400 Subject: [PATCH 2/7] Remove T: Debug bound on UnsafeCell Debug impl --- library/core/src/fmt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index d696ffa82774b..59493bb0425f3 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2268,7 +2268,7 @@ impl Debug for RefMut<'_, T> { } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl Debug for UnsafeCell { +impl Debug for UnsafeCell { fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.pad("UnsafeCell") } From 5e87f97de789d68719efafde6a0175d64ed90e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sun, 11 Apr 2021 00:00:00 +0000 Subject: [PATCH 3/7] Check for asm support in UI tests that require it Add `needs-asm-support` compiletest directive, and use it in asm tests that require asm support without relying on any architecture specific features. --- src/test/ui/asm/bad-options.rs | 2 +- src/test/ui/asm/naked-invalid-attr.rs | 2 +- .../ui/feature-gates/feature-gate-naked_functions.rs | 1 + .../feature-gates/feature-gate-naked_functions.stderr | 4 ++-- src/test/ui/rfc-2091-track-caller/error-with-naked.rs | 1 + .../ui/rfc-2091-track-caller/error-with-naked.stderr | 4 ++-- src/tools/compiletest/src/header.rs | 5 +++++ src/tools/compiletest/src/header/tests.rs | 11 +++++++++++ src/tools/compiletest/src/util.rs | 9 +++++++++ 9 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/test/ui/asm/bad-options.rs b/src/test/ui/asm/bad-options.rs index 755fc2ca238aa..a60478f62154f 100644 --- a/src/test/ui/asm/bad-options.rs +++ b/src/test/ui/asm/bad-options.rs @@ -1,4 +1,4 @@ -// only-x86_64 +// needs-asm-support #![feature(asm)] diff --git a/src/test/ui/asm/naked-invalid-attr.rs b/src/test/ui/asm/naked-invalid-attr.rs index cdb6c17454b73..2576d1124c85c 100644 --- a/src/test/ui/asm/naked-invalid-attr.rs +++ b/src/test/ui/asm/naked-invalid-attr.rs @@ -1,6 +1,6 @@ // Checks that #[naked] attribute can be placed on function definitions only. // -// ignore-wasm32 asm unsupported +// needs-asm-support #![feature(asm)] #![feature(naked_functions)] #![naked] //~ ERROR should be applied to a function definition diff --git a/src/test/ui/feature-gates/feature-gate-naked_functions.rs b/src/test/ui/feature-gates/feature-gate-naked_functions.rs index 06bddc422cf80..71ca5b9373a68 100644 --- a/src/test/ui/feature-gates/feature-gate-naked_functions.rs +++ b/src/test/ui/feature-gates/feature-gate-naked_functions.rs @@ -1,3 +1,4 @@ +// needs-asm-support #![feature(asm)] #[naked] diff --git a/src/test/ui/feature-gates/feature-gate-naked_functions.stderr b/src/test/ui/feature-gates/feature-gate-naked_functions.stderr index d95561d20133e..653d7b738da1a 100644 --- a/src/test/ui/feature-gates/feature-gate-naked_functions.stderr +++ b/src/test/ui/feature-gates/feature-gate-naked_functions.stderr @@ -1,5 +1,5 @@ error[E0658]: the `#[naked]` attribute is an experimental feature - --> $DIR/feature-gate-naked_functions.rs:3:1 + --> $DIR/feature-gate-naked_functions.rs:4:1 | LL | #[naked] | ^^^^^^^^ @@ -8,7 +8,7 @@ LL | #[naked] = help: add `#![feature(naked_functions)]` to the crate attributes to enable error[E0658]: the `#[naked]` attribute is an experimental feature - --> $DIR/feature-gate-naked_functions.rs:9:1 + --> $DIR/feature-gate-naked_functions.rs:10:1 | LL | #[naked] | ^^^^^^^^ diff --git a/src/test/ui/rfc-2091-track-caller/error-with-naked.rs b/src/test/ui/rfc-2091-track-caller/error-with-naked.rs index 70ec0e3033c6f..9464ffe872282 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-naked.rs +++ b/src/test/ui/rfc-2091-track-caller/error-with-naked.rs @@ -1,3 +1,4 @@ +// needs-asm-support #![feature(asm, naked_functions)] #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` diff --git a/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr b/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr index 1b49148d629b2..5f17d6b2b5173 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr +++ b/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr @@ -1,11 +1,11 @@ error[E0736]: cannot use `#[track_caller]` with `#[naked]` - --> $DIR/error-with-naked.rs:3:1 + --> $DIR/error-with-naked.rs:4:1 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ error[E0736]: cannot use `#[track_caller]` with `#[naked]` - --> $DIR/error-with-naked.rs:12:5 + --> $DIR/error-with-naked.rs:13:5 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 531a23d76a27b..363105a9f09c0 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -44,6 +44,7 @@ impl EarlyProps { let mut props = EarlyProps::default(); let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some(); let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some(); + let has_asm_support = util::has_asm_support(&config.target); let has_asan = util::ASAN_SUPPORTED_TARGETS.contains(&&*config.target); let has_lsan = util::LSAN_SUPPORTED_TARGETS.contains(&&*config.target); let has_msan = util::MSAN_SUPPORTED_TARGETS.contains(&&*config.target); @@ -76,6 +77,10 @@ impl EarlyProps { props.ignore = true; } + if !has_asm_support && config.parse_name_directive(ln, "needs-asm-support") { + props.ignore = true; + } + if !rustc_has_profiler_support && config.parse_needs_profiler_support(ln) { props.ignore = true; } diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index ec99fde0df9c2..c41b43cdd0b53 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -223,6 +223,17 @@ fn sanitizers() { assert!(parse_rs(&config, "// needs-sanitizer-thread").ignore); } +#[test] +fn asm_support() { + let mut config = config(); + + config.target = "avr-unknown-gnu-atmega328".to_owned(); + assert!(parse_rs(&config, "// needs-asm-support").ignore); + + config.target = "i686-unknown-netbsd".to_owned(); + assert!(!parse_rs(&config, "// needs-asm-support").ignore); +} + #[test] fn test_extract_version_range() { use super::{extract_llvm_version, extract_version_range}; diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index b302953708c18..7dbd70948b84d 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -128,6 +128,15 @@ const BIG_ENDIAN: &[&str] = &[ "sparcv9", ]; +static ASM_SUPPORTED_ARCHS: &[&str] = &[ + "x86", "x86_64", "arm", "aarch64", "riscv32", "riscv64", "nvptx64", "hexagon", "mips", + "mips64", "spirv", "wasm32", +]; + +pub fn has_asm_support(triple: &str) -> bool { + ASM_SUPPORTED_ARCHS.contains(&get_arch(triple)) +} + pub fn matches_os(triple: &str, name: &str) -> bool { // For the wasm32 bare target we ignore anything also ignored on emscripten // and then we also recognize `wasm32-bare` as the os for the target From 2d99a8650a26f0a6f705d52747c5d883cf9cd7c5 Mon Sep 17 00:00:00 2001 From: Andreas Jonson Date: Sun, 11 Apr 2021 18:38:05 +0200 Subject: [PATCH 4/7] stabilize const_cttz --- library/core/src/intrinsics.rs | 2 +- library/core/src/lib.rs | 1 - src/test/ui/consts/const-int-unchecked.rs | 9 +++++++ src/test/ui/consts/const-int-unchecked.stderr | 24 ++++++++++++++++++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index b5371d6b69dbb..1ba0b23ae5be3 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1543,7 +1543,7 @@ extern "rust-intrinsic" { /// let num_trailing = unsafe { cttz_nonzero(x) }; /// assert_eq!(num_trailing, 3); /// ``` - #[rustc_const_unstable(feature = "const_cttz", issue = "none")] + #[rustc_const_stable(feature = "const_cttz", since = "1.53.0")] pub fn cttz_nonzero(x: T) -> T; /// Reverses the bytes in an integer type `T`. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 760b8d8cbb060..85866523d9f13 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -79,7 +79,6 @@ #![feature(const_int_unchecked_arith)] #![feature(const_mut_refs)] #![feature(const_refs_to_cell)] -#![feature(const_cttz)] #![feature(const_panic)] #![feature(const_pin)] #![feature(const_fn)] diff --git a/src/test/ui/consts/const-int-unchecked.rs b/src/test/ui/consts/const-int-unchecked.rs index 41d8f7a0972bc..2ccc5d27bbb78 100644 --- a/src/test/ui/consts/const-int-unchecked.rs +++ b/src/test/ui/consts/const-int-unchecked.rs @@ -186,4 +186,13 @@ const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; //~^ ERROR any use of this value will cause an error //~| WARN this was previously accepted by the compiler but is being phased out +// capture fault with zero value + +const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; +//~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out +const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; +//~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out + fn main() {} diff --git a/src/test/ui/consts/const-int-unchecked.stderr b/src/test/ui/consts/const-int-unchecked.stderr index e5ecbbc71a7f6..999b26543e2d5 100644 --- a/src/test/ui/consts/const-int-unchecked.stderr +++ b/src/test/ui/consts/const-int-unchecked.stderr @@ -516,5 +516,27 @@ LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 -error: aborting due to 47 previous errors +error: any use of this value will cause an error + --> $DIR/const-int-unchecked.rs:191:25 + | +LL | const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; + | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- + | | + | `ctlz_nonzero` called on 0 + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 + +error: any use of this value will cause an error + --> $DIR/const-int-unchecked.rs:194:25 + | +LL | const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; + | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- + | | + | `cttz_nonzero` called on 0 + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 + +error: aborting due to 49 previous errors From 12249acdc8373efdcb9836ca00a714de1e5d5e65 Mon Sep 17 00:00:00 2001 From: Andreas Jonson Date: Sun, 11 Apr 2021 19:15:55 +0200 Subject: [PATCH 5/7] Stabilize nonzero_leading_trailing_zeros --- library/core/src/num/nonzero.rs | 10 ++++------ library/core/tests/lib.rs | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 111feb7dbec69..81262a2f91839 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -191,13 +191,12 @@ macro_rules! nonzero_leading_trailing_zeros { /// Basic usage: /// /// ``` - /// #![feature(nonzero_leading_trailing_zeros)] #[doc = concat!("let n = std::num::", stringify!($Ty), "::new(", stringify!($LeadingTestExpr), ").unwrap();")] /// /// assert_eq!(n.leading_zeros(), 0); /// ``` - #[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] - #[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] + #[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")] + #[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")] #[inline] pub const fn leading_zeros(self) -> u32 { // SAFETY: since `self` can not be zero it is safe to call ctlz_nonzero @@ -214,13 +213,12 @@ macro_rules! nonzero_leading_trailing_zeros { /// Basic usage: /// /// ``` - /// #![feature(nonzero_leading_trailing_zeros)] #[doc = concat!("let n = std::num::", stringify!($Ty), "::new(0b0101000).unwrap();")] /// /// assert_eq!(n.trailing_zeros(), 3); /// ``` - #[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] - #[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] + #[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")] + #[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")] #[inline] pub const fn trailing_zeros(self) -> u32 { // SAFETY: since `self` can not be zero it is safe to call cttz_nonzero diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 7dc6e220c08bc..950c33cc83a00 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -69,7 +69,6 @@ #![feature(ptr_metadata)] #![feature(once_cell)] #![feature(unsized_tuple_coercion)] -#![feature(nonzero_leading_trailing_zeros)] #![feature(const_option)] #![feature(integer_atomics)] #![feature(slice_group_by)] From d1e23b8af8615a0b0bbb22f11674b977d2ecdd54 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 11 Apr 2021 11:24:17 +0200 Subject: [PATCH 6/7] Stabilize duration_zero. --- library/core/src/time.rs | 7 ++----- library/core/tests/lib.rs | 1 - library/std/src/lib.rs | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 2219353b055ad..f6d480ae54b38 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -124,14 +124,13 @@ impl Duration { /// # Examples /// /// ``` - /// #![feature(duration_zero)] /// use std::time::Duration; /// /// let duration = Duration::ZERO; /// assert!(duration.is_zero()); /// assert_eq!(duration.as_nanos(), 0); /// ``` - #[unstable(feature = "duration_zero", issue = "73544")] + #[stable(feature = "duration_zero", since = "1.53.0")] pub const ZERO: Duration = Duration::from_nanos(0); /// The maximum duration. @@ -269,7 +268,6 @@ impl Duration { /// # Examples /// /// ``` - /// #![feature(duration_zero)] /// use std::time::Duration; /// /// assert!(Duration::ZERO.is_zero()); @@ -281,7 +279,7 @@ impl Duration { /// assert!(!Duration::from_nanos(1).is_zero()); /// assert!(!Duration::from_secs(1).is_zero()); /// ``` - #[unstable(feature = "duration_zero", issue = "73544")] + #[stable(feature = "duration_zero", since = "1.53.0")] #[inline] pub const fn is_zero(&self) -> bool { self.secs == 0 && self.nanos == 0 @@ -536,7 +534,6 @@ impl Duration { /// # Examples /// /// ``` - /// #![feature(duration_zero)] /// use std::time::Duration; /// /// assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1)); diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 3e5e5f32609db..4b52cc5aec155 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -24,7 +24,6 @@ #![feature(div_duration)] #![feature(duration_consts_2)] #![feature(duration_constants)] -#![feature(duration_zero)] #![feature(exact_size_is_empty)] #![feature(extern_types)] #![feature(flt2dec)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 91695ced6a962..d532bc076e0a8 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -261,7 +261,6 @@ #![cfg_attr(not(bootstrap), feature(doc_notable_trait))] #![feature(dropck_eyepatch)] #![feature(duration_constants)] -#![feature(duration_zero)] #![feature(edition_panic)] #![feature(exact_size_is_empty)] #![feature(exhaustive_patterns)] From b44ae964e2086b280a250dea62abad29164eea58 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 11 Apr 2021 11:36:35 +0200 Subject: [PATCH 7/7] Mark Duration::is_zero as rustc_const_stable. --- library/core/src/time.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index f6d480ae54b38..fa6a6c2cccc01 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -280,6 +280,7 @@ impl Duration { /// assert!(!Duration::from_secs(1).is_zero()); /// ``` #[stable(feature = "duration_zero", since = "1.53.0")] + #[rustc_const_stable(feature = "duration_zero", since = "1.53.0")] #[inline] pub const fn is_zero(&self) -> bool { self.secs == 0 && self.nanos == 0