Skip to content

Commit c44f879

Browse files
committed
Add #[rustc_significant_interior_mutable_type] to core and std types
1 parent be30909 commit c44f879

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
@@ -308,6 +308,7 @@ pub use once::OnceCell;
308308
#[stable(feature = "rust1", since = "1.0.0")]
309309
#[repr(transparent)]
310310
#[rustc_pub_transparent]
311+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
311312
pub struct Cell<T: ?Sized> {
312313
value: UnsafeCell<T>,
313314
}
@@ -727,6 +728,7 @@ impl<T, const N: usize> Cell<[T; N]> {
727728
/// See the [module-level documentation](self) for more.
728729
#[rustc_diagnostic_item = "RefCell"]
729730
#[stable(feature = "rust1", since = "1.0.0")]
731+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
730732
pub struct RefCell<T: ?Sized> {
731733
borrow: Cell<BorrowFlag>,
732734
// Stores the location of the earliest currently active borrow.
@@ -2072,6 +2074,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
20722074
#[stable(feature = "rust1", since = "1.0.0")]
20732075
#[repr(transparent)]
20742076
#[rustc_pub_transparent]
2077+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
20752078
pub struct UnsafeCell<T: ?Sized> {
20762079
value: T,
20772080
}

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
@@ -32,6 +32,7 @@ use crate::{fmt, mem};
3232
/// assert!(cell.get().is_some());
3333
/// ```
3434
#[stable(feature = "once_cell", since = "1.70.0")]
35+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
3536
pub struct OnceCell<T> {
3637
// Invariant: written to at most once.
3738
inner: UnsafeCell<Option<T>>,

library/core/src/sync/atomic.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ const EMULATE_ATOMIC_BOOL: bool =
267267
#[cfg(target_has_atomic_load_store = "8")]
268268
#[stable(feature = "rust1", since = "1.0.0")]
269269
#[rustc_diagnostic_item = "AtomicBool"]
270+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
270271
#[repr(C, align(1))]
271272
pub struct AtomicBool {
272273
v: UnsafeCell<u8>,
@@ -296,6 +297,7 @@ unsafe impl Sync for AtomicBool {}
296297
#[cfg(target_has_atomic_load_store = "ptr")]
297298
#[stable(feature = "rust1", since = "1.0.0")]
298299
#[rustc_diagnostic_item = "AtomicPtr"]
300+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
299301
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
300302
#[cfg_attr(target_pointer_width = "32", repr(C, align(4)))]
301303
#[cfg_attr(target_pointer_width = "64", repr(C, align(8)))]
@@ -2388,6 +2390,7 @@ macro_rules! atomic_int {
23882390
$const_stable_new:meta,
23892391
$const_stable_into_inner:meta,
23902392
$diagnostic_item:meta,
2393+
$interior_mut_item:meta,
23912394
$s_int_type:literal,
23922395
$extra_feature:expr,
23932396
$min_fn:ident, $max_fn:ident,
@@ -2425,6 +2428,7 @@ macro_rules! atomic_int {
24252428
/// [module-level documentation]: crate::sync::atomic
24262429
#[$stable]
24272430
#[$diagnostic_item]
2431+
#[$interior_mut_item]
24282432
#[repr(C, align($align))]
24292433
pub struct $atomic_type {
24302434
v: UnsafeCell<$int_type>,
@@ -3447,6 +3451,7 @@ atomic_int! {
34473451
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
34483452
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
34493453
rustc_diagnostic_item = "AtomicI8",
3454+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
34503455
"i8",
34513456
"",
34523457
atomic_min, atomic_max,
@@ -3466,6 +3471,7 @@ atomic_int! {
34663471
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
34673472
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
34683473
rustc_diagnostic_item = "AtomicU8",
3474+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
34693475
"u8",
34703476
"",
34713477
atomic_umin, atomic_umax,
@@ -3485,6 +3491,7 @@ atomic_int! {
34853491
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
34863492
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
34873493
rustc_diagnostic_item = "AtomicI16",
3494+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
34883495
"i16",
34893496
"",
34903497
atomic_min, atomic_max,
@@ -3504,6 +3511,7 @@ atomic_int! {
35043511
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35053512
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35063513
rustc_diagnostic_item = "AtomicU16",
3514+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35073515
"u16",
35083516
"",
35093517
atomic_umin, atomic_umax,
@@ -3523,6 +3531,7 @@ atomic_int! {
35233531
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35243532
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35253533
rustc_diagnostic_item = "AtomicI32",
3534+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35263535
"i32",
35273536
"",
35283537
atomic_min, atomic_max,
@@ -3542,6 +3551,7 @@ atomic_int! {
35423551
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35433552
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35443553
rustc_diagnostic_item = "AtomicU32",
3554+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35453555
"u32",
35463556
"",
35473557
atomic_umin, atomic_umax,
@@ -3561,6 +3571,7 @@ atomic_int! {
35613571
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35623572
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35633573
rustc_diagnostic_item = "AtomicI64",
3574+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35643575
"i64",
35653576
"",
35663577
atomic_min, atomic_max,
@@ -3580,6 +3591,7 @@ atomic_int! {
35803591
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35813592
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35823593
rustc_diagnostic_item = "AtomicU64",
3594+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35833595
"u64",
35843596
"",
35853597
atomic_umin, atomic_umax,
@@ -3599,6 +3611,7 @@ atomic_int! {
35993611
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36003612
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36013613
rustc_diagnostic_item = "AtomicI128",
3614+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36023615
"i128",
36033616
"#![feature(integer_atomics)]\n\n",
36043617
atomic_min, atomic_max,
@@ -3618,6 +3631,7 @@ atomic_int! {
36183631
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36193632
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36203633
rustc_diagnostic_item = "AtomicU128",
3634+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36213635
"u128",
36223636
"#![feature(integer_atomics)]\n\n",
36233637
atomic_umin, atomic_umax,
@@ -3641,6 +3655,7 @@ macro_rules! atomic_int_ptr_sized {
36413655
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
36423656
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36433657
rustc_diagnostic_item = "AtomicIsize",
3658+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36443659
"isize",
36453660
"",
36463661
atomic_min, atomic_max,
@@ -3660,6 +3675,7 @@ macro_rules! atomic_int_ptr_sized {
36603675
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
36613676
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36623677
rustc_diagnostic_item = "AtomicUsize",
3678+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36633679
"usize",
36643680
"",
36653681
atomic_umin, atomic_umax,

library/std/src/sync/barrier.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::sync::{Condvar, Mutex};
2626
/// });
2727
/// ```
2828
#[stable(feature = "rust1", since = "1.0.0")]
29+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
2930
pub struct Barrier {
3031
lock: Mutex<BarrierState>,
3132
cvar: Condvar,

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
// FIXME(nonpoison_once): if possible, switch to nonpoison version once it is available
6768
once: Once,

library/std/src/sync/once_lock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ use crate::sync::Once;
103103
///
104104
/// ```
105105
#[stable(feature = "once_cell", since = "1.70.0")]
106+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
106107
pub struct OnceLock<T> {
107108
// FIXME(nonpoison_once): switch to nonpoison version once it is available
108109
once: Once,

library/std/src/sync/poison/condvar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl WaitTimeoutResult {
106106
/// }
107107
/// ```
108108
#[stable(feature = "rust1", since = "1.0.0")]
109+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
109110
pub struct Condvar {
110111
inner: sys::Condvar,
111112
}

library/std/src/sync/poison/mutex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ use crate::sys::sync as sys;
172172
///
173173
#[stable(feature = "rust1", since = "1.0.0")]
174174
#[cfg_attr(not(test), rustc_diagnostic_item = "Mutex")]
175+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
175176
pub struct Mutex<T: ?Sized> {
176177
inner: sys::Mutex,
177178
poison: poison::Flag,

library/std/src/sync/poison/once.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::sys::sync as sys;
3232
/// [`OnceLock<T>`]: crate::sync::OnceLock
3333
/// [`LazyLock<T, F>`]: crate::sync::LazyLock
3434
#[stable(feature = "rust1", since = "1.0.0")]
35+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
3536
pub struct Once {
3637
inner: sys::Once,
3738
}

0 commit comments

Comments
 (0)