From 75616f630026d1e9cf5c051df86638eacd8de02e Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Mon, 29 Jun 2026 19:37:43 +0200 Subject: [PATCH] stabilize `feature(atomic_from_mut)` --- library/core/src/sync/atomic.rs | 27 +++++++------------ .../miri/tests/pass/0weak_memory/extra_cpp.rs | 2 -- ...mut-not-available.alignment_matches.stderr | 13 --------- ...ut-not-available.alignment_mismatch.stderr | 2 +- .../atomic-from-mut-not-available.rs | 2 +- 5 files changed, 11 insertions(+), 35 deletions(-) delete mode 100644 tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_matches.stderr diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index e8865823deb98..802d38e3994b3 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -608,7 +608,6 @@ impl AtomicBool { /// # Examples /// /// ``` - /// #![feature(atomic_from_mut)] /// use std::sync::atomic::{AtomicBool, Ordering}; /// /// let mut some_bool = true; @@ -618,7 +617,7 @@ impl AtomicBool { /// ``` #[inline] #[cfg(target_has_atomic_primitive_alignment = "8")] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn from_mut(v: &mut bool) -> &mut Self { // SAFETY: the mutable reference guarantees unique ownership, and // alignment of both `bool` and `Self` is 1. @@ -633,7 +632,6 @@ impl AtomicBool { /// # Examples /// /// ```ignore-wasm - /// #![feature(atomic_from_mut)] /// use std::sync::atomic::{AtomicBool, Ordering}; /// /// let mut some_bools = [const { AtomicBool::new(false) }; 10]; @@ -653,7 +651,7 @@ impl AtomicBool { /// }); /// ``` #[inline] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn get_mut_slice(this: &mut [Self]) -> &mut [bool] { // SAFETY: the mutable reference guarantees unique ownership. unsafe { &mut *(this as *mut [Self] as *mut [bool]) } @@ -664,7 +662,6 @@ impl AtomicBool { /// # Examples /// /// ```rust,ignore-wasm - /// #![feature(atomic_from_mut)] /// use std::sync::atomic::{AtomicBool, Ordering}; /// /// let mut some_bools = [false; 10]; @@ -678,7 +675,7 @@ impl AtomicBool { /// ``` #[inline] #[cfg(target_has_atomic_primitive_alignment = "8")] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn from_mut_slice(v: &mut [bool]) -> &mut [Self] { // SAFETY: the mutable reference guarantees unique ownership, and // alignment of both `bool` and `Self` is 1. @@ -1577,7 +1574,6 @@ impl AtomicPtr { /// # Examples /// /// ``` - /// #![feature(atomic_from_mut)] /// use std::sync::atomic::{AtomicPtr, Ordering}; /// /// let mut data = 123; @@ -1589,7 +1585,7 @@ impl AtomicPtr { /// ``` #[inline] #[cfg(target_has_atomic_primitive_alignment = "ptr")] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn from_mut(v: &mut *mut T) -> &mut Self { let [] = [(); align_of::>() - align_of::<*mut ()>()]; // SAFETY: @@ -1607,7 +1603,6 @@ impl AtomicPtr { /// # Examples /// /// ```ignore-wasm - /// #![feature(atomic_from_mut)] /// use std::ptr::null_mut; /// use std::sync::atomic::{AtomicPtr, Ordering}; /// @@ -1633,7 +1628,7 @@ impl AtomicPtr { /// }); /// ``` #[inline] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn get_mut_slice(this: &mut [Self]) -> &mut [*mut T] { // SAFETY: the mutable reference guarantees unique ownership. unsafe { &mut *(this as *mut [Self] as *mut [*mut T]) } @@ -1646,7 +1641,6 @@ impl AtomicPtr { /// # Examples /// /// ```ignore-wasm - /// #![feature(atomic_from_mut)] /// use std::ptr::null_mut; /// use std::sync::atomic::{AtomicPtr, Ordering}; /// @@ -1668,7 +1662,7 @@ impl AtomicPtr { /// ``` #[inline] #[cfg(target_has_atomic_primitive_alignment = "ptr")] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn from_mut_slice(v: &mut [*mut T]) -> &mut [Self] { // SAFETY: // - the mutable reference guarantees unique ownership. @@ -2721,7 +2715,6 @@ macro_rules! atomic_int { /// # Examples /// /// ``` - /// #![feature(atomic_from_mut)] #[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")] /// /// let mut some_int = 123; @@ -2732,7 +2725,7 @@ macro_rules! atomic_int { /// #[inline] #[$cfg_align] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn from_mut(v: &mut $int_type) -> &mut Self { let [] = [(); align_of::() - align_of::<$int_type>()]; // SAFETY: @@ -2750,7 +2743,6 @@ macro_rules! atomic_int { /// # Examples /// /// ```ignore-wasm - /// #![feature(atomic_from_mut)] #[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")] /// #[doc = concat!("let mut some_ints = [const { ", stringify!($atomic_type), "::new(0) }; 10];")] @@ -2772,7 +2764,7 @@ macro_rules! atomic_int { /// }); /// ``` #[inline] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn get_mut_slice(this: &mut [Self]) -> &mut [$int_type] { // SAFETY: the mutable reference guarantees unique ownership. unsafe { &mut *(this as *mut [Self] as *mut [$int_type]) } @@ -2791,7 +2783,6 @@ macro_rules! atomic_int { /// # Examples /// /// ```ignore-wasm - /// #![feature(atomic_from_mut)] #[doc = concat!($extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};")] /// /// let mut some_ints = [0; 10]; @@ -2807,7 +2798,7 @@ macro_rules! atomic_int { /// ``` #[inline] #[$cfg_align] - #[unstable(feature = "atomic_from_mut", issue = "76314")] + #[stable(feature = "atomic_from_mut", since = "CURRENT_RUSTC_VERSION")] pub fn from_mut_slice(v: &mut [$int_type]) -> &mut [Self] { let [] = [(); align_of::() - align_of::<$int_type>()]; // SAFETY: diff --git a/src/tools/miri/tests/pass/0weak_memory/extra_cpp.rs b/src/tools/miri/tests/pass/0weak_memory/extra_cpp.rs index 6791382f8e0f9..5f4e68b913335 100644 --- a/src/tools/miri/tests/pass/0weak_memory/extra_cpp.rs +++ b/src/tools/miri/tests/pass/0weak_memory/extra_cpp.rs @@ -3,8 +3,6 @@ // Tests operations not performable through C++'s atomic API // but doable in safe (at least sound) Rust. -#![feature(atomic_from_mut)] - use std::sync::atomic::Ordering::*; use std::sync::atomic::{AtomicU16, AtomicU32}; use std::thread::spawn; diff --git a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_matches.stderr b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_matches.stderr deleted file mode 100644 index 109985c005286..0000000000000 --- a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_matches.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: use of unstable library feature `atomic_from_mut` - --> $DIR/atomic-from-mut-not-available.rs:24:5 - | -LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #76314 for more information - = help: add `#![feature(atomic_from_mut)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr index 4df97a655d626..4d17a6d4b5e9e 100644 --- a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr +++ b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr @@ -1,5 +1,5 @@ error[E0599]: no associated function or constant named `from_mut` found for struct `Atomic` in the current scope - --> $DIR/atomic-from-mut-not-available.rs:24:36 + --> $DIR/atomic-from-mut-not-available.rs:25:36 | LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64); | ^^^^^^^^ associated function or constant not found in `Atomic` diff --git a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs index e8aad9cbeb9fa..0d5e09e6e2883 100644 --- a/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs +++ b/tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs @@ -19,9 +19,9 @@ // ... but pass on 64-bit x86_64 linux. //@[alignment_matches] only-x86_64 //@[alignment_matches] only-linux +//@[alignment_matches] check-pass fn main() { core::sync::atomic::AtomicU64::from_mut(&mut 0u64); //[alignment_mismatch]~^ ERROR no associated function or constant named `from_mut` found for struct `Atomic` - //[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut` }