mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 17:40:16 +00:00
Rollup merge of #153015 - joboet:atomic_alias_generic, r=jhpratt
core: make atomic primitives type aliases of `Atomic<T>` Tracking issue: https://github.com/rust-lang/rust/issues/130539 This makes `AtomicI32` and friends type aliases of `Atomic<T>` by encoding their alignment requirements via the use of an internal `Storage` associated type. This is also used to encode that `AtomicBool` store a `u8` internally. Modulo the `Send`/`Sync` implementations, this PR does not move any trait implementations, methods or associated functions – I'll leave that for another PR.
This commit is contained in:
@@ -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 {})*
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -171,20 +171,7 @@ symbols! {
|
||||
AsyncGenFinished,
|
||||
AsyncGenPending,
|
||||
AsyncGenReady,
|
||||
AtomicBool,
|
||||
AtomicI8,
|
||||
AtomicI16,
|
||||
AtomicI32,
|
||||
AtomicI64,
|
||||
AtomicI128,
|
||||
AtomicIsize,
|
||||
AtomicPtr,
|
||||
AtomicU8,
|
||||
AtomicU16,
|
||||
AtomicU32,
|
||||
AtomicU64,
|
||||
AtomicU128,
|
||||
AtomicUsize,
|
||||
Atomic,
|
||||
BTreeMap,
|
||||
Bool,
|
||||
Borrow,
|
||||
@@ -485,7 +472,6 @@ symbols! {
|
||||
atomic_load,
|
||||
atomic_max,
|
||||
atomic_min,
|
||||
atomic_mod,
|
||||
atomic_nand,
|
||||
atomic_or,
|
||||
atomic_singlethreadfence,
|
||||
|
||||
@@ -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>(T);
|
||||
#[cfg(target_has_atomic_load_store = "16")]
|
||||
#[repr(C, align(2))]
|
||||
pub struct Align2<T>(T);
|
||||
#[cfg(target_has_atomic_load_store = "32")]
|
||||
#[repr(C, align(4))]
|
||||
pub struct Align4<T>(T);
|
||||
#[cfg(target_has_atomic_load_store = "64")]
|
||||
#[repr(C, align(8))]
|
||||
pub struct Align8<T>(T);
|
||||
#[cfg(target_has_atomic_load_store = "128")]
|
||||
#[repr(C, align(16))]
|
||||
pub struct Align16<T>(T);
|
||||
}
|
||||
|
||||
/// A marker trait for primitive types which can be modified atomically.
|
||||
///
|
||||
/// This is an implementation detail for <code>[Atomic]\<T></code> 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<u8>, size("8"));
|
||||
impl_atomic_primitive!([] i8 as Align1<i8>, size("8"));
|
||||
impl_atomic_primitive!([] u8 as Align1<u8>, size("8"));
|
||||
impl_atomic_primitive!([] i16 as Align2<i16>, size("16"));
|
||||
impl_atomic_primitive!([] u16 as Align2<u16>, size("16"));
|
||||
impl_atomic_primitive!([] i32 as Align4<i32>, size("32"));
|
||||
impl_atomic_primitive!([] u32 as Align4<u32>, size("32"));
|
||||
impl_atomic_primitive!([] i64 as Align8<i64>, size("64"));
|
||||
impl_atomic_primitive!([] u64 as Align8<u64>, size("64"));
|
||||
impl_atomic_primitive!([] i128 as Align16<i128>, size("128"));
|
||||
impl_atomic_primitive!([] u128 as Align16<u128>, size("128"));
|
||||
|
||||
#[cfg(target_pointer_width = "16")]
|
||||
impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(2));
|
||||
impl_atomic_primitive!([] isize as Align2<isize>, size("ptr"));
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(4));
|
||||
impl_atomic_primitive!([] isize as Align4<isize>, size("ptr"));
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
impl_atomic_primitive!(AtomicIsize(isize), size("ptr"), align(8));
|
||||
impl_atomic_primitive!([] isize as Align8<isize>, size("ptr"));
|
||||
|
||||
#[cfg(target_pointer_width = "16")]
|
||||
impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(2));
|
||||
impl_atomic_primitive!([] usize as Align2<usize>, size("ptr"));
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(4));
|
||||
impl_atomic_primitive!([] usize as Align4<usize>, size("ptr"));
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
impl_atomic_primitive!(AtomicUsize(usize), size("ptr"), align(8));
|
||||
impl_atomic_primitive!([] usize as Align8<usize>, size("ptr"));
|
||||
|
||||
#[cfg(target_pointer_width = "16")]
|
||||
impl_atomic_primitive!(AtomicPtr<T>(*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<T>(*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<T>(*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<T>(*mut T), size("ptr"), align(8));
|
||||
///
|
||||
/// [module-level documentation]: crate::sync::atomic
|
||||
#[unstable(feature = "generic_atomic", issue = "130539")]
|
||||
pub type Atomic<T> = <T as AtomicPrimitive>::AtomicInner;
|
||||
#[repr(C)]
|
||||
#[rustc_diagnostic_item = "Atomic"]
|
||||
pub struct Atomic<T: AtomicPrimitive> {
|
||||
v: UnsafeCell<T::Storage>,
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<T: AtomicPrimitive> Send for Atomic<T> {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<T: AtomicPrimitive> Sync for Atomic<T> {}
|
||||
|
||||
// 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<u8>,
|
||||
}
|
||||
pub type AtomicBool = Atomic<bool>;
|
||||
|
||||
#[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<T> {
|
||||
p: UnsafeCell<*mut T>,
|
||||
}
|
||||
pub type AtomicPtr<T> = Atomic<*mut T>;
|
||||
|
||||
#[cfg(target_has_atomic_load_store = "ptr")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@@ -413,13 +426,6 @@ impl<T> Default for AtomicPtr<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_has_atomic_load_store = "ptr")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<T> Send for AtomicPtr<T> {}
|
||||
#[cfg(target_has_atomic_load_store = "ptr")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe impl<T> Sync for AtomicPtr<T> {}
|
||||
|
||||
/// Atomic memory orderings
|
||||
///
|
||||
/// Memory orderings specify the way atomic operations synchronize memory.
|
||||
@@ -528,7 +534,9 @@ 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<T>` is essentially a transparent wrapper around `T`.
|
||||
unsafe { transmute(v) }
|
||||
}
|
||||
|
||||
/// Creates a new `AtomicBool` from a pointer.
|
||||
@@ -597,7 +605,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 +707,11 @@ 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<T>` is essentially a transparent wrapper around `T`.
|
||||
// * all operations on `Atomic<bool>` ensure that `T::Storage` remains
|
||||
// a valid `bool`.
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
|
||||
/// Loads a value from the bool.
|
||||
@@ -726,7 +738,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().cast::<u8>(), order) != 0 }
|
||||
}
|
||||
|
||||
/// Stores a value into the bool.
|
||||
@@ -756,7 +768,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().cast::<u8>(), val as u8, order);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -790,7 +802,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().cast::<u8>(), val as u8, order) != 0 }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -950,7 +962,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().cast::<u8>(),
|
||||
current as u8,
|
||||
new as u8,
|
||||
success,
|
||||
failure,
|
||||
)
|
||||
} {
|
||||
Ok(x) => Ok(x != 0),
|
||||
Err(x) => Err(x != 0),
|
||||
@@ -1024,7 +1042,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().cast::<u8>(),
|
||||
current as u8,
|
||||
new as u8,
|
||||
success,
|
||||
failure,
|
||||
)
|
||||
} {
|
||||
Ok(x) => Ok(x != 0),
|
||||
Err(x) => Err(x != 0),
|
||||
@@ -1070,7 +1094,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().cast::<u8>(), val as u8, order) != 0 }
|
||||
}
|
||||
|
||||
/// Logical "nand" with a boolean value.
|
||||
@@ -1166,7 +1190,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().cast::<u8>(), val as u8, order) != 0 }
|
||||
}
|
||||
|
||||
/// Logical "xor" with a boolean value.
|
||||
@@ -1208,7 +1232,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().cast::<u8>(), val as u8, order) != 0 }
|
||||
}
|
||||
|
||||
/// Logical "not" with a boolean value.
|
||||
@@ -1457,7 +1481,9 @@ impl<T> AtomicPtr<T> {
|
||||
#[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<T> {
|
||||
AtomicPtr { p: UnsafeCell::new(p) }
|
||||
// SAFETY:
|
||||
// `Atomic<T>` is essentially a transparent wrapper around `T`.
|
||||
unsafe { transmute(p) }
|
||||
}
|
||||
|
||||
/// Creates a new `AtomicPtr` from a pointer.
|
||||
@@ -1544,7 +1570,9 @@ impl<T> AtomicPtr<T> {
|
||||
#[inline]
|
||||
#[stable(feature = "atomic_access", since = "1.15.0")]
|
||||
pub fn get_mut(&mut self) -> &mut *mut T {
|
||||
self.p.get_mut()
|
||||
// SAFETY:
|
||||
// `Atomic<T>` is essentially a transparent wrapper around `T`.
|
||||
unsafe { &mut *self.as_ptr() }
|
||||
}
|
||||
|
||||
/// Gets atomic access to a pointer.
|
||||
@@ -1672,7 +1700,9 @@ impl<T> AtomicPtr<T> {
|
||||
#[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<T>` is essentially a transparent wrapper around `T`.
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
|
||||
/// Loads a value from the pointer.
|
||||
@@ -1699,7 +1729,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +1760,7 @@ impl<T> AtomicPtr<T> {
|
||||
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 +1793,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +1917,7 @@ impl<T> AtomicPtr<T> {
|
||||
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 +1984,7 @@ impl<T> AtomicPtr<T> {
|
||||
// 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 +2273,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +2309,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +2360,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +2410,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +2458,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +2497,7 @@ impl<T> AtomicPtr<T> {
|
||||
#[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 +2550,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 +2586,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 +2611,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 +2626,9 @@ macro_rules! atomic_int {
|
||||
#[$const_stable_new]
|
||||
#[must_use]
|
||||
pub const fn new(v: $int_type) -> Self {
|
||||
Self {v: UnsafeCell::new(v)}
|
||||
// SAFETY:
|
||||
// `Atomic<T>` is essentially a transparent wrapper around `T`.
|
||||
unsafe { transmute(v) }
|
||||
}
|
||||
|
||||
/// Creates a new reference to an atomic integer from a pointer.
|
||||
@@ -2667,7 +2690,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 +2708,9 @@ macro_rules! atomic_int {
|
||||
#[inline]
|
||||
#[$stable_access]
|
||||
pub fn get_mut(&mut self) -> &mut $int_type {
|
||||
self.v.get_mut()
|
||||
// SAFETY:
|
||||
// `Atomic<T>` is essentially a transparent wrapper around `T`.
|
||||
unsafe { &mut *self.as_ptr() }
|
||||
}
|
||||
|
||||
#[doc = concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.")]
|
||||
@@ -2815,7 +2839,9 @@ macro_rules! atomic_int {
|
||||
#[$stable_access]
|
||||
#[$const_stable_into_inner]
|
||||
pub const fn into_inner(self) -> $int_type {
|
||||
self.v.into_inner()
|
||||
// SAFETY:
|
||||
// `Atomic<T>` is essentially a transparent wrapper around `T`.
|
||||
unsafe { transmute(self) }
|
||||
}
|
||||
|
||||
/// Loads a value from the atomic integer.
|
||||
@@ -2841,7 +2867,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 +2895,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 +2924,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 +3062,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 +3127,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 +3159,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 +3190,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 +3224,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 +3258,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 +3292,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 +3326,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 +3525,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 +3572,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 +3612,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 +3630,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 +3648,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 +3666,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 +3684,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 +3702,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 +3720,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 +3738,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 +3756,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 +3774,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 +3792,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 +3814,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 +3832,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,
|
||||
|
||||
@@ -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 @@ class StdRcProvider(printer_base):
|
||||
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:
|
||||
|
||||
@@ -9,6 +9,7 @@ from lldb import (
|
||||
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<T> { pointer: *const T }
|
||||
struct NonZero<T>(T)
|
||||
struct RcInner<T> { strong: Cell<usize>, weak: Cell<usize>, value: T }
|
||||
struct Cell<T> { value: UnsafeCell<T> }
|
||||
struct UnsafeCell<T> { value: T }
|
||||
|
||||
struct Arc<T> { ptr: NonNull<ArcInner<T>>, ... }
|
||||
struct ArcInner<T> { strong: atomic::AtomicUsize, weak: atomic::AtomicUsize, data: T }
|
||||
struct AtomicUsize { v: UnsafeCell<usize> }
|
||||
struct ArcInner<T> { strong: atomic::Atomic<usize>, weak: atomic::Atomic<usize>, data: T }
|
||||
"""
|
||||
|
||||
def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_atomic: bool = False):
|
||||
@@ -1261,16 +1265,8 @@ class StdRcSyntheticProvider:
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -89,38 +89,38 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="core::sync::atomic::AtomicBool">
|
||||
<DisplayString>{(bool)v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<bool>">
|
||||
<DisplayString>{(bool)v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicI8">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<i8>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicI16">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<i16>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicI32">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<i32>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicI64">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<i64>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicIsize">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<isize>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicU8">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<u8>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicU16">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<u16>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicU32">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<u32>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicU64">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<u64>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
<Type Name="core::sync::atomic::AtomicUsize">
|
||||
<DisplayString>{v.value}</DisplayString>
|
||||
<Type Name="core::sync::atomic::Atomic<usize>">
|
||||
<DisplayString>{v.value.__0}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="core::time::Duration">
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -5,8 +5,8 @@ LL | fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _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<usize>`, which has interior mutability
|
||||
= note: ... because it contains `Atomic<usize>`, which has interior mutability
|
||||
= note: ... because it contains `UnsafeCell<<usize as AtomicPrimitive>::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<Key, usize>, _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<usize>`, which has interior mutability
|
||||
= note: ... because it contains `Atomic<usize>`, which has interior mutability
|
||||
= note: ... because it contains `UnsafeCell<<usize as AtomicPrimitive>::Storage>`, which has interior mutability
|
||||
|
||||
error: mutable key type
|
||||
--> tests/ui/mut_key.rs:35:5
|
||||
@@ -27,8 +27,8 @@ LL | let _other: HashMap<Key, bool> = 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<usize>`, which has interior mutability
|
||||
= note: ... because it contains `Atomic<usize>`, which has interior mutability
|
||||
= note: ... because it contains `UnsafeCell<<usize as AtomicPrimitive>::Storage>`, which has interior mutability
|
||||
|
||||
error: mutable key type
|
||||
--> tests/ui/mut_key.rs:64:22
|
||||
@@ -38,8 +38,8 @@ LL | fn tuples_bad<U>(_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<usize>`, which has interior mutability
|
||||
= note: ... because it contains `Atomic<usize>`, which has interior mutability
|
||||
= note: ... because it contains `UnsafeCell<<usize as AtomicPrimitive>::Storage>`, which has interior mutability
|
||||
|
||||
error: mutable key type
|
||||
--> tests/ui/mut_key.rs:77:5
|
||||
|
||||
@@ -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<u8>]
|
||||
//@ cdb-check:a_bool_t : true [Type: core::sync::atomic::Atomic<bool>]
|
||||
|
||||
//@ 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<u8>]
|
||||
//@ cdb-check:a_bool_f : false [Type: core::sync::atomic::Atomic<bool>]
|
||||
|
||||
//@ cdb-command: dx a_i8
|
||||
//@ cdb-check:a_i8 : 2 [Type: core::sync::atomic::AtomicI8]
|
||||
//@ cdb-check: [+0x000] v : 2 [Type: core::cell::UnsafeCell<i8>]
|
||||
//@ cdb-check:a_i8 : 2 [Type: core::sync::atomic::Atomic<i8>]
|
||||
|
||||
//@ cdb-command: dx a_i16
|
||||
//@ cdb-check:a_i16 : 4 [Type: core::sync::atomic::AtomicI16]
|
||||
//@ cdb-check: [+0x000] v : 4 [Type: core::cell::UnsafeCell<i16>]
|
||||
//@ cdb-check:a_i16 : 4 [Type: core::sync::atomic::Atomic<i16>]
|
||||
|
||||
//@ cdb-command: dx a_i32
|
||||
//@ cdb-check:a_i32 : 8 [Type: core::sync::atomic::AtomicI32]
|
||||
//@ cdb-check: [+0x000] v : 8 [Type: core::cell::UnsafeCell<i32>]
|
||||
//@ cdb-check:a_i32 : 8 [Type: core::sync::atomic::Atomic<i32>]
|
||||
|
||||
//@ cdb-command: dx a_i64
|
||||
//@ cdb-check:a_i64 : 16 [Type: core::sync::atomic::AtomicI64]
|
||||
//@ cdb-check: [+0x000] v : 16 [Type: core::cell::UnsafeCell<i64>]
|
||||
//@ cdb-check:a_i64 : 16 [Type: core::sync::atomic::Atomic<i64>]
|
||||
|
||||
//@ cdb-command: dx a_isize
|
||||
//@ cdb-check:a_isize : 32 [Type: core::sync::atomic::AtomicIsize]
|
||||
//@ cdb-check: [+0x000] v : 32 [Type: core::cell::UnsafeCell<isize>]
|
||||
//@ cdb-check:a_isize : 32 [Type: core::sync::atomic::Atomic<isize>]
|
||||
|
||||
//@ cdb-command: dx a_u8
|
||||
//@ cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::AtomicU8]
|
||||
//@ cdb-check: [+0x000] v : 0x40 [Type: core::cell::UnsafeCell<u8>]
|
||||
//@ cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::Atomic<u8>]
|
||||
|
||||
//@ cdb-command: dx a_u16
|
||||
//@ cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::AtomicU16]
|
||||
//@ cdb-check: [+0x000] v : 0x80 [Type: core::cell::UnsafeCell<u16>]
|
||||
//@ cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::Atomic<u16>]
|
||||
|
||||
//@ cdb-command: dx a_u32
|
||||
//@ cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::AtomicU32]
|
||||
//@ cdb-check: [+0x000] v : 0x100 [Type: core::cell::UnsafeCell<u32>]
|
||||
//@ cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::Atomic<u32>]
|
||||
|
||||
//@ cdb-command: dx a_u64
|
||||
//@ cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::AtomicU64]
|
||||
//@ cdb-check: [+0x000] v : 0x200 [Type: core::cell::UnsafeCell<u64>]
|
||||
//@ cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::Atomic<u64>]
|
||||
|
||||
//@ cdb-command: dx a_usize
|
||||
//@ cdb-check:a_usize : 0x400 [Type: core::sync::atomic::AtomicUsize]
|
||||
//@ cdb-check: [+0x000] v : 0x400 [Type: core::cell::UnsafeCell<usize>]
|
||||
//@ cdb-check:a_usize : 0x400 [Type: core::sync::atomic::Atomic<usize>]
|
||||
|
||||
|
||||
// === GDB TESTS ===================================================================================
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
|
||||
//@ cdb-command:dx arc,d
|
||||
//@ cdb-check:arc,d : 222 [Type: alloc::sync::Arc<i32,alloc::alloc::Global>]
|
||||
//@ 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<usize>]
|
||||
//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic<usize>]
|
||||
|
||||
//@ cdb-command:dx weak_arc,d
|
||||
//@ cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak<i32,alloc::alloc::Global>]
|
||||
//@ 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<usize>]
|
||||
//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic<usize>]
|
||||
|
||||
//@ cdb-command:dx dyn_rc,d
|
||||
//@ cdb-check:dyn_rc,d [Type: alloc::rc::Rc<dyn$<core::fmt::Debug>,alloc::alloc::Global>]
|
||||
@@ -76,19 +76,19 @@
|
||||
|
||||
//@ cdb-command:dx dyn_arc,d
|
||||
//@ cdb-check:dyn_arc,d [Type: alloc::sync::Arc<dyn$<core::fmt::Debug>,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<usize>]
|
||||
//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic<usize>]
|
||||
|
||||
//@ cdb-command:dx dyn_arc_weak,d
|
||||
//@ cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak<dyn$<core::fmt::Debug>,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<usize>]
|
||||
//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic<usize>]
|
||||
|
||||
//@ cdb-command:dx slice_arc,d
|
||||
//@ cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc<slice2$<u32>,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<usize>]
|
||||
//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic<usize>]
|
||||
//@ 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<slice2$<u32>,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<usize>]
|
||||
//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::Atomic<usize>]
|
||||
//@ cdb-check: [0] : 4 [Type: u32]
|
||||
//@ cdb-check: [1] : 5 [Type: u32]
|
||||
//@ cdb-check: [2] : 6 [Type: u32]
|
||||
|
||||
@@ -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<T: Read>(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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<usize>`, which does not implement the `Copy` trait
|
||||
|
|
||||
help: consider borrowing here
|
||||
|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
|
||||
|
||||
@@ -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::<usize>::fetch_add`
|
||||
};
|
||||
|
||||
const READ_INTERIOR_MUT: usize = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
error[E0080]: calling non-const function `AtomicUsize::fetch_add`
|
||||
error[E0080]: calling non-const function `Atomic::<usize>::fetch_add`
|
||||
--> $DIR/const_refers_to_static.rs:11:5
|
||||
|
|
||||
LL | FOO.fetch_add(1, Ordering::Relaxed)
|
||||
|
||||
@@ -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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<bool>`
|
||||
|
|
||||
= 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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| ^ `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<i32>`
|
||||
| ^ `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<i32>`
|
||||
| `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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= 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<u32>`
|
||||
|
|
||||
= note: each usage of a `const` item creates a new temporary
|
||||
= note: only the temporaries and never the original `const A` will be modified
|
||||
|
||||
@@ -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;
|
||||
|
|
||||
|
||||
@@ -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<usize>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
||||
@@ -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<u64>` 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<u64>`
|
||||
|
|
||||
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<u64>`, consider using `Atomic::<u64>::new` which returns `Atomic<u64>`
|
||||
--> $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<bool>`
|
||||
- `Atomic<i16>`
|
||||
- `Atomic<i32>`
|
||||
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
|
||||
|
|
||||
|
||||
@@ -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<u64>`
|
||||
//[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut`
|
||||
}
|
||||
|
||||
@@ -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<u32>`
|
||||
}
|
||||
|
||||
struct A;
|
||||
|
||||
@@ -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<u32>`, found integer
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
help: call `Into::into` on this expression to convert `{integer}` into `AtomicU32`
|
||||
= note: expected struct `Atomic<u32>`
|
||||
found type `{integer}`
|
||||
help: call `Into::into` on this expression to convert `{integer}` into `Atomic<u32>`
|
||||
|
|
||||
LL | let z: AtomicU32 = 1.into();
|
||||
| +++++++
|
||||
|
||||
@@ -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<bool>`, 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<isize>`, 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<usize>`, 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<usize>`, 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
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user