diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-01-08 16:57:20 +0300 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-01-08 16:57:20 +0300 |
| commit | 2b03ed19f665fa599f3710e4ecd6ca28c945e664 (patch) | |
| tree | 5877219c78e7cb70944e99185905c1cc48e3c74e | |
| parent | 84abaf3f7dc2b7c2b453deb18890d00d28ebd844 (diff) | |
| download | rust-2b03ed19f665fa599f3710e4ecd6ca28c945e664.tar.gz rust-2b03ed19f665fa599f3710e4ecd6ca28c945e664.zip | |
Make `Atomic*::from_mut` return `&mut Atomic*`
| -rw-r--r-- | library/core/src/sync/atomic.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 1dd3b2d8e3c..27243d8ca70 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -333,10 +333,10 @@ impl AtomicBool { #[inline] #[cfg(target_has_atomic_equal_alignment = "8")] #[unstable(feature = "atomic_from_mut", issue = "76314")] - pub fn from_mut(v: &mut bool) -> &Self { + 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. - unsafe { &*(v as *mut bool as *mut Self) } + unsafe { &mut *(v as *mut bool as *mut Self) } } /// Consumes the atomic and returns the contained value. @@ -934,14 +934,14 @@ impl<T> AtomicPtr<T> { #[inline] #[cfg(target_has_atomic_equal_alignment = "ptr")] #[unstable(feature = "atomic_from_mut", issue = "76314")] - pub fn from_mut(v: &mut *mut T) -> &Self { + pub fn from_mut(v: &mut *mut T) -> &mut Self { use crate::mem::align_of; let [] = [(); align_of::<AtomicPtr<()>>() - align_of::<*mut ()>()]; // SAFETY: // - the mutable reference guarantees unique ownership. // - the alignment of `*mut T` and `Self` is the same on all platforms // supported by rust, as verified above. - unsafe { &*(v as *mut *mut T as *mut Self) } + unsafe { &mut *(v as *mut *mut T as *mut Self) } } /// Consumes the atomic and returns the contained value. @@ -1447,14 +1447,14 @@ macro_rules! atomic_int { #[inline] #[$cfg_align] #[unstable(feature = "atomic_from_mut", issue = "76314")] - pub fn from_mut(v: &mut $int_type) -> &Self { + pub fn from_mut(v: &mut $int_type) -> &mut Self { use crate::mem::align_of; let [] = [(); align_of::<Self>() - align_of::<$int_type>()]; // SAFETY: // - the mutable reference guarantees unique ownership. // - the alignment of `$int_type` and `Self` is the // same, as promised by $cfg_align and verified above. - unsafe { &*(v as *mut $int_type as *mut Self) } + unsafe { &mut *(v as *mut $int_type as *mut Self) } } /// Consumes the atomic and returns the contained value. |
