Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1dfe94c

Browse files
authoredNov 16, 2024
Rollup merge of rust-lang#131717 - tgross35:stabilize-const_atomic_from_ptr, r=RalfJung
Stabilize `const_atomic_from_ptr` The API is already stable since rust-lang#115719, but const stability was blocked on `const_mut_refs`. Since that was recently stabilized, const stabilize the following: ```rust // core::atomic impl AtomicBool { pub const unsafe fn from_ptr<'a>(ptr: *mut bool) -> &'a AtomicBool; } impl<T> AtomicPtr<T> { pub const unsafe fn from_ptr<'a>(ptr: *mut *mut T) -> &'a AtomicPtr<T>; } impl AtomicU8 { pub const unsafe fn from_ptr<'a>(ptr: *mut u8) -> &'a AtomicU8; } impl AtomicU16 { pub const unsafe fn from_ptr<'a>(ptr: *mut u16) -> &'a AtomicU16; } impl AtomicU32 { pub const unsafe fn from_ptr<'a>(ptr: *mut u32) -> &'a AtomicU32; } impl AtomicU64 { pub const unsafe fn from_ptr<'a>(ptr: *mut u64) -> &'a AtomicU64; } impl AtomicUsize { pub const unsafe fn from_ptr<'a>(ptr: *mut usize) -> &'a AtomicUsize; } impl AtomicI8 { pub const unsafe fn from_ptr<'a>(ptr: *mut i8) -> &'a AtomicI8; } impl AtomicI16 { pub const unsafe fn from_ptr<'a>(ptr: *mut i16) -> &'a AtomicI16; } impl AtomicI32 { pub const unsafe fn from_ptr<'a>(ptr: *mut i32) -> &'a AtomicI32; } impl AtomicI64 { pub const unsafe fn from_ptr<'a>(ptr: *mut i64) -> &'a AtomicI64; } impl AtomicIsize { pub const unsafe fn from_ptr<'a>(ptr: *mut isize) -> &'a AtomicIsize; } ```
2 parents 4010980 + 34329c0 commit 1dfe94c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎core/src/sync/atomic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl AtomicBool {
469469
/// [valid]: crate::ptr#safety
470470
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
471471
#[stable(feature = "atomic_from_ptr", since = "1.75.0")]
472-
#[rustc_const_unstable(feature = "const_atomic_from_ptr", issue = "108652")]
472+
#[rustc_const_stable(feature = "const_atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")]
473473
pub const unsafe fn from_ptr<'a>(ptr: *mut bool) -> &'a AtomicBool {
474474
// SAFETY: guaranteed by the caller
475475
unsafe { &*ptr.cast() }
@@ -1264,7 +1264,7 @@ impl<T> AtomicPtr<T> {
12641264
/// [valid]: crate::ptr#safety
12651265
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
12661266
#[stable(feature = "atomic_from_ptr", since = "1.75.0")]
1267-
#[rustc_const_unstable(feature = "const_atomic_from_ptr", issue = "108652")]
1267+
#[rustc_const_stable(feature = "const_atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")]
12681268
pub const unsafe fn from_ptr<'a>(ptr: *mut *mut T) -> &'a AtomicPtr<T> {
12691269
// SAFETY: guaranteed by the caller
12701270
unsafe { &*ptr.cast() }
@@ -2263,7 +2263,7 @@ macro_rules! atomic_int {
22632263
/// [valid]: crate::ptr#safety
22642264
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
22652265
#[stable(feature = "atomic_from_ptr", since = "1.75.0")]
2266-
#[rustc_const_unstable(feature = "const_atomic_from_ptr", issue = "108652")]
2266+
#[rustc_const_stable(feature = "const_atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")]
22672267
pub const unsafe fn from_ptr<'a>(ptr: *mut $int_type) -> &'a $atomic_type {
22682268
// SAFETY: guaranteed by the caller
22692269
unsafe { &*ptr.cast() }

0 commit comments

Comments
 (0)
Failed to load comments.