Skip to content

Commit 0fa0c08

Browse files
committed
Add #[rustc_significant_interior_mutable_type] to core and std types
1 parent 697df8f commit 0fa0c08

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
#[cfg_attr(not(test), 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
@@ -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)))]
@@ -2387,6 +2389,7 @@ macro_rules! atomic_int {
23872389
$const_stable_new:meta,
23882390
$const_stable_into_inner:meta,
23892391
$diagnostic_item:meta,
2392+
$interior_mut_item:meta,
23902393
$s_int_type:literal,
23912394
$extra_feature:expr,
23922395
$min_fn:ident, $max_fn:ident,
@@ -2424,6 +2427,7 @@ macro_rules! atomic_int {
24242427
/// [module-level documentation]: crate::sync::atomic
24252428
#[$stable]
24262429
#[$diagnostic_item]
2430+
#[$interior_mut_item]
24272431
#[repr(C, align($align))]
24282432
pub struct $atomic_type {
24292433
v: UnsafeCell<$int_type>,
@@ -3446,6 +3450,7 @@ atomic_int! {
34463450
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
34473451
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
34483452
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI8"),
3453+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
34493454
"i8",
34503455
"",
34513456
atomic_min, atomic_max,
@@ -3465,6 +3470,7 @@ atomic_int! {
34653470
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
34663471
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
34673472
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU8"),
3473+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
34683474
"u8",
34693475
"",
34703476
atomic_umin, atomic_umax,
@@ -3484,6 +3490,7 @@ atomic_int! {
34843490
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
34853491
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
34863492
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI16"),
3493+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
34873494
"i16",
34883495
"",
34893496
atomic_min, atomic_max,
@@ -3503,6 +3510,7 @@ atomic_int! {
35033510
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35043511
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35053512
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU16"),
3513+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35063514
"u16",
35073515
"",
35083516
atomic_umin, atomic_umax,
@@ -3522,6 +3530,7 @@ atomic_int! {
35223530
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35233531
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35243532
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI32"),
3533+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35253534
"i32",
35263535
"",
35273536
atomic_min, atomic_max,
@@ -3541,6 +3550,7 @@ atomic_int! {
35413550
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35423551
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35433552
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU32"),
3553+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35443554
"u32",
35453555
"",
35463556
atomic_umin, atomic_umax,
@@ -3560,6 +3570,7 @@ atomic_int! {
35603570
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35613571
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35623572
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI64"),
3573+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35633574
"i64",
35643575
"",
35653576
atomic_min, atomic_max,
@@ -3579,6 +3590,7 @@ atomic_int! {
35793590
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35803591
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35813592
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU64"),
3593+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35823594
"u64",
35833595
"",
35843596
atomic_umin, atomic_umax,
@@ -3598,6 +3610,7 @@ atomic_int! {
35983610
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
35993611
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36003612
cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"),
3613+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36013614
"i128",
36023615
"#![feature(integer_atomics)]\n\n",
36033616
atomic_min, atomic_max,
@@ -3617,6 +3630,7 @@ atomic_int! {
36173630
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36183631
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36193632
cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"),
3633+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36203634
"u128",
36213635
"#![feature(integer_atomics)]\n\n",
36223636
atomic_umin, atomic_umax,
@@ -3640,6 +3654,7 @@ macro_rules! atomic_int_ptr_sized {
36403654
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
36413655
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36423656
cfg_attr(not(test), rustc_diagnostic_item = "AtomicIsize"),
3657+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36433658
"isize",
36443659
"",
36453660
atomic_min, atomic_max,
@@ -3659,6 +3674,7 @@ macro_rules! atomic_int_ptr_sized {
36593674
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
36603675
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36613676
cfg_attr(not(test), rustc_diagnostic_item = "AtomicUsize"),
3677+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36623678
"usize",
36633679
"",
36643680
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
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ use crate::sys::sync as sys;
7777
/// [`Mutex`]: super::Mutex
7878
#[stable(feature = "rust1", since = "1.0.0")]
7979
#[cfg_attr(not(test), rustc_diagnostic_item = "RwLock")]
80+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
8081
pub struct RwLock<T: ?Sized> {
8182
inner: sys::RwLock,
8283
poison: poison::Flag,

library/std/src/sync/reentrant_lock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ use crate::thread::{ThreadId, current_id};
8080
// we don't need to further synchronize the TID accesses, so they can be regular 64-bit
8181
// non-atomic accesses.
8282
#[unstable(feature = "reentrant_lock", issue = "121440")]
83+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
8384
pub struct ReentrantLock<T: ?Sized> {
8485
mutex: sys::Mutex,
8586
owner: Tid,

0 commit comments

Comments
 (0)