Skip to content

Commit 7ab3d96

Browse files
committed
Add #[rustc_significant_interior_mutable_type] to core and std types
1 parent 642449a commit 7ab3d96

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
}
@@ -718,6 +719,7 @@ impl<T, const N: usize> Cell<[T; N]> {
718719
/// See the [module-level documentation](self) for more.
719720
#[rustc_diagnostic_item = "RefCell"]
720721
#[stable(feature = "rust1", since = "1.0.0")]
722+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
721723
pub struct RefCell<T: ?Sized> {
722724
borrow: Cell<BorrowFlag>,
723725
// Stores the location of the earliest currently active borrow.
@@ -2067,6 +2069,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
20672069
#[stable(feature = "rust1", since = "1.0.0")]
20682070
#[repr(transparent)]
20692071
#[rustc_pub_transparent]
2072+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
20702073
pub struct UnsafeCell<T: ?Sized> {
20712074
value: T,
20722075
}

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
@@ -361,6 +361,7 @@ const EMULATE_ATOMIC_BOOL: bool =
361361
#[cfg(target_has_atomic_load_store = "8")]
362362
#[stable(feature = "rust1", since = "1.0.0")]
363363
#[rustc_diagnostic_item = "AtomicBool"]
364+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
364365
#[repr(C, align(1))]
365366
pub struct AtomicBool {
366367
v: UnsafeCell<u8>,
@@ -390,6 +391,7 @@ unsafe impl Sync for AtomicBool {}
390391
#[cfg(target_has_atomic_load_store = "ptr")]
391392
#[stable(feature = "rust1", since = "1.0.0")]
392393
#[rustc_diagnostic_item = "AtomicPtr"]
394+
#[cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type)]
393395
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
394396
#[cfg_attr(target_pointer_width = "32", repr(C, align(4)))]
395397
#[cfg_attr(target_pointer_width = "64", repr(C, align(8)))]
@@ -2484,6 +2486,7 @@ macro_rules! atomic_int {
24842486
$const_stable_new:meta,
24852487
$const_stable_into_inner:meta,
24862488
$diagnostic_item:meta,
2489+
$interior_mut_item:meta,
24872490
$s_int_type:literal,
24882491
$extra_feature:expr,
24892492
$min_fn:ident, $max_fn:ident,
@@ -2521,6 +2524,7 @@ macro_rules! atomic_int {
25212524
/// [module-level documentation]: crate::sync::atomic
25222525
#[$stable]
25232526
#[$diagnostic_item]
2527+
#[$interior_mut_item]
25242528
#[repr(C, align($align))]
25252529
pub struct $atomic_type {
25262530
v: UnsafeCell<$int_type>,
@@ -3544,6 +3548,7 @@ atomic_int! {
35443548
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35453549
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35463550
rustc_diagnostic_item = "AtomicI8",
3551+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35473552
"i8",
35483553
"",
35493554
atomic_min, atomic_max,
@@ -3563,6 +3568,7 @@ atomic_int! {
35633568
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35643569
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35653570
rustc_diagnostic_item = "AtomicU8",
3571+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35663572
"u8",
35673573
"",
35683574
atomic_umin, atomic_umax,
@@ -3582,6 +3588,7 @@ atomic_int! {
35823588
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
35833589
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
35843590
rustc_diagnostic_item = "AtomicI16",
3591+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
35853592
"i16",
35863593
"",
35873594
atomic_min, atomic_max,
@@ -3601,6 +3608,7 @@ atomic_int! {
36013608
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
36023609
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36033610
rustc_diagnostic_item = "AtomicU16",
3611+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36043612
"u16",
36053613
"",
36063614
atomic_umin, atomic_umax,
@@ -3620,6 +3628,7 @@ atomic_int! {
36203628
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
36213629
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36223630
rustc_diagnostic_item = "AtomicI32",
3631+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36233632
"i32",
36243633
"",
36253634
atomic_min, atomic_max,
@@ -3639,6 +3648,7 @@ atomic_int! {
36393648
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
36403649
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36413650
rustc_diagnostic_item = "AtomicU32",
3651+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36423652
"u32",
36433653
"",
36443654
atomic_umin, atomic_umax,
@@ -3658,6 +3668,7 @@ atomic_int! {
36583668
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
36593669
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36603670
rustc_diagnostic_item = "AtomicI64",
3671+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36613672
"i64",
36623673
"",
36633674
atomic_min, atomic_max,
@@ -3677,6 +3688,7 @@ atomic_int! {
36773688
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
36783689
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
36793690
rustc_diagnostic_item = "AtomicU64",
3691+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36803692
"u64",
36813693
"",
36823694
atomic_umin, atomic_umax,
@@ -3696,6 +3708,7 @@ atomic_int! {
36963708
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36973709
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
36983710
rustc_diagnostic_item = "AtomicI128",
3711+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
36993712
"i128",
37003713
"#![feature(integer_atomics)]\n\n",
37013714
atomic_min, atomic_max,
@@ -3715,6 +3728,7 @@ atomic_int! {
37153728
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
37163729
rustc_const_unstable(feature = "integer_atomics", issue = "99069"),
37173730
rustc_diagnostic_item = "AtomicU128",
3731+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
37183732
"u128",
37193733
"#![feature(integer_atomics)]\n\n",
37203734
atomic_umin, atomic_umax,
@@ -3738,6 +3752,7 @@ macro_rules! atomic_int_ptr_sized {
37383752
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
37393753
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
37403754
rustc_diagnostic_item = "AtomicIsize",
3755+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
37413756
"isize",
37423757
"",
37433758
atomic_min, atomic_max,
@@ -3757,6 +3772,7 @@ macro_rules! atomic_int_ptr_sized {
37573772
rustc_const_stable(feature = "const_ptr_sized_atomics", since = "1.24.0"),
37583773
rustc_const_stable(feature = "const_atomic_into_inner", since = "1.79.0"),
37593774
rustc_diagnostic_item = "AtomicUsize",
3775+
cfg_attr(not(bootstrap), rustc_significant_interior_mutable_type),
37603776
"usize",
37613777
"",
37623778
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)