Skip to content

Commit a11079b

Browse files
authored
Rollup merge of rust-lang#107706 - tgross35:atomic-as-mut-ptr, r=m-ou-se
Mark 'atomic_mut_ptr' methods const There's nothing that would block these methods from being const (just an UnsafeCell get), and it would be helpful for FFI interfaces in static contexts Related tracking issue: rust-lang#66893
2 parents 0978f42 + b51d3b9 commit a11079b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/core/src/sync/atomic.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,8 @@ impl AtomicBool {
928928
/// ```
929929
#[inline]
930930
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
931-
pub fn as_mut_ptr(&self) -> *mut bool {
932-
self.v.get() as *mut bool
931+
pub const fn as_mut_ptr(&self) -> *mut bool {
932+
self.v.get().cast()
933933
}
934934

935935
/// Fetches the value, and applies a function to it that returns an optional
@@ -1803,7 +1803,7 @@ impl<T> AtomicPtr<T> {
18031803
///
18041804
/// ```ignore (extern-declaration)
18051805
/// #![feature(atomic_mut_ptr)]
1806-
//// use std::sync::atomic::AtomicPtr;
1806+
/// use std::sync::atomic::AtomicPtr;
18071807
///
18081808
/// extern "C" {
18091809
/// fn my_atomic_op(arg: *mut *mut u32);
@@ -1819,7 +1819,7 @@ impl<T> AtomicPtr<T> {
18191819
/// ```
18201820
#[inline]
18211821
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
1822-
pub fn as_mut_ptr(&self) -> *mut *mut T {
1822+
pub const fn as_mut_ptr(&self) -> *mut *mut T {
18231823
self.p.get()
18241824
}
18251825
}
@@ -2727,7 +2727,7 @@ macro_rules! atomic_int {
27272727
#[unstable(feature = "atomic_mut_ptr",
27282728
reason = "recently added",
27292729
issue = "66893")]
2730-
pub fn as_mut_ptr(&self) -> *mut $int_type {
2730+
pub const fn as_mut_ptr(&self) -> *mut $int_type {
27312731
self.v.get()
27322732
}
27332733
}

0 commit comments

Comments
 (0)