Skip to content

Commit 2a930d3

Browse files
committed
Add #[rustc_significant_interior_mutable_type] to core and std types
1 parent afcb09b commit 2a930d3

File tree

12 files changed

+29
-0
lines changed

12 files changed

+29
-0
lines changed

Diff for: library/core/src/cell.rs

+3
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ pub use once::OnceCell;
307307
#[stable(feature = "rust1", since = "1.0.0")]
308308
#[repr(transparent)]
309309
#[rustc_pub_transparent]
310+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
310311
pub struct Cell<T: ?Sized> {
311312
value: UnsafeCell<T>,
312313
}
@@ -723,6 +724,7 @@ impl<T, const N: usize> Cell<[T; N]> {
723724
/// See the [module-level documentation](self) for more.
724725
#[cfg_attr(not(test), rustc_diagnostic_item = "RefCell")]
725726
#[stable(feature = "rust1", since = "1.0.0")]
727+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
726728
pub struct RefCell<T: ?Sized> {
727729
borrow: Cell<BorrowFlag>,
728730
// Stores the location of the earliest currently active borrow.
@@ -2068,6 +2070,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
20682070
#[stable(feature = "rust1", since = "1.0.0")]
20692071
#[repr(transparent)]
20702072
#[rustc_pub_transparent]
2073+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
20712074
pub struct UnsafeCell<T: ?Sized> {
20722075
value: T,
20732076
}

Diff for: library/core/src/cell/lazy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum State<T, F> {
3535
/// // 92
3636
/// ```
3737
#[stable(feature = "lazy_cell", since = "1.80.0")]
38+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
3839
pub struct LazyCell<T, F = fn() -> T> {
3940
state: UnsafeCell<State<T, F>>,
4041
}

Diff for: library/core/src/cell/once.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::{fmt, mem};
2929
/// assert!(cell.get().is_some());
3030
/// ```
3131
#[stable(feature = "once_cell", since = "1.70.0")]
32+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
3233
pub struct OnceCell<T> {
3334
// Invariant: written to at most once.
3435
inner: UnsafeCell<Option<T>>,

Diff for: library/core/src/sync/atomic.rs

+16
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ const EMULATE_ATOMIC_BOOL: bool =
266266
#[cfg(target_has_atomic_load_store = "8")]
267267
#[stable(feature = "rust1", since = "1.0.0")]
268268
#[rustc_diagnostic_item = "AtomicBool"]
269+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
269270
#[repr(C, align(1))]
270271
pub struct AtomicBool {
271272
v: UnsafeCell<u8>,
@@ -295,6 +296,7 @@ unsafe impl Sync for AtomicBool {}
295296
#[cfg(target_has_atomic_load_store = "ptr")]
296297
#[stable(feature = "rust1", since = "1.0.0")]
297298
#[cfg_attr(not(test), rustc_diagnostic_item = "AtomicPtr")]
299+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
298300
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
299301
#[cfg_attr(target_pointer_width = "32", repr(C, align(4)))]
300302
#[cfg_attr(target_pointer_width = "64", repr(C, align(8)))]
@@ -2125,6 +2127,7 @@ macro_rules! atomic_int {
21252127
$const_stable_new:meta,
21262128
$const_stable_into_inner:meta,
21272129
$diagnostic_item:meta,
2130+
$interior_mut_item:meta,
21282131
$s_int_type:literal,
21292132
$extra_feature:expr,
21302133
$min_fn:ident, $max_fn:ident,
@@ -2162,6 +2165,7 @@ macro_rules! atomic_int {
21622165
/// [module-level documentation]: crate::sync::atomic
21632166
#[$stable]
21642167
#[$diagnostic_item]
2168+
#[$interior_mut_item]
21652169
#[repr(C, align($align))]
21662170
pub struct $atomic_type {
21672171
v: UnsafeCell<$int_type>,
@@ -3057,6 +3061,7 @@ atomic_int! {
30573061
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
30583062
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
30593063
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI8"),
3064+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
30603065
"i8",
30613066
"",
30623067
atomic_min, atomic_max,
@@ -3076,6 +3081,7 @@ atomic_int! {
30763081
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
30773082
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
30783083
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU8"),
3084+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
30793085
"u8",
30803086
"",
30813087
atomic_umin, atomic_umax,
@@ -3095,6 +3101,7 @@ atomic_int! {
30953101
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
30963102
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
30973103
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI16"),
3104+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
30983105
"i16",
30993106
"",
31003107
atomic_min, atomic_max,
@@ -3114,6 +3121,7 @@ atomic_int! {
31143121
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31153122
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
31163123
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU16"),
3124+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31173125
"u16",
31183126
"",
31193127
atomic_umin, atomic_umax,
@@ -3133,6 +3141,7 @@ atomic_int! {
31333141
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31343142
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
31353143
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI32"),
3144+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31363145
"i32",
31373146
"",
31383147
atomic_min, atomic_max,
@@ -3152,6 +3161,7 @@ atomic_int! {
31523161
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31533162
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
31543163
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU32"),
3164+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31553165
"u32",
31563166
"",
31573167
atomic_umin, atomic_umax,
@@ -3171,6 +3181,7 @@ atomic_int! {
31713181
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31723182
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
31733183
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI64"),
3184+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31743185
"i64",
31753186
"",
31763187
atomic_min, atomic_max,
@@ -3190,6 +3201,7 @@ atomic_int! {
31903201
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31913202
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
31923203
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU64"),
3204+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31933205
"u64",
31943206
"",
31953207
atomic_umin, atomic_umax,
@@ -3209,6 +3221,7 @@ atomic_int! {
32093221
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
32103222
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
32113223
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"),
3224+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32123225
"i128",
32133226
"#![feature(integer_atomics)]\n\n",
32143227
atomic_min, atomic_max,
@@ -3228,6 +3241,7 @@ atomic_int! {
32283241
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
32293242
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
32303243
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"),
3244+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32313245
"u128",
32323246
"#![feature(integer_atomics)]\n\n",
32333247
atomic_umin, atomic_umax,
@@ -3251,6 +3265,7 @@ macro_rules! atomic_int_ptr_sized {
32513265
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
32523266
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
32533267
cfg_attr(not(test), rustc_diagnostic_item = "AtomicIsize"),
3268+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32543269
"isize",
32553270
"",
32563271
atomic_min, atomic_max,
@@ -3270,6 +3285,7 @@ macro_rules! atomic_int_ptr_sized {
32703285
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
32713286
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
32723287
cfg_attr(not(test), rustc_diagnostic_item = "AtomicUsize"),
3288+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32733289
"usize",
32743290
"",
32753291
atomic_umin, atomic_umax,

Diff for: library/std/src/sync/barrier.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::sync::{Condvar, Mutex};
3232
/// }
3333
/// ```
3434
#[stable(feature = "rust1", since = "1.0.0")]
35+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
3536
pub struct Barrier {
3637
lock: Mutex<BarrierState>,
3738
cvar: Condvar,

Diff for: library/std/src/sync/condvar.rs

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ impl WaitTimeoutResult {
107107
/// }
108108
/// ```
109109
#[stable(feature = "rust1", since = "1.0.0")]
110+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
110111
pub struct Condvar {
111112
inner: sys::Condvar,
112113
}

Diff for: library/std/src/sync/lazy_lock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ union Data<T, F> {
6262
/// }
6363
/// ```
6464
#[stable(feature = "lazy_cell", since = "1.80.0")]
65+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
6566
pub struct LazyLock<T, F = fn() -> T> {
6667
once: Once,
6768
data: UnsafeCell<Data<T, F>>,

Diff for: library/std/src/sync/mutex.rs

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ use crate::sys::sync as sys;
175175
///
176176
#[stable(feature = "rust1", since = "1.0.0")]
177177
#[cfg_attr(not(test), rustc_diagnostic_item = "Mutex")]
178+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
178179
pub struct Mutex<T: ?Sized> {
179180
inner: sys::Mutex,
180181
poison: poison::Flag,

Diff for: library/std/src/sync/once.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use crate::sys::sync as sys;
3535
/// [`OnceLock<T>`]: crate::sync::OnceLock
3636
/// [`LazyLock<T, F>`]: crate::sync::LazyLock
3737
#[stable(feature = "rust1", since = "1.0.0")]
38+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
3839
pub struct Once {
3940
inner: sys::Once,
4041
}

Diff for: library/std/src/sync/once_lock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ use crate::sync::Once;
100100
///
101101
/// ```
102102
#[stable(feature = "once_cell", since = "1.70.0")]
103+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
103104
pub struct OnceLock<T> {
104105
once: Once,
105106
// Whether or not the value is initialized is tracked by `once.is_completed()`.

Diff for: library/std/src/sync/reentrant_lock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ use crate::thread::{ThreadId, current_id};
8383
// we don't need to further synchronize the TID accesses, so they can be regular 64-bit
8484
// non-atomic accesses.
8585
#[unstable(feature = "reentrant_lock", issue = "121440")]
86+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
8687
pub struct ReentrantLock<T: ?Sized> {
8788
mutex: sys::Mutex,
8889
owner: Tid,

Diff for: library/std/src/sync/rwlock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ use crate::sys::sync as sys;
8080
/// [`Mutex`]: super::Mutex
8181
#[stable(feature = "rust1", since = "1.0.0")]
8282
#[cfg_attr(not(test), rustc_diagnostic_item = "RwLock")]
83+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
8384
pub struct RwLock<T: ?Sized> {
8485
inner: sys::RwLock,
8586
poison: poison::Flag,

0 commit comments

Comments
 (0)