Skip to content

Commit a8aa687

Browse files
committed
Update test for E0796 and static_mut_ref lint
1 parent 18edf9a commit a8aa687

File tree

54 files changed

+805
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+805
-237
lines changed

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ fn start<T: Termination + 'static>(
111111
}
112112

113113
static mut NUM: u8 = 6 * 7;
114+
115+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
116+
#[allow(static_mut_ref)]
114117
static NUM_REF: &'static u8 = unsafe { &NUM };
115118

116119
unsafe fn zeroed<T>() -> T {

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ fn start<T: Termination + 'static>(
9898
}
9999

100100
static mut NUM: u8 = 6 * 7;
101+
102+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
103+
#[allow(static_mut_ref)]
101104
static NUM_REF: &'static u8 = unsafe { &NUM };
102105

103106
macro_rules! assert {

library/panic_unwind/src/seh.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ cfg_if::cfg_if! {
261261
}
262262
}
263263

264+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
265+
#[cfg_attr(not(bootstrap), allow(static_mut_ref))]
264266
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
265267
use core::intrinsics::atomic_store_seqcst;
266268

@@ -322,6 +324,8 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
322324
_CxxThrowException(throw_ptr, &mut THROW_INFO as *mut _ as *mut _);
323325
}
324326

327+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
328+
#[cfg_attr(not(bootstrap), allow(static_mut_ref))]
325329
pub unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> {
326330
// A null payload here means that we got here from the catch (...) of
327331
// __rust_try. This happens when a non-Rust foreign exception is caught.

library/std/src/panicking.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ pub mod panic_count {
337337
#[doc(hidden)]
338338
#[cfg(not(feature = "panic_immediate_abort"))]
339339
#[unstable(feature = "update_panic_count", issue = "none")]
340+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
341+
#[cfg_attr(not(bootstrap), allow(static_mut_ref))]
340342
pub mod panic_count {
341343
use crate::cell::Cell;
342344
use crate::sync::atomic::{AtomicUsize, Ordering};

library/std/src/sys/common/thread_local/fast_local.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub macro thread_local_inner {
1313
(@key $t:ty, const $init:expr) => {{
1414
#[inline]
1515
#[deny(unsafe_op_in_unsafe_fn)]
16+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
17+
#[cfg_attr(not(bootstrap), allow(static_mut_ref))]
1618
unsafe fn __getit(
1719
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
1820
) -> $crate::option::Option<&'static $t> {

library/std/src/sys/common/thread_local/static_local.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub macro thread_local_inner {
1111
(@key $t:ty, const $init:expr) => {{
1212
#[inline] // see comments below
1313
#[deny(unsafe_op_in_unsafe_fn)]
14+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
15+
#[cfg_attr(not(bootstrap), allow(static_mut_ref))]
1416
unsafe fn __getit(
1517
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
1618
) -> $crate::option::Option<&'static $t> {

library/std/src/thread/local.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
180180
#[stable(feature = "rust1", since = "1.0.0")]
181181
#[cfg_attr(not(test), rustc_diagnostic_item = "thread_local_macro")]
182182
#[allow_internal_unstable(thread_local_internals)]
183+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
184+
#[cfg_attr(not(bootstrap), allow(static_mut_ref))]
183185
macro_rules! thread_local {
184186
// empty (base case for the recursion)
185187
() => {};

src/tools/lint-docs/src/groups.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static GROUP_DESCRIPTIONS: &[(&str, &str)] = &[
1515
("future-incompatible", "Lints that detect code that has future-compatibility problems"),
1616
("rust-2018-compatibility", "Lints used to transition code from the 2015 edition to 2018"),
1717
("rust-2021-compatibility", "Lints used to transition code from the 2018 edition to 2021"),
18+
("rust-2024-compatibility", "Lints used to transition code from the 2021 edition to 2024"),
1819
];
1920

2021
type LintGroups = BTreeMap<String, BTreeSet<String>>;

src/tools/miri/tests/fail/tls/tls_static_dealloc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Ensure that thread-local statics get deallocated when the thread dies.
22
33
#![feature(thread_local)]
4+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
5+
#![allow(static_mut_ref)]
46

57
#[thread_local]
68
static mut TLS: u8 = 0;

src/tools/miri/tests/pass/static_mut.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
static mut FOO: i32 = 42;
2+
3+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
4+
#[allow(static_mut_ref)]
25
static BAR: Foo = Foo(unsafe { &FOO as *const _ });
36

47
#[allow(dead_code)]

0 commit comments

Comments
 (0)