Skip to content

Commit b588372

Browse files
committed
Rename static_mut_ref to static_mut_refs
1 parent c15b018 commit b588372

File tree

56 files changed

+85
-82
lines changed

Some content is hidden

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

56 files changed

+85
-82
lines changed

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ fn start<T: Termination + 'static>(
112112

113113
static mut NUM: u8 = 6 * 7;
114114

115-
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
116-
#[allow(static_mut_ref)]
115+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
116+
#[allow(static_mut_refs)]
117117
static NUM_REF: &'static u8 = unsafe { &NUM };
118118

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

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ fn start<T: Termination + 'static>(
9999

100100
static mut NUM: u8 = 6 * 7;
101101

102-
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
103-
#[allow(static_mut_ref)]
102+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
103+
#[allow(static_mut_refs)]
104104
static NUM_REF: &'static u8 = unsafe { &NUM };
105105

106106
macro_rules! assert {

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ hir_analysis_static_mut_ref = reference to mutable static is disallowed
380380
.suggestion = shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer
381381
.suggestion_mut = mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer
382382
383-
hir_analysis_static_mut_ref_lint = {$shared}reference to mutable static is discouraged
383+
hir_analysis_static_mut_refs_lint = {$shared}reference to mutable static is discouraged
384384
.label = shared reference of mutable static
385385
.label_mut = mutable reference of mutable static
386386
.suggestion = shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer

compiler/rustc_hir_analysis/src/check/errs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_hir as hir;
22
use rustc_hir_pretty::qpath_to_string;
3-
use rustc_lint_defs::builtin::STATIC_MUT_REF;
3+
use rustc_lint_defs::builtin::STATIC_MUT_REFS;
44
use rustc_middle::ty::TyCtxt;
55
use rustc_span::Span;
66
use rustc_type_ir::Mutability;
@@ -89,7 +89,7 @@ fn handle_static_mut_ref(
8989
)
9090
};
9191
tcx.emit_node_span_lint(
92-
STATIC_MUT_REF,
92+
STATIC_MUT_REFS,
9393
hir_id,
9494
span,
9595
errors::RefOfMutStatic { shared, why_note: (), why_note_mut: (), label, sugg },

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ pub enum StaticMutRefSugg {
14931493

14941494
// STATIC_MUT_REF lint
14951495
#[derive(LintDiagnostic)]
1496-
#[diag(hir_analysis_static_mut_ref_lint)]
1496+
#[diag(hir_analysis_static_mut_refs_lint)]
14971497
#[note]
14981498
pub struct RefOfMutStatic<'a> {
14991499
pub shared: &'a str,

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ fn register_builtins(store: &mut LintStore) {
324324
store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
325325
store.register_renamed("non_fmt_panic", "non_fmt_panics");
326326
store.register_renamed("unused_tuple_struct_fields", "dead_code");
327+
store.register_renamed("static_mut_ref", "static_mut_refs");
327328

328329
// These were moved to tool lints, but rustc still sees them when compiling normally, before
329330
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ declare_lint_pass! {
8989
SINGLE_USE_LIFETIMES,
9090
SOFT_UNSTABLE,
9191
STABLE_FEATURES,
92-
STATIC_MUT_REF,
92+
STATIC_MUT_REFS,
9393
SUSPICIOUS_AUTO_TRAIT_IMPLS,
9494
TEST_UNSTABLE_LINT,
9595
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
@@ -1769,7 +1769,7 @@ declare_lint! {
17691769
}
17701770

17711771
declare_lint! {
1772-
/// The `static_mut_ref` lint checks for shared or mutable references
1772+
/// The `static_mut_refs` lint checks for shared or mutable references
17731773
/// of mutable static inside `unsafe` blocks and `unsafe` functions.
17741774
///
17751775
/// ### Example
@@ -1809,7 +1809,7 @@ declare_lint! {
18091809
///
18101810
/// This lint is "warn" by default on editions up to 2021, in 2024 there is
18111811
/// a hard error instead.
1812-
pub STATIC_MUT_REF,
1812+
pub STATIC_MUT_REFS,
18131813
Warn,
18141814
"shared references or mutable references of mutable static is discouraged",
18151815
@future_incompatible = FutureIncompatibleInfo {

library/panic_unwind/src/seh.rs

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

264-
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
265-
#[allow(static_mut_ref)]
264+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
265+
#[allow(static_mut_refs)]
266266
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
267267
use core::intrinsics::atomic_store_seqcst;
268268

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

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

library/std/src/panicking.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ 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-
#[allow(static_mut_ref)]
340+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
341+
#[cfg_attr(bootstrap, allow(static_mut_ref))]
342+
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
342343
pub mod panic_count {
343344
use crate::cell::Cell;
344345
use crate::sync::atomic::{AtomicUsize, Ordering};

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ 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-
#[allow(static_mut_ref)]
16+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
17+
#[cfg_attr(bootstrap, allow(static_mut_ref))]
18+
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
1819
unsafe fn __getit(
1920
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
2021
) -> $crate::option::Option<&'static $t> {

0 commit comments

Comments
 (0)