diff --git a/compiler/rustc_data_structures/src/marker.rs b/compiler/rustc_data_structures/src/marker.rs index 72d5f004194a8..e2193a97a0f43 100644 --- a/compiler/rustc_data_structures/src/marker.rs +++ b/compiler/rustc_data_structures/src/marker.rs @@ -59,11 +59,16 @@ macro_rules! already_send { // These structures are already `Send`. already_send!( - [std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr][std::io::Error][std::fs::File][std::panic::Location<'_>] - [rustc_arena::DroplessArena][jobserver_crate::Client][jobserver_crate::HelperThread] - [crate::memmap::Mmap][crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice] + [std::sync::atomic::AtomicBool][std::sync::atomic::AtomicUsize][std::sync::atomic::AtomicU8] + [std::sync::atomic::AtomicU32][std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr] + [std::io::Error][std::fs::File][std::panic::Location<'_>][rustc_arena::DroplessArena] + [jobserver_crate::Client][jobserver_crate::HelperThread][crate::memmap::Mmap] + [crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice] ); +#[cfg(target_has_atomic = "64")] +already_send!([std::sync::atomic::AtomicU64]); + macro_rules! impl_dyn_send { ($($($attr: meta)* [$ty: ty where $($generics2: tt)*])*) => { $(unsafe impl<$($generics2)*> DynSend for $ty {})* diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index a2427d9ca5889..6f9795db17ebe 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1036,31 +1036,13 @@ impl InvalidAtomicOrdering { expr: &Expr<'hir>, recognized_names: &[Symbol], // used for fast path calculation ) -> Option<(Symbol, &'hir [Expr<'hir>])> { - const ATOMIC_TYPES: &[Symbol] = &[ - sym::AtomicBool, - sym::AtomicPtr, - sym::AtomicUsize, - sym::AtomicU8, - sym::AtomicU16, - sym::AtomicU32, - sym::AtomicU64, - sym::AtomicU128, - sym::AtomicIsize, - sym::AtomicI8, - sym::AtomicI16, - sym::AtomicI32, - sym::AtomicI64, - sym::AtomicI128, - ]; if let ExprKind::MethodCall(method_path, _, args, _) = &expr.kind && recognized_names.contains(&method_path.ident.name) && let Some(m_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) // skip extension traits, only lint functions from the standard library && let Some(impl_did) = cx.tcx.inherent_impl_of_assoc(m_def_id) && let Some(adt) = cx.tcx.type_of(impl_did).instantiate_identity().ty_adt_def() - && let parent = cx.tcx.parent(adt.did()) - && cx.tcx.is_diagnostic_item(sym::atomic_mod, parent) - && ATOMIC_TYPES.contains(&cx.tcx.item_name(adt.did())) + && cx.tcx.is_diagnostic_item(sym::Atomic, adt.did()) { return Some((method_path.ident.name, args)); } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 3d40b7317459b..94f1436c02112 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -169,20 +169,7 @@ symbols! { AsyncGenFinished, AsyncGenPending, AsyncGenReady, - AtomicBool, - AtomicI8, - AtomicI16, - AtomicI32, - AtomicI64, - AtomicI128, - AtomicIsize, - AtomicPtr, - AtomicU8, - AtomicU16, - AtomicU32, - AtomicU64, - AtomicU128, - AtomicUsize, + Atomic, BTreeMap, Bool, Borrow, @@ -476,7 +463,6 @@ symbols! { atomic_load, atomic_max, atomic_min, - atomic_mod, atomic_nand, atomic_or, atomic_singlethreadfence, diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index adc2bbcde51b0..cfce867c446d7 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -238,7 +238,6 @@ #![stable(feature = "rust1", since = "1.0.0")] #![cfg_attr(not(target_has_atomic_load_store = "8"), allow(dead_code))] #![cfg_attr(not(target_has_atomic_load_store = "8"), allow(unused_imports))] -#![rustc_diagnostic_item = "atomic_mod"] // Clippy complains about the pattern of "safe function calling unsafe function taking pointers". // This happens with AtomicPtr intrinsics but is fine, as the pointers clippy is concerned about // are just normal values that get loaded/stored, but not dereferenced. @@ -248,40 +247,60 @@ use self::Ordering::*; use crate::cell::UnsafeCell; use crate::hint::spin_loop; use crate::intrinsics::AtomicOrdering as AO; +use crate::mem::transmute; use crate::{fmt, intrinsics}; -trait Sealed {} +#[unstable( + feature = "atomic_internals", + reason = "implementation detail which may disappear or be replaced at any time", + issue = "none" +)] +#[expect(missing_debug_implementations)] +mod private { + pub(super) trait Sealed {} + + #[cfg(target_has_atomic_load_store = "8")] + #[repr(C, align(1))] + pub struct Align1(T); + #[cfg(target_has_atomic_load_store = "16")] + #[repr(C, align(2))] + pub struct Align2(T); + #[cfg(target_has_atomic_load_store = "32")] + #[repr(C, align(4))] + pub struct Align4(T); + #[cfg(target_has_atomic_load_store = "64")] + #[repr(C, align(8))] + pub struct Align8(T); + #[cfg(target_has_atomic_load_store = "128")] + #[repr(C, align(16))] + pub struct Align16(T); +} /// A marker trait for primitive types which can be modified atomically. /// /// This is an implementation detail for [Atomic]\ which may disappear or be replaced at any time. -/// -/// # Safety -/// -/// Types implementing this trait must be primitives that can be modified atomically. -/// -/// The associated `Self::AtomicInner` type must have the same size and bit validity as `Self`, -/// but may have a higher alignment requirement, so the following `transmute`s are sound: -/// -/// - `&mut Self::AtomicInner` as `&mut Self` -/// - `Self` as `Self::AtomicInner` or the reverse +// +// # Safety +// +// Types implementing this trait must be primitives that can be modified atomically. +// +// The associated `Self::Storage` type must have the same size, but may have fewer validity +// invariants or a higher alignment requirement than `Self`. #[unstable( feature = "atomic_internals", reason = "implementation detail which may disappear or be replaced at any time", issue = "none" )] #[expect(private_bounds)] -pub unsafe trait AtomicPrimitive: Sized + Copy + Sealed { +pub unsafe trait AtomicPrimitive: Sized + Copy + private::Sealed { /// Temporary implementation detail. - type AtomicInner: Sized; + type Storage: Sized; } macro impl_atomic_primitive( - $Atom:ident $(<$T:ident>)? ($Primitive:ty), - size($size:literal), - align($align:literal) $(,)? + [$($T:ident)?] $Primitive:ty as $Storage:ident<$Operand:ty>, size($size:literal) ) { - impl $(<$T>)? Sealed for $Primitive {} + impl $(<$T>)? private::Sealed for $Primitive {} #[unstable( feature = "atomic_internals", @@ -290,42 +309,42 @@ macro impl_atomic_primitive( )] #[cfg(target_has_atomic_load_store = $size)] unsafe impl $(<$T>)? AtomicPrimitive for $Primitive { - type AtomicInner = $Atom $(<$T>)?; + type Storage = private::$Storage<$Operand>; } } -impl_atomic_primitive!(AtomicBool(bool), size("8"), align(1)); -impl_atomic_primitive!(AtomicI8(i8), size("8"), align(1)); -impl_atomic_primitive!(AtomicU8(u8), size("8"), align(1)); -impl_atomic_primitive!(AtomicI16(i16), size("16"), align(2)); -impl_atomic_primitive!(AtomicU16(u16), size("16"), align(2)); -impl_atomic_primitive!(AtomicI32(i32), size("32"), align(4)); -impl_atomic_primitive!(AtomicU32(u32), size("32"), align(4)); -impl_atomic_primitive!(AtomicI64(i64), size("64"), align(8)); -impl_atomic_primitive!(AtomicU64(u64), size("64"), align(8)); -impl_atomic_primitive!(AtomicI128(i128), size("128"), align(16)); -impl_atomic_primitive!(AtomicU128(u128), size("128"), align(16)); +impl_atomic_primitive!([] bool as Align1, size("8")); +impl_atomic_primitive!([] i8 as Align1, size("8")); +impl_atomic_primitive!([] u8 as Align1, size("8")); +impl_atomic_primitive!([] i16 as Align2, size("16")); +impl_atomic_primitive!([] u16 as Align2, size("16")); +impl_atomic_primitive!([] i32 as Align4, size("32")); +impl_atomic_primitive!([] u32 as Align4, size("32")); +impl_atomic_primitive!([] i64 as Align8, size("64")); +impl_atomic_primitive!([] u64 as Align8, size("64")); +impl_atomic_primitive!([] i128 as Align16, size("128")); +impl_atomic_primitive!([] u128 as Align16, size("128")); #[cfg(target_pointer_width = "16")] -impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(2)); +impl_atomic_primitive!([] isize as Align2, size("ptr")); #[cfg(target_pointer_width = "32")] -impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(4)); +impl_atomic_primitive!([] isize as Align4, size("ptr")); #[cfg(target_pointer_width = "64")] -impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(8)); +impl_atomic_primitive!([] isize as Align8, size("ptr")); #[cfg(target_pointer_width = "16")] -impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(2)); +impl_atomic_primitive!([] usize as Align2, size("ptr")); #[cfg(target_pointer_width = "32")] -impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(4)); +impl_atomic_primitive!([] usize as Align4, size("ptr")); #[cfg(target_pointer_width = "64")] -impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(8)); +impl_atomic_primitive!([] usize as Align8, size("ptr")); #[cfg(target_pointer_width = "16")] -impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(2)); +impl_atomic_primitive!([T] *mut T as Align2<*mut T>, size("ptr")); #[cfg(target_pointer_width = "32")] -impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(4)); +impl_atomic_primitive!([T] *mut T as Align4<*mut T>, size("ptr")); #[cfg(target_pointer_width = "64")] -impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(8)); +impl_atomic_primitive!([T] *mut T as Align8<*mut T>, size("ptr")); /// A memory location which can be safely modified from multiple threads. /// @@ -342,7 +361,16 @@ impl_atomic_primitive!(AtomicPtr(*mut T), size("ptr"), align(8)); /// /// [module-level documentation]: crate::sync::atomic #[unstable(feature = "generic_atomic", issue = "130539")] -pub type Atomic = ::AtomicInner; +#[repr(C)] +#[rustc_diagnostic_item = "Atomic"] +pub struct Atomic { + v: UnsafeCell, +} + +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Send for Atomic {} +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Sync for Atomic {} // Some architectures don't have byte-sized atomics, which results in LLVM // emulating them using a LL/SC loop. However for AtomicBool we can take @@ -367,11 +395,7 @@ const EMULATE_ATOMIC_BOOL: bool = cfg!(any( /// loads and stores of `u8`. #[cfg(target_has_atomic_load_store = "8")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_diagnostic_item = "AtomicBool"] -#[repr(C, align(1))] -pub struct AtomicBool { - v: UnsafeCell, -} +pub type AtomicBool = Atomic; #[cfg(target_has_atomic_load_store = "8")] #[stable(feature = "rust1", since = "1.0.0")] @@ -383,11 +407,6 @@ impl Default for AtomicBool { } } -// Send is implicitly implemented for AtomicBool. -#[cfg(target_has_atomic_load_store = "8")] -#[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Sync for AtomicBool {} - /// A raw pointer type which can be safely shared between threads. /// /// This type has the same size and bit validity as a `*mut T`. @@ -396,13 +415,7 @@ unsafe impl Sync for AtomicBool {} /// loads and stores of pointers. Its size depends on the target pointer's size. #[cfg(target_has_atomic_load_store = "ptr")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_diagnostic_item = "AtomicPtr"] -#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))] -#[cfg_attr(target_pointer_width = "32", repr(C, align(4)))] -#[cfg_attr(target_pointer_width = "64", repr(C, align(8)))] -pub struct AtomicPtr { - p: UnsafeCell<*mut T>, -} +pub type AtomicPtr = Atomic<*mut T>; #[cfg(target_has_atomic_load_store = "ptr")] #[stable(feature = "rust1", since = "1.0.0")] @@ -413,13 +426,6 @@ impl Default for AtomicPtr { } } -#[cfg(target_has_atomic_load_store = "ptr")] -#[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Send for AtomicPtr {} -#[cfg(target_has_atomic_load_store = "ptr")] -#[stable(feature = "rust1", since = "1.0.0")] -unsafe impl Sync for AtomicPtr {} - /// Atomic memory orderings /// /// Memory orderings specify the way atomic operations synchronize memory. @@ -528,7 +534,10 @@ impl AtomicBool { #[rustc_const_stable(feature = "const_atomic_new", since = "1.24.0")] #[must_use] pub const fn new(v: bool) -> AtomicBool { - AtomicBool { v: UnsafeCell::new(v as u8) } + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + unsafe { transmute(v) } } /// Creates a new `AtomicBool` from a pointer. @@ -597,7 +606,7 @@ impl AtomicBool { #[stable(feature = "atomic_access", since = "1.15.0")] pub fn get_mut(&mut self) -> &mut bool { // SAFETY: the mutable reference guarantees unique ownership. - unsafe { &mut *(self.v.get() as *mut bool) } + unsafe { &mut *self.as_ptr() } } /// Gets atomic access to a `&mut bool`. @@ -699,7 +708,12 @@ impl AtomicBool { #[stable(feature = "atomic_access", since = "1.15.0")] #[rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0")] pub const fn into_inner(self) -> bool { - self.v.into_inner() != 0 + // SAFETY: + // * `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + // * all operations on `Atomic` ensure that `T::Storage` remains + // a valid `bool`. + unsafe { transmute(self) } } /// Loads a value from the bool. @@ -726,7 +740,7 @@ impl AtomicBool { pub fn load(&self, order: Ordering) -> bool { // SAFETY: any data races are prevented by atomic intrinsics and the raw // pointer passed in is valid because we got it from a reference. - unsafe { atomic_load(self.v.get(), order) != 0 } + unsafe { atomic_load(self.v.get() as *mut u8, order) != 0 } } /// Stores a value into the bool. @@ -756,7 +770,7 @@ impl AtomicBool { // SAFETY: any data races are prevented by atomic intrinsics and the raw // pointer passed in is valid because we got it from a reference. unsafe { - atomic_store(self.v.get(), val as u8, order); + atomic_store(self.v.get() as *mut u8, val as u8, order); } } @@ -790,7 +804,7 @@ impl AtomicBool { if val { self.fetch_or(true, order) } else { self.fetch_and(false, order) } } else { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_swap(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_swap(self.v.get() as *mut u8, val as u8, order) != 0 } } } @@ -950,7 +964,13 @@ impl AtomicBool { } else { // SAFETY: data races are prevented by atomic intrinsics. match unsafe { - atomic_compare_exchange(self.v.get(), current as u8, new as u8, success, failure) + atomic_compare_exchange( + self.v.get() as *mut u8, + current as u8, + new as u8, + success, + failure, + ) } { Ok(x) => Ok(x != 0), Err(x) => Err(x != 0), @@ -1024,7 +1044,13 @@ impl AtomicBool { // SAFETY: data races are prevented by atomic intrinsics. match unsafe { - atomic_compare_exchange_weak(self.v.get(), current as u8, new as u8, success, failure) + atomic_compare_exchange_weak( + self.v.get() as *mut u8, + current as u8, + new as u8, + success, + failure, + ) } { Ok(x) => Ok(x != 0), Err(x) => Err(x != 0), @@ -1070,7 +1096,7 @@ impl AtomicBool { #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_and(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_and(self.v.get() as *mut u8, val as u8, order) != 0 } } /// Logical "nand" with a boolean value. @@ -1166,7 +1192,7 @@ impl AtomicBool { #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_or(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_or(self.v.get() as *mut u8, val as u8, order) != 0 } } /// Logical "xor" with a boolean value. @@ -1208,7 +1234,7 @@ impl AtomicBool { #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_xor(self.v.get(), val as u8, order) != 0 } + unsafe { atomic_xor(self.v.get() as *mut u8, val as u8, order) != 0 } } /// Logical "not" with a boolean value. @@ -1457,7 +1483,10 @@ impl AtomicPtr { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_atomic_new", since = "1.24.0")] pub const fn new(p: *mut T) -> AtomicPtr { - AtomicPtr { p: UnsafeCell::new(p) } + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + unsafe { transmute(p) } } /// Creates a new `AtomicPtr` from a pointer. @@ -1544,7 +1573,10 @@ impl AtomicPtr { #[inline] #[stable(feature = "atomic_access", since = "1.15.0")] pub fn get_mut(&mut self) -> &mut *mut T { - self.p.get_mut() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + unsafe { &mut *self.as_ptr() } } /// Gets atomic access to a pointer. @@ -1672,7 +1704,10 @@ impl AtomicPtr { #[stable(feature = "atomic_access", since = "1.15.0")] #[rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0")] pub const fn into_inner(self) -> *mut T { - self.p.into_inner() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + unsafe { transmute(self) } } /// Loads a value from the pointer. @@ -1699,7 +1734,7 @@ impl AtomicPtr { #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn load(&self, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_load(self.p.get(), order) } + unsafe { atomic_load(self.as_ptr(), order) } } /// Stores a value into the pointer. @@ -1730,7 +1765,7 @@ impl AtomicPtr { pub fn store(&self, ptr: *mut T, order: Ordering) { // SAFETY: data races are prevented by atomic intrinsics. unsafe { - atomic_store(self.p.get(), ptr, order); + atomic_store(self.as_ptr(), ptr, order); } } @@ -1763,7 +1798,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_swap(self.p.get(), ptr, order) } + unsafe { atomic_swap(self.as_ptr(), ptr, order) } } /// Stores a value into the pointer if the current value is the same as the `current` value. @@ -1887,7 +1922,7 @@ impl AtomicPtr { failure: Ordering, ) -> Result<*mut T, *mut T> { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_compare_exchange(self.p.get(), current, new, success, failure) } + unsafe { atomic_compare_exchange(self.as_ptr(), current, new, success, failure) } } /// Stores a value into the pointer if the current value is the same as the `current` value. @@ -1954,7 +1989,7 @@ impl AtomicPtr { // but we know for sure that the pointer is valid (we just got it from // an `UnsafeCell` that we have by reference) and the atomic operation // itself allows us to safely mutate the `UnsafeCell` contents. - unsafe { atomic_compare_exchange_weak(self.p.get(), current, new, success, failure) } + unsafe { atomic_compare_exchange_weak(self.as_ptr(), current, new, success, failure) } } /// An alias for [`AtomicPtr::try_update`]. @@ -2243,7 +2278,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_byte_add(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_add(self.p.get(), val, order).cast() } + unsafe { atomic_add(self.as_ptr(), val, order).cast() } } /// Offsets the pointer's address by subtracting `val` *bytes*, returning the @@ -2279,7 +2314,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_byte_sub(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_sub(self.p.get(), val, order).cast() } + unsafe { atomic_sub(self.as_ptr(), val, order).cast() } } /// Performs a bitwise "or" operation on the address of the current pointer, @@ -2330,7 +2365,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_or(self.p.get(), val, order).cast() } + unsafe { atomic_or(self.as_ptr(), val, order).cast() } } /// Performs a bitwise "and" operation on the address of the current @@ -2380,7 +2415,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_and(self.p.get(), val, order).cast() } + unsafe { atomic_and(self.as_ptr(), val, order).cast() } } /// Performs a bitwise "xor" operation on the address of the current @@ -2428,7 +2463,7 @@ impl AtomicPtr { #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_xor(self.p.get(), val, order).cast() } + unsafe { atomic_xor(self.as_ptr(), val, order).cast() } } /// Returns a mutable pointer to the underlying pointer. @@ -2467,7 +2502,7 @@ impl AtomicPtr { #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut *mut T { - self.p.get() + self.v.get().cast() } } @@ -2520,7 +2555,6 @@ macro_rules! atomic_int { $stable_nand:meta, $const_stable_new:meta, $const_stable_into_inner:meta, - $diagnostic_item:meta, $s_int_type:literal, $extra_feature:expr, $min_fn:ident, $max_fn:ident, @@ -2557,11 +2591,7 @@ macro_rules! atomic_int { /// /// [module-level documentation]: crate::sync::atomic #[$stable] - #[$diagnostic_item] - #[repr(C, align($align))] - pub struct $atomic_type { - v: UnsafeCell<$int_type>, - } + pub type $atomic_type = Atomic<$int_type>; #[$stable] impl Default for $atomic_type { @@ -2586,10 +2616,6 @@ macro_rules! atomic_int { } } - // Send is implicitly implemented. - #[$stable] - unsafe impl Sync for $atomic_type {} - impl $atomic_type { /// Creates a new atomic integer. /// @@ -2605,7 +2631,10 @@ macro_rules! atomic_int { #[$const_stable_new] #[must_use] pub const fn new(v: $int_type) -> Self { - Self {v: UnsafeCell::new(v)} + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + unsafe { transmute(v) } } /// Creates a new reference to an atomic integer from a pointer. @@ -2667,7 +2696,6 @@ macro_rules! atomic_int { unsafe { &*ptr.cast() } } - /// Returns a mutable reference to the underlying integer. /// /// This is safe because the mutable reference guarantees that no other threads are @@ -2686,7 +2714,10 @@ macro_rules! atomic_int { #[inline] #[$stable_access] pub fn get_mut(&mut self) -> &mut $int_type { - self.v.get_mut() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + unsafe { &mut *self.as_ptr() } } #[doc = concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.")] @@ -2815,7 +2846,10 @@ macro_rules! atomic_int { #[$stable_access] #[$const_stable_into_inner] pub const fn into_inner(self) -> $int_type { - self.v.into_inner() + // SAFETY: + // `Atomic` is essentially a transparent wrapper around `T` with + // interior mutability and potentially higher alignment. + unsafe { transmute(self) } } /// Loads a value from the atomic integer. @@ -2841,7 +2875,7 @@ macro_rules! atomic_int { #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn load(&self, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_load(self.v.get(), order) } + unsafe { atomic_load(self.as_ptr(), order) } } /// Stores a value into the atomic integer. @@ -2869,7 +2903,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn store(&self, val: $int_type, order: Ordering) { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_store(self.v.get(), val, order); } + unsafe { atomic_store(self.as_ptr(), val, order); } } /// Stores a value into the atomic integer, returning the previous value. @@ -2898,7 +2932,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_swap(self.v.get(), val, order) } + unsafe { atomic_swap(self.as_ptr(), val, order) } } /// Stores a value into the atomic integer if the current value is the same as @@ -3036,7 +3070,7 @@ macro_rules! atomic_int { success: Ordering, failure: Ordering) -> Result<$int_type, $int_type> { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_compare_exchange(self.v.get(), current, new, success, failure) } + unsafe { atomic_compare_exchange(self.as_ptr(), current, new, success, failure) } } /// Stores a value into the atomic integer if the current value is the same as @@ -3101,7 +3135,7 @@ macro_rules! atomic_int { failure: Ordering) -> Result<$int_type, $int_type> { // SAFETY: data races are prevented by atomic intrinsics. unsafe { - atomic_compare_exchange_weak(self.v.get(), current, new, success, failure) + atomic_compare_exchange_weak(self.as_ptr(), current, new, success, failure) } } @@ -3133,7 +3167,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_add(self.v.get(), val, order) } + unsafe { atomic_add(self.as_ptr(), val, order) } } /// Subtracts from the current value, returning the previous value. @@ -3164,7 +3198,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_sub(self.v.get(), val, order) } + unsafe { atomic_sub(self.as_ptr(), val, order) } } /// Bitwise "and" with the current value. @@ -3198,7 +3232,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_and(self.v.get(), val, order) } + unsafe { atomic_and(self.as_ptr(), val, order) } } /// Bitwise "nand" with the current value. @@ -3232,7 +3266,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_nand(self.v.get(), val, order) } + unsafe { atomic_nand(self.as_ptr(), val, order) } } /// Bitwise "or" with the current value. @@ -3266,7 +3300,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_or(self.v.get(), val, order) } + unsafe { atomic_or(self.as_ptr(), val, order) } } /// Bitwise "xor" with the current value. @@ -3300,7 +3334,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { atomic_xor(self.v.get(), val, order) } + unsafe { atomic_xor(self.as_ptr(), val, order) } } /// An alias for @@ -3499,7 +3533,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { $max_fn(self.v.get(), val, order) } + unsafe { $max_fn(self.as_ptr(), val, order) } } /// Minimum with the current value. @@ -3546,7 +3580,7 @@ macro_rules! atomic_int { #[rustc_should_not_be_called_on_const_items] pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. - unsafe { $min_fn(self.v.get(), val, order) } + unsafe { $min_fn(self.as_ptr(), val, order) } } /// Returns a mutable pointer to the underlying integer. @@ -3586,7 +3620,7 @@ macro_rules! atomic_int { #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] #[rustc_never_returns_null_ptr] pub const fn as_ptr(&self) -> *mut $int_type { - self.v.get() + self.v.get().cast() } } } @@ -3604,7 +3638,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI8", "i8", "", atomic_min, atomic_max, @@ -3623,7 +3656,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU8", "u8", "", atomic_umin, atomic_umax, @@ -3642,7 +3674,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI16", "i16", "", atomic_min, atomic_max, @@ -3661,7 +3692,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU16", "u16", "", atomic_umin, atomic_umax, @@ -3680,7 +3710,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI32", "i32", "", atomic_min, atomic_max, @@ -3699,7 +3728,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU32", "u32", "", atomic_umin, atomic_umax, @@ -3718,7 +3746,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicI64", "i64", "", atomic_min, atomic_max, @@ -3737,7 +3764,6 @@ atomic_int! { stable(feature = "integer_atomics_stable", since = "1.34.0"), rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicU64", "u64", "", atomic_umin, atomic_umax, @@ -3756,7 +3782,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), - rustc_diagnostic_item = "AtomicI128", "i128", "#![feature(integer_atomics)]\n\n", atomic_min, atomic_max, @@ -3775,7 +3800,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), rustc_const_unstable(feature = "integer_atomics", issue = "99069"), - rustc_diagnostic_item = "AtomicU128", "u128", "#![feature(integer_atomics)]\n\n", atomic_umin, atomic_umax, @@ -3798,7 +3822,6 @@ macro_rules! atomic_int_ptr_sized { stable(feature = "atomic_nand", since = "1.27.0"), rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicIsize", "isize", "", atomic_min, atomic_max, @@ -3817,7 +3840,6 @@ macro_rules! atomic_int_ptr_sized { stable(feature = "atomic_nand", since = "1.27.0"), rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"), rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"), - rustc_diagnostic_item = "AtomicUsize", "usize", "", atomic_umin, atomic_umax, diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py index b0b6682f5279e..bd27998b37706 100644 --- a/src/etc/gdb_providers.py +++ b/src/etc/gdb_providers.py @@ -18,6 +18,12 @@ def unwrap_unique_or_non_null(unique_or_nonnull): return ptr if ptr.type.code == gdb.TYPE_CODE_PTR else ptr[ptr.type.fields()[0]] +def unwrap_scalar_wrappers(wrapper): + while not wrapper.type.is_scalar: + wrapper = wrapper[wrapper.type.fields()[0]] + return wrapper + + # GDB 14 has a tag class that indicates that extension methods are ok # to call. Use of this tag only requires that printers hide local # attributes and methods by prefixing them with "_". @@ -197,8 +203,8 @@ def __init__(self, valobj, is_atomic=False): self._is_atomic = is_atomic self._ptr = unwrap_unique_or_non_null(valobj["ptr"]) self._value = self._ptr["data" if is_atomic else "value"] - self._strong = self._ptr["strong"]["v" if is_atomic else "value"]["value"] - self._weak = self._ptr["weak"]["v" if is_atomic else "value"]["value"] - 1 + self._strong = unwrap_scalar_wrappers(self._ptr["strong"]) + self._weak = unwrap_scalar_wrappers(self._ptr["weak"]) - 1 def to_string(self): if self._is_atomic: diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 582471622baa6..88d210691d00e 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -9,6 +9,7 @@ eBasicTypeUnsignedLong, eBasicTypeUnsignedChar, eFormatChar, + eTypeIsInteger, ) from rust_types import is_tuple_fields @@ -90,6 +91,12 @@ def unwrap_unique_or_non_null(unique_or_nonnull: SBValue) -> SBValue: return ptr if ptr.TypeIsPointerType() else ptr.GetChildAtIndex(0) +def unwrap_scalar_wrappers(wrapper: SBValue) -> SBValue: + while (wrapper.type.GetTypeFlags() & eTypeIsInteger) == 0: + wrapper = wrapper.GetChildAtIndex(0) + return wrapper + + class DefaultSyntheticProvider: def __init__(self, valobj: SBValue, _dict: LLDBOpaque): # logger = Logger.Logger() @@ -1246,12 +1253,9 @@ class StdRcSyntheticProvider: rust 1.33.0: struct NonNull { pointer: *const T } struct NonZero(T) struct RcInner { strong: Cell, weak: Cell, value: T } - struct Cell { value: UnsafeCell } - struct UnsafeCell { value: T } struct Arc { ptr: NonNull>, ... } - struct ArcInner { strong: atomic::AtomicUsize, weak: atomic::AtomicUsize, data: T } - struct AtomicUsize { v: UnsafeCell } + struct ArcInner { strong: atomic::Atomic, weak: atomic::Atomic, data: T } """ def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_atomic: bool = False): @@ -1261,16 +1265,8 @@ def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_atomic: bool = False): self.value = self.ptr.GetChildMemberWithName("data" if is_atomic else "value") - self.strong = ( - self.ptr.GetChildMemberWithName("strong") - .GetChildAtIndex(0) - .GetChildMemberWithName("value") - ) - self.weak = ( - self.ptr.GetChildMemberWithName("weak") - .GetChildAtIndex(0) - .GetChildMemberWithName("value") - ) + self.strong = unwrap_scalar_wrappers(self.ptr.GetChildMemberWithName("strong")) + self.weak = unwrap_scalar_wrappers(self.ptr.GetChildMemberWithName("weak")) self.value_builder = ValueBuilder(valobj) diff --git a/src/etc/natvis/libcore.natvis b/src/etc/natvis/libcore.natvis index d09f0d635692a..a2755888094a1 100644 --- a/src/etc/natvis/libcore.natvis +++ b/src/etc/natvis/libcore.natvis @@ -89,38 +89,38 @@ - - {(bool)v.value} + + {(bool)v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} - - {v.value} + + {v.value.__0} diff --git a/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs b/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs index d5dbcbe9dc701..ca8383070d70f 100644 --- a/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/missing_spin_loop.rs @@ -40,7 +40,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, cond: &'tcx Expr<'_>, body: &' && let ExprKind::MethodCall(method, callee, ..) = unpack_cond(cond).kind && [sym::load, sym::compare_exchange, sym::compare_exchange_weak].contains(&method.ident.name) && let callee_ty = cx.typeck_results().expr_ty(callee) - && callee_ty.is_diag_item(cx, sym::AtomicBool) + && callee_ty.is_diag_item(cx, sym::Atomic) && let Some(std_or_core) = std_or_core(cx) { span_lint_and_sugg( diff --git a/src/tools/clippy/tests/ui/mut_key.stderr b/src/tools/clippy/tests/ui/mut_key.stderr index 0d504584fbae8..e7a1d6833847e 100644 --- a/src/tools/clippy/tests/ui/mut_key.stderr +++ b/src/tools/clippy/tests/ui/mut_key.stderr @@ -5,8 +5,8 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability = note: `-D clippy::mutable-key-type` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::mutable_key_type)]` @@ -17,8 +17,8 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash | ^^^^^^^^^^^^ | = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability error: mutable key type --> tests/ui/mut_key.rs:35:5 @@ -27,8 +27,8 @@ LL | let _other: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability error: mutable key type --> tests/ui/mut_key.rs:64:22 @@ -38,8 +38,8 @@ LL | fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} | = note: ... because it contains `(Key, U)`, which has interior mutability = note: ... because it contains `Key`, which has interior mutability - = note: ... because it contains `AtomicUsize`, which has interior mutability - = note: ... because it contains `UnsafeCell`, which has interior mutability + = note: ... because it contains `Atomic`, which has interior mutability + = note: ... because it contains `UnsafeCell<::Storage>`, which has interior mutability error: mutable key type --> tests/ui/mut_key.rs:77:5 diff --git a/tests/debuginfo/numeric-types.rs b/tests/debuginfo/numeric-types.rs index 81fa7900c5faf..dbbc4ee6e8614 100644 --- a/tests/debuginfo/numeric-types.rs +++ b/tests/debuginfo/numeric-types.rs @@ -114,52 +114,40 @@ //@ cdb-check: [+0x000] __0 : 0x78 [Type: unsigned __int64] //@ cdb-command: dx a_bool_t -//@ cdb-check:a_bool_t : true [Type: core::sync::atomic::AtomicBool] -//@ cdb-check: [+0x000] v : 0x1 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_bool_t : true [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_bool_f -//@ cdb-check:a_bool_f : false [Type: core::sync::atomic::AtomicBool] -//@ cdb-check: [+0x000] v : 0x0 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_bool_f : false [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i8 -//@ cdb-check:a_i8 : 2 [Type: core::sync::atomic::AtomicI8] -//@ cdb-check: [+0x000] v : 2 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i8 : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i16 -//@ cdb-check:a_i16 : 4 [Type: core::sync::atomic::AtomicI16] -//@ cdb-check: [+0x000] v : 4 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i16 : 4 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i32 -//@ cdb-check:a_i32 : 8 [Type: core::sync::atomic::AtomicI32] -//@ cdb-check: [+0x000] v : 8 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i32 : 8 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_i64 -//@ cdb-check:a_i64 : 16 [Type: core::sync::atomic::AtomicI64] -//@ cdb-check: [+0x000] v : 16 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_i64 : 16 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_isize -//@ cdb-check:a_isize : 32 [Type: core::sync::atomic::AtomicIsize] -//@ cdb-check: [+0x000] v : 32 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_isize : 32 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u8 -//@ cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::AtomicU8] -//@ cdb-check: [+0x000] v : 0x40 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u16 -//@ cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::AtomicU16] -//@ cdb-check: [+0x000] v : 0x80 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u32 -//@ cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::AtomicU32] -//@ cdb-check: [+0x000] v : 0x100 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_u64 -//@ cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::AtomicU64] -//@ cdb-check: [+0x000] v : 0x200 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::Atomic] //@ cdb-command: dx a_usize -//@ cdb-check:a_usize : 0x400 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [+0x000] v : 0x400 [Type: core::cell::UnsafeCell] +//@ cdb-check:a_usize : 0x400 [Type: core::sync::atomic::Atomic] // === GDB TESTS =================================================================================== diff --git a/tests/debuginfo/rc_arc.rs b/tests/debuginfo/rc_arc.rs index a2eeeaad6aa8b..b22b7e0d1611d 100644 --- a/tests/debuginfo/rc_arc.rs +++ b/tests/debuginfo/rc_arc.rs @@ -38,13 +38,13 @@ //@ cdb-command:dx arc,d //@ cdb-check:arc,d : 222 [Type: alloc::sync::Arc] -//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx weak_arc,d //@ cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak] -//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx dyn_rc,d //@ cdb-check:dyn_rc,d [Type: alloc::rc::Rc,alloc::alloc::Global>] @@ -76,19 +76,19 @@ //@ cdb-command:dx dyn_arc,d //@ cdb-check:dyn_arc,d [Type: alloc::sync::Arc,alloc::alloc::Global>] -//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx dyn_arc_weak,d //@ cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak,alloc::alloc::Global>] -//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-command:dx slice_arc,d //@ cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc,alloc::alloc::Global>] //@ cdb-check: [Length] : 3 [Type: [...]] -//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-check: [0] : 4 [Type: u32] //@ cdb-check: [1] : 5 [Type: u32] //@ cdb-check: [2] : 6 [Type: u32] @@ -96,8 +96,8 @@ //@ cdb-command:dx slice_arc_weak,d //@ cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak,alloc::alloc::Global>] //@ cdb-check: [Length] : 3 [Type: [...]] -//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] -//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::Atomic] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic] //@ cdb-check: [0] : 4 [Type: u32] //@ cdb-check: [1] : 5 [Type: u32] //@ cdb-check: [2] : 6 [Type: u32] diff --git a/tests/rustdoc-html/jump-to-def/non-local-method.rs b/tests/rustdoc-html/jump-to-def/non-local-method.rs index c601f3259c4da..e084899b2495e 100644 --- a/tests/rustdoc-html/jump-to-def/non-local-method.rs +++ b/tests/rustdoc-html/jump-to-def/non-local-method.rs @@ -4,8 +4,8 @@ //@ has 'src/foo/non-local-method.rs.html' -//@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'std::sync::atomic::AtomicIsize' -use std::sync::atomic::AtomicIsize; +//@ has - '//a[@href="{{channel}}/alloc/boxed/struct.Box.html"]' 'std::boxed::Box' +use std::boxed::Box; //@ has - '//a[@href="{{channel}}/std/io/trait.Read.html"]' 'std::io::Read' use std::io::Read; //@ has - '//a[@href="{{channel}}/std/io/index.html"]' 'std::io' @@ -21,9 +21,9 @@ pub fn bar2(readable: T) { } pub fn bar() { - //@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'AtomicIsize' - //@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html#method.new"]' 'new' - let _ = AtomicIsize::new(0); + //@ has - '//a[@href="{{channel}}/alloc/boxed/struct.Box.html"]' 'Box' + //@ has - '//a[@href="{{channel}}/alloc/boxed/struct.Box.html#method.new"]' 'new' + let _ = Box::new(0); //@ has - '//a[@href="#49"]' 'local_private' local_private(); } diff --git a/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs b/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs index fa43924ff4ebf..1b2e756c2ce70 100644 --- a/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs +++ b/tests/rustdoc-html/reexport/overlapping-reexport-105735-2.rs @@ -1,26 +1,26 @@ -// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. +// Regression test to ensure that both `Thing` items are displayed but not the re-export. // https://github.com/rust-lang/rust/issues/105735 #![crate_name = "foo"] #![no_std] //@ has 'foo/index.html' -//@ has - '//dt/a[@class="type"]' 'AtomicU8' -//@ has - '//dt/a[@class="constant"]' 'AtomicU8' +//@ has - '//dt/a[@class="type"]' 'Thing' +//@ has - '//dt/a[@class="constant"]' 'Thing' // We also ensure we don't have another item displayed. //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' mod other { - pub type AtomicU8 = (); + pub type Thing = (); } mod thing { - pub use crate::other::AtomicU8; + pub use crate::other::Thing; #[allow(non_upper_case_globals)] - pub const AtomicU8: () = (); + pub const Thing: () = (); } -pub use crate::thing::AtomicU8; +pub use crate::thing::Thing; diff --git a/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs b/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs index d1b5c0b6749ad..499887b918ded 100644 --- a/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs +++ b/tests/rustdoc-html/reexport/overlapping-reexport-105735.rs @@ -1,22 +1,22 @@ -// Regression test to ensure that both `AtomicU8` items are displayed but not the re-export. +// Regression test to ensure that both `Ordering` items are displayed but not the re-export. // https://github.com/rust-lang/rust/issues/105735 #![crate_name = "foo"] #![no_std] //@ has 'foo/index.html' -//@ has - '//dt/a[@class="struct"]' 'AtomicU8' -//@ has - '//dt/a[@class="constant"]' 'AtomicU8' +//@ has - '//dt/a[@class="enum"]' 'Ordering' +//@ has - '//dt/a[@class="constant"]' 'Ordering' // We also ensure we don't have another item displayed. //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 -//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Enums' //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' mod thing { - pub use core::sync::atomic::AtomicU8; + pub use core::cmp::Ordering; #[allow(non_upper_case_globals)] - pub const AtomicU8: () = (); + pub const Ordering: () = (); } -pub use crate::thing::AtomicU8; +pub use crate::thing::Ordering; diff --git a/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr b/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr index d6aeb410ec4de..d237d21d77de3 100644 --- a/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr +++ b/tests/ui/borrowck/issue-47215-ice-from-drop-elab.stderr @@ -2,7 +2,7 @@ error[E0507]: cannot move out of static item `X` --> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 | LL | let mut x = X; - | ^ move occurs because `X` has type `AtomicUsize`, which does not implement the `Copy` trait + | ^ move occurs because `X` has type `Atomic`, which does not implement the `Copy` trait | help: consider borrowing here | diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.rs b/tests/ui/consts/const_refs_to_static-ice-121413.rs index 27d5d8600b4b0..d0f89283ed049 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.rs +++ b/tests/ui/consts/const_refs_to_static-ice-121413.rs @@ -5,7 +5,7 @@ //@ compile-flags: -Zextra-const-ub-checks // ignore-tidy-linelength const REF_INTERIOR_MUT: &usize = { - //~^ HELP consider importing this struct + //~^ HELP consider importing this type alias static FOO: Sync = AtomicUsize::new(0); //~^ ERROR cannot find //~| WARN trait objects without an explicit `dyn` are deprecated diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index 150b8cb079e72..2787109769324 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -4,7 +4,7 @@ error[E0433]: cannot find type `AtomicUsize` in this scope LL | static FOO: Sync = AtomicUsize::new(0); | ^^^^^^^^^^^ use of undeclared type `AtomicUsize` | -help: consider importing this struct +help: consider importing this type alias | LL + use std::sync::atomic::AtomicUsize; | diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs index eb78b5335cba9..9546f34792ad4 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -8,7 +8,7 @@ use std::sync::atomic::Ordering; const MUTATE_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - FOO.fetch_add(1, Ordering::Relaxed) //~ERROR calling non-const function `AtomicUsize::fetch_add` + FOO.fetch_add(1, Ordering::Relaxed) //~ERROR calling non-const function `Atomic::::fetch_add` }; const READ_INTERIOR_MUT: usize = { diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr index 5b8797c511627..bf7d6eecb7c3a 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -1,4 +1,4 @@ -error[E0080]: calling non-const function `AtomicUsize::fetch_add` +error[E0080]: calling non-const function `Atomic::::fetch_add` --> $DIR/const_refers_to_static.rs:11:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr index 908a196828999..dd6f561f5b799 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr @@ -4,7 +4,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -22,7 +22,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -39,7 +39,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(false, true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -56,7 +56,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -73,7 +73,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -90,7 +90,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -107,7 +107,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -124,7 +124,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -141,7 +141,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(true, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -158,7 +158,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_not` LL | let _a = A.fetch_not(Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -175,7 +175,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -192,7 +192,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -209,7 +209,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicBool` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -226,7 +226,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -243,7 +243,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -260,7 +260,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -275,7 +275,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:64:14 | LL | let _a = A.compare_exchange( - | ^ `A` is a interior mutable `const` item of type `AtomicPtr` + | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -299,7 +299,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch --> $DIR/const-item-interior-mutations-const-atomics.rs:72:14 | LL | let _a = A.compare_exchange_weak( - | ^ `A` is a interior mutable `const` item of type `AtomicPtr` + | ^ `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | ______________| | | LL | | @@ -325,7 +325,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -342,7 +342,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -359,7 +359,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -376,7 +376,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_ad LL | let _a = A.fetch_ptr_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -393,7 +393,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_ptr_su LL | let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -410,7 +410,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_a LL | let _a = A.fetch_byte_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -427,7 +427,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_byte_s LL | let _a = A.fetch_byte_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -444,7 +444,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_and` LL | let _a = A.fetch_and(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -461,7 +461,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -478,7 +478,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicPtr` + | `A` is a interior mutable `const` item of type `Atomic<*mut i32>` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -495,7 +495,7 @@ warning: mutation of an interior mutable `const` item with call to `store` LL | let _a = A.store(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -512,7 +512,7 @@ warning: mutation of an interior mutable `const` item with call to `swap` LL | let _a = A.swap(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -529,7 +529,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_and_ LL | let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -546,7 +546,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -563,7 +563,7 @@ warning: mutation of an interior mutable `const` item with call to `compare_exch LL | let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -580,7 +580,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -597,7 +597,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_sub` LL | let _a = A.fetch_sub(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -614,7 +614,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_add` LL | let _a = A.fetch_add(2, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -631,7 +631,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_nand` LL | let _a = A.fetch_nand(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -648,7 +648,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_or` LL | let _a = A.fetch_or(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -665,7 +665,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_xor` LL | let _a = A.fetch_xor(1, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -682,7 +682,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_update LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -699,7 +699,7 @@ warning: mutation of an interior mutable `const` item with call to `try_update` LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -716,7 +716,7 @@ warning: mutation of an interior mutable `const` item with call to `update` LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -733,7 +733,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_max` LL | let _a = A.fetch_max(20, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified @@ -750,7 +750,7 @@ warning: mutation of an interior mutable `const` item with call to `fetch_min` LL | let _a = A.fetch_min(5, Ordering::SeqCst); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | `A` is a interior mutable `const` item of type `AtomicU32` + | `A` is a interior mutable `const` item of type `Atomic` | = note: each usage of a `const` item creates a new temporary = note: only the temporaries and never the original `const A` will be modified diff --git a/tests/ui/resolve/112590-2.stderr b/tests/ui/resolve/112590-2.stderr index 8569dd0c3fa08..75e7961cb35f4 100644 --- a/tests/ui/resolve/112590-2.stderr +++ b/tests/ui/resolve/112590-2.stderr @@ -49,7 +49,7 @@ error[E0433]: cannot find `sync_error` in `std` LL | let _t = std::sync_error::atomic::AtomicBool::new(true); | ^^^^^^^^^^ could not find `sync_error` in `std` | -help: consider importing this struct +help: consider importing this type alias | LL + use std::sync::atomic::AtomicBool; | diff --git a/tests/ui/static/missing-type.stderr b/tests/ui/static/missing-type.stderr index 6489ceb700a2e..5aad521fb403e 100644 --- a/tests/ui/static/missing-type.stderr +++ b/tests/ui/static/missing-type.stderr @@ -2,7 +2,7 @@ error: missing type for `static` item --> $DIR/missing-type.rs:2:16 | LL | static S_COUNT: = std::sync::atomic::AtomicUsize::new(0); - | ^ help: provide a type for the static variable: `AtomicUsize` + | ^ help: provide a type for the static variable: `Atomic` error: aborting due to 1 previous error 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 93e189ffa0d3f..4b1cd8a5a1256 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,14 +1,20 @@ -error[E0599]: no function or associated item named `from_mut` found for struct `AtomicU64` in the current scope +error[E0599]: no function or associated item named `from_mut` found for struct `Atomic` in the current scope --> $DIR/atomic-from-mut-not-available.rs:24:36 | LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64); - | ^^^^^^^^ function or associated item not found in `AtomicU64` + | ^^^^^^^^ function or associated item not found in `Atomic` | -note: if you're trying to build a new `AtomicU64`, consider using `AtomicU64::new` which returns `AtomicU64` +note: if you're trying to build a new `Atomic`, consider using `Atomic::::new` which returns `Atomic` --> $SRC_DIR/core/src/sync/atomic.rs:LL:COL ::: $SRC_DIR/core/src/sync/atomic.rs:LL:COL | = note: in this macro invocation + = note: the function or associated item was found for + - `Atomic<*mut T>` + - `Atomic` + - `Atomic` + - `Atomic` + and 6 more types = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info) help: there is an associated function `from` with a similar name | 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 7e9de3570eb91..519b6977dcb56 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 @@ -22,6 +22,6 @@ fn main() { core::sync::atomic::AtomicU64::from_mut(&mut 0u64); - //[alignment_mismatch]~^ ERROR no function or associated item named `from_mut` found for struct `AtomicU64` + //[alignment_mismatch]~^ ERROR no function or associated item named `from_mut` found for struct `Atomic` //[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut` } diff --git a/tests/ui/suggestions/into-convert.rs b/tests/ui/suggestions/into-convert.rs index 1c9a9e0aaf561..3fdb2587727a4 100644 --- a/tests/ui/suggestions/into-convert.rs +++ b/tests/ui/suggestions/into-convert.rs @@ -13,7 +13,7 @@ fn main() { let z: AtomicU32 = 1; //~^ ERROR mismatched types - //~| HELP call `Into::into` on this expression to convert `{integer}` into `AtomicU32` + //~| HELP call `Into::into` on this expression to convert `{integer}` into `Atomic` } struct A; diff --git a/tests/ui/suggestions/into-convert.stderr b/tests/ui/suggestions/into-convert.stderr index 704b280a985f4..8a754e7d2b3c0 100644 --- a/tests/ui/suggestions/into-convert.stderr +++ b/tests/ui/suggestions/into-convert.stderr @@ -30,11 +30,13 @@ error[E0308]: mismatched types --> $DIR/into-convert.rs:14:24 | LL | let z: AtomicU32 = 1; - | --------- ^ expected `AtomicU32`, found integer + | --------- ^ expected `Atomic`, found integer | | | expected due to this | -help: call `Into::into` on this expression to convert `{integer}` into `AtomicU32` + = note: expected struct `Atomic` + found type `{integer}` +help: call `Into::into` on this expression to convert `{integer}` into `Atomic` | LL | let z: AtomicU32 = 1.into(); | +++++++ diff --git a/tests/ui/sync/atomic-types-not-copyable.stderr b/tests/ui/sync/atomic-types-not-copyable.stderr index 05103f5d8f265..4d6918e63c744 100644 --- a/tests/ui/sync/atomic-types-not-copyable.stderr +++ b/tests/ui/sync/atomic-types-not-copyable.stderr @@ -2,7 +2,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:11:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic`, which does not implement the `Copy` trait | help: consider removing the dereference here | @@ -14,7 +14,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:13:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic`, which does not implement the `Copy` trait | help: consider removing the dereference here | @@ -26,7 +26,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:15:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic`, which does not implement the `Copy` trait | help: consider removing the dereference here | @@ -38,7 +38,7 @@ error[E0507]: cannot move out of a shared reference --> $DIR/atomic-types-not-copyable.rs:17:13 | LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr`, which does not implement the `Copy` trait + | ^^^ move occurs because value has type `Atomic<*mut usize>`, which does not implement the `Copy` trait | help: consider removing the dereference here |