Skip to content

Commit ce7c92d

Browse files
committed
Add #[rustc_significant_interior_mutable_type] to core and std types
1 parent 5a3fef5 commit ce7c92d

File tree

12 files changed

+29
-0
lines changed

12 files changed

+29
-0
lines changed

library/core/src/cell.rs

Lines changed: 3 additions & 0 deletions
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
}

library/core/src/cell/lazy.rs

Lines changed: 1 addition & 0 deletions
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
}

library/core/src/cell/once.rs

Lines changed: 1 addition & 0 deletions
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>>,

library/core/src/sync/atomic.rs

Lines changed: 16 additions & 0 deletions
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)))]
@@ -2124,6 +2126,7 @@ macro_rules! atomic_int {
21242126
$stable_nand:meta,
21252127
$const_stable:meta,
21262128
$diagnostic_item:meta,
2129+
$interior_mut_item:meta,
21272130
$s_int_type:literal,
21282131
$extra_feature:expr,
21292132
$min_fn:ident, $max_fn:ident,
@@ -2161,6 +2164,7 @@ macro_rules! atomic_int {
21612164
/// [module-level documentation]: crate::sync::atomic
21622165
#[$stable]
21632166
#[$diagnostic_item]
2167+
#[$interior_mut_item]
21642168
#[repr(C, align($align))]
21652169
pub struct $atomic_type {
21662170
v: UnsafeCell<$int_type>,
@@ -3055,6 +3059,7 @@ atomic_int! {
30553059
stable(feature = "integer_atomics_stable", since = "1.34.0"),
30563060
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
30573061
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI8"),
3062+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
30583063
"i8",
30593064
"",
30603065
atomic_min, atomic_max,
@@ -3073,6 +3078,7 @@ atomic_int! {
30733078
stable(feature = "integer_atomics_stable", since = "1.34.0"),
30743079
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
30753080
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU8"),
3081+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
30763082
"u8",
30773083
"",
30783084
atomic_umin, atomic_umax,
@@ -3091,6 +3097,7 @@ atomic_int! {
30913097
stable(feature = "integer_atomics_stable", since = "1.34.0"),
30923098
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
30933099
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI16"),
3100+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
30943101
"i16",
30953102
"",
30963103
atomic_min, atomic_max,
@@ -3109,6 +3116,7 @@ atomic_int! {
31093116
stable(feature = "integer_atomics_stable", since = "1.34.0"),
31103117
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31113118
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU16"),
3119+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31123120
"u16",
31133121
"",
31143122
atomic_umin, atomic_umax,
@@ -3127,6 +3135,7 @@ atomic_int! {
31273135
stable(feature = "integer_atomics_stable", since = "1.34.0"),
31283136
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31293137
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI32"),
3138+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31303139
"i32",
31313140
"",
31323141
atomic_min, atomic_max,
@@ -3145,6 +3154,7 @@ atomic_int! {
31453154
stable(feature = "integer_atomics_stable", since = "1.34.0"),
31463155
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31473156
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU32"),
3157+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31483158
"u32",
31493159
"",
31503160
atomic_umin, atomic_umax,
@@ -3163,6 +3173,7 @@ atomic_int! {
31633173
stable(feature = "integer_atomics_stable", since = "1.34.0"),
31643174
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31653175
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI64"),
3176+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31663177
"i64",
31673178
"",
31683179
atomic_min, atomic_max,
@@ -3181,6 +3192,7 @@ atomic_int! {
31813192
stable(feature = "integer_atomics_stable", since = "1.34.0"),
31823193
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
31833194
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU64"),
3195+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
31843196
"u64",
31853197
"",
31863198
atomic_umin, atomic_umax,
@@ -3199,6 +3211,7 @@ atomic_int! {
31993211
unstable(feature = "integer_atomics", issue = "99069"),
32003212
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
32013213
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"),
3214+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32023215
"i128",
32033216
"#![feature(integer_atomics)]\n\n",
32043217
atomic_min, atomic_max,
@@ -3217,6 +3230,7 @@ atomic_int! {
32173230
unstable(feature = "integer_atomics", issue = "99069"),
32183231
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
32193232
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"),
3233+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32203234
"u128",
32213235
"#![feature(integer_atomics)]\n\n",
32223236
atomic_umin, atomic_umax,
@@ -3239,6 +3253,7 @@ macro_rules! atomic_int_ptr_sized {
32393253
stable(feature = "atomic_nand", since = "1.27.0"),
32403254
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
32413255
cfg_attr(not(test), rustc_diagnostic_item = "AtomicIsize"),
3256+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32423257
"isize",
32433258
"",
32443259
atomic_min, atomic_max,
@@ -3257,6 +3272,7 @@ macro_rules! atomic_int_ptr_sized {
32573272
stable(feature = "atomic_nand", since = "1.27.0"),
32583273
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
32593274
cfg_attr(not(test), rustc_diagnostic_item = "AtomicUsize"),
3275+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
32603276
"usize",
32613277
"",
32623278
atomic_umin, atomic_umax,

library/std/src/sync/barrier.rs

Lines changed: 1 addition & 0 deletions
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,

library/std/src/sync/condvar.rs

Lines changed: 1 addition & 0 deletions
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
}

library/std/src/sync/lazy_lock.rs

Lines changed: 1 addition & 0 deletions
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>>,

library/std/src/sync/mutex.rs

Lines changed: 1 addition & 0 deletions
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,

library/std/src/sync/once.rs

Lines changed: 1 addition & 0 deletions
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
}

library/std/src/sync/once_lock.rs

Lines changed: 1 addition & 0 deletions
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()`.

library/std/src/sync/reentrant_lock.rs

Lines changed: 1 addition & 0 deletions
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,

library/std/src/sync/rwlock.rs

Lines changed: 1 addition & 0 deletions
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)