Skip to content

Commit

Permalink
Allow interior_mutable_consts lint in std for INIT const
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Oct 25, 2024
1 parent da4de38 commit b1bc607
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ pub enum Ordering {
note = "the `new` function is now preferred",
suggestion = "AtomicBool::new(false)"
)]
#[cfg_attr(not(bootstrap), expect(interior_mutable_consts))]
pub const ATOMIC_BOOL_INIT: AtomicBool = AtomicBool::new(false);

#[cfg(target_has_atomic_load_store = "8")]
Expand Down Expand Up @@ -3288,6 +3289,7 @@ macro_rules! atomic_int_ptr_sized {
note = "the `new` function is now preferred",
suggestion = "AtomicIsize::new(0)",
)]
#[cfg_attr(not(bootstrap), expect(interior_mutable_consts))]
pub const ATOMIC_ISIZE_INIT: AtomicIsize = AtomicIsize::new(0);

/// An [`AtomicUsize`] initialized to `0`.
Expand All @@ -3298,6 +3300,7 @@ macro_rules! atomic_int_ptr_sized {
note = "the `new` function is now preferred",
suggestion = "AtomicUsize::new(0)",
)]
#[cfg_attr(not(bootstrap), expect(interior_mutable_consts))]
pub const ATOMIC_USIZE_INIT: AtomicUsize = AtomicUsize::new(0);
)* };
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sync/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub(crate) enum ExclusiveState {
note = "the `Once::new()` function is now preferred",
suggestion = "Once::new()"
)]
#[cfg_attr(not(bootstrap), expect(interior_mutable_consts))]
pub const ONCE_INIT: Once = Once::new();

impl Once {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/thread_local/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub macro thread_local_inner {

// Used to generate the `LocalKey` value for const-initialized thread locals.
(@key $t:ty, const $init:expr) => {{
#[cfg_attr(not(bootstrap), expect(interior_mutable_consts))]
const __INIT: $t = $init;

unsafe {
Expand Down

0 comments on commit b1bc607

Please sign in to comment.