Skip to content

Commit

Permalink
Rename static_mut_ref to static_mut_refs
Browse files Browse the repository at this point in the history
  • Loading branch information
obeis committed Feb 14, 2024
1 parent c15b018 commit b588372
Show file tree
Hide file tree
Showing 56 changed files with 85 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ fn start<T: Termination + 'static>(

static mut NUM: u8 = 6 * 7;

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

unsafe fn zeroed<T>() -> T {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ fn start<T: Termination + 'static>(

static mut NUM: u8 = 6 * 7;

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

macro_rules! assert {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ hir_analysis_static_mut_ref = reference to mutable static is disallowed
.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
.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
hir_analysis_static_mut_ref_lint = {$shared}reference to mutable static is discouraged
hir_analysis_static_mut_refs_lint = {$shared}reference to mutable static is discouraged
.label = shared reference of mutable static
.label_mut = mutable reference of mutable static
.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
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/errs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_hir as hir;
use rustc_hir_pretty::qpath_to_string;
use rustc_lint_defs::builtin::STATIC_MUT_REF;
use rustc_lint_defs::builtin::STATIC_MUT_REFS;
use rustc_middle::ty::TyCtxt;
use rustc_span::Span;
use rustc_type_ir::Mutability;
Expand Down Expand Up @@ -89,7 +89,7 @@ fn handle_static_mut_ref(
)
};
tcx.emit_node_span_lint(
STATIC_MUT_REF,
STATIC_MUT_REFS,
hir_id,
span,
errors::RefOfMutStatic { shared, why_note: (), why_note_mut: (), label, sugg },
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ pub enum StaticMutRefSugg {

// STATIC_MUT_REF lint
#[derive(LintDiagnostic)]
#[diag(hir_analysis_static_mut_ref_lint)]
#[diag(hir_analysis_static_mut_refs_lint)]
#[note]
pub struct RefOfMutStatic<'a> {
pub shared: &'a str,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ fn register_builtins(store: &mut LintStore) {
store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
store.register_renamed("non_fmt_panic", "non_fmt_panics");
store.register_renamed("unused_tuple_struct_fields", "dead_code");
store.register_renamed("static_mut_ref", "static_mut_refs");

// These were moved to tool lints, but rustc still sees them when compiling normally, before
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ declare_lint_pass! {
SINGLE_USE_LIFETIMES,
SOFT_UNSTABLE,
STABLE_FEATURES,
STATIC_MUT_REF,
STATIC_MUT_REFS,
SUSPICIOUS_AUTO_TRAIT_IMPLS,
TEST_UNSTABLE_LINT,
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
Expand Down Expand Up @@ -1769,7 +1769,7 @@ declare_lint! {
}

declare_lint! {
/// The `static_mut_ref` lint checks for shared or mutable references
/// The `static_mut_refs` lint checks for shared or mutable references
/// of mutable static inside `unsafe` blocks and `unsafe` functions.
///
/// ### Example
Expand Down Expand Up @@ -1809,7 +1809,7 @@ declare_lint! {
///
/// This lint is "warn" by default on editions up to 2021, in 2024 there is
/// a hard error instead.
pub STATIC_MUT_REF,
pub STATIC_MUT_REFS,
Warn,
"shared references or mutable references of mutable static is discouraged",
@future_incompatible = FutureIncompatibleInfo {
Expand Down
8 changes: 4 additions & 4 deletions library/panic_unwind/src/seh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ cfg_if::cfg_if! {
}
}

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

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

// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#[allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[allow(static_mut_refs)]
pub unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> {
// A null payload here means that we got here from the catch (...) of
// __rust_try. This happens when a non-Rust foreign exception is caught.
Expand Down
5 changes: 3 additions & 2 deletions library/std/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,9 @@ pub mod panic_count {
#[doc(hidden)]
#[cfg(not(feature = "panic_immediate_abort"))]
#[unstable(feature = "update_panic_count", issue = "none")]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#[allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[cfg_attr(bootstrap, allow(static_mut_ref))]
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
pub mod panic_count {
use crate::cell::Cell;
use crate::sync::atomic::{AtomicUsize, Ordering};
Expand Down
5 changes: 3 additions & 2 deletions library/std/src/sys/pal/common/thread_local/fast_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ pub macro thread_local_inner {
(@key $t:ty, const $init:expr) => {{
#[inline]
#[deny(unsafe_op_in_unsafe_fn)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#[allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[cfg_attr(bootstrap, allow(static_mut_ref))]
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
unsafe fn __getit(
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
) -> $crate::option::Option<&'static $t> {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/pal/common/thread_local/static_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub macro thread_local_inner {
(@key $t:ty, const $init:expr) => {{
#[inline] // see comments below
#[deny(unsafe_op_in_unsafe_fn)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#[allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[allow(static_mut_refs)]
unsafe fn __getit(
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
) -> $crate::option::Option<&'static $t> {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "thread_local_macro")]
#[allow_internal_unstable(thread_local_internals)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#[allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
macro_rules! thread_local {
// empty (base case for the recursion)
() => {};
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/tests/fail/tls/tls_static_dealloc.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Ensure that thread-local statics get deallocated when the thread dies.

#![feature(thread_local)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#![allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#![allow(static_mut_refs)]

#[thread_local]
static mut TLS: u8 = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/tests/pass/static_mut.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
static mut FOO: i32 = 42;

// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#[allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[allow(static_mut_refs)]
static BAR: Foo = Foo(unsafe { &FOO as *const _ });

#[allow(dead_code)]
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/tests/pass/tls/tls_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
//! test, we also check that thread-locals act as per-thread statics.

#![feature(thread_local)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#![allow(static_mut_ref)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#![allow(static_mut_refs)]

use std::thread;

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/abi/statics/static-mut-foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ unsafe fn run() {
rust_dbg_static_mut = -3;
assert_eq!(rust_dbg_static_mut, -3);
static_bound(&rust_dbg_static_mut);
//~^ WARN shared reference to mutable static is discouraged [static_mut_ref]
//~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
static_bound_set(&mut rust_dbg_static_mut);
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
}

pub fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/abi/statics/static-mut-foreign.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | static_bound(&rust_dbg_static_mut);
= note: reference of mutable static is a hard error in 2024 edition
= note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways
= note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways
= note: `#[warn(static_mut_ref)]` on by default
= note: `#[warn(static_mut_refs)]` on by default
help: 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
|
LL | static_bound(addr_of!(rust_dbg_static_mut));
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/borrowck-access-permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
let _y1 = &mut static_x; //~ ERROR [E0596]
unsafe {
let _y2 = &mut static_x_mut;
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/borrowck-access-permissions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | let _y2 = &mut static_x_mut;
= note: reference of mutable static is a hard error in 2024 edition
= note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways
= note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways
= note: `#[warn(static_mut_ref)]` on by default
= note: `#[warn(static_mut_refs)]` on by default
help: 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
|
LL | let _y2 = addr_of_mut!(static_x_mut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Foo {
fn main() {
unsafe {
let sfoo: *mut Foo = &mut SFOO;
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
let x = (*sfoo).x();
(*sfoo).x[1] += 1;
*x += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | let sfoo: *mut Foo = &mut SFOO;
= note: reference of mutable static is a hard error in 2024 edition
= note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways
= note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways
= note: `#[warn(static_mut_ref)]` on by default
= note: `#[warn(static_mut_refs)]` on by default
help: 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
|
LL | let sfoo: *mut Foo = addr_of_mut!(SFOO);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/issue-20801.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn imm_ref() -> &'static T {

fn mut_ref() -> &'static mut T {
unsafe { &mut GLOBAL_MUT_T }
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
}

fn mut_ptr() -> *mut T {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/issue-20801.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | unsafe { &mut GLOBAL_MUT_T }
= note: reference of mutable static is a hard error in 2024 edition
= note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways
= note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways
= note: `#[warn(static_mut_ref)]` on by default
= note: `#[warn(static_mut_refs)]` on by default
help: 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
|
LL | unsafe { addr_of_mut!(GLOBAL_MUT_T) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod borrowck_closures_unique {
//~^ ERROR is not declared as mutable
unsafe {
c1(&mut Y);
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
}
}
}
Expand All @@ -25,7 +25,7 @@ mod borrowck_closures_unique_grandparent {
};
unsafe {
c1(&mut Z);
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
}
}
}
Expand Down Expand Up @@ -62,7 +62,7 @@ fn main() {
static mut X: isize = 2;
unsafe {
borrowck_closures_unique::e(&mut X);
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
}

mutability_errors::capture_assign_whole((1000,));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | c1(&mut Y);
= note: reference of mutable static is a hard error in 2024 edition
= note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways
= note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways
= note: `#[warn(static_mut_ref)]` on by default
= note: `#[warn(static_mut_refs)]` on by default
help: 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
|
LL | c1(addr_of_mut!(Y));
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const_let_assign2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static mut BB: AA = AA::new();

fn main() {
let ptr = unsafe { &mut BB };
//~^ WARN mutable reference to mutable static is discouraged [static_mut_ref]
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
for a in ptr.data.iter() {
println!("{}", a);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const_let_assign2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | let ptr = unsafe { &mut BB };
= note: reference of mutable static is a hard error in 2024 edition
= note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways
= note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways
= note: `#[warn(static_mut_ref)]` on by default
= note: `#[warn(static_mut_refs)]` on by default
help: 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
|
LL | let ptr = unsafe { addr_of_mut!(BB) };
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const_refs_to_static_fail_invalid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
#![feature(const_refs_to_static)]
#![allow(static_mut_ref)]
#![allow(static_mut_refs)]

fn invalid() {
static S: i8 = 10;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/issue-17718-const-bad-values.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(static_mut_ref)]
#![allow(static_mut_refs)]

const C1: &'static mut [usize] = &mut [];
//~^ ERROR: mutable references are not allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// aux-build:static_cross_crate.rs
// stderr-per-bitwidth
#![feature(exclusive_range_pattern, half_open_range_patterns_in_slices)]
#![allow(static_mut_ref)]
#![allow(static_mut_refs)]

extern crate static_cross_crate;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/miri_unleashed/extern-static.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(thread_local)]
#![allow(static_mut_ref)]
#![allow(static_mut_refs)]

extern "C" {
static mut DATA: u8;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/miri_unleashed/mutable_references_err.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// stderr-per-bitwidth
// compile-flags: -Zunleash-the-miri-inside-of-you
#![allow(invalid_reference_casting, static_mut_ref)]
#![allow(invalid_reference_casting, static_mut_refs)]

use std::sync::atomic::*;
use std::cell::UnsafeCell;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/static-promoted-to-mutable-static.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// check-pass
#![allow(non_camel_case_types, non_upper_case_globals, static_mut_ref)]
#![allow(non_camel_case_types, non_upper_case_globals, static_mut_refs)]

pub struct wl_interface {
pub version: i32
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/static_mut_containing_mut_ref.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// build-pass (FIXME(62277): could be check-pass?)
#![allow(static_mut_ref)]
#![allow(static_mut_refs)]

static mut STDERR_BUFFER_SPACE: [u8; 42] = [0u8; 42];

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/static_mut_containing_mut_ref2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// revisions: stock mut_refs
#![allow(static_mut_ref)]
#![allow(static_mut_refs)]
#![cfg_attr(mut_refs, feature(const_mut_refs))]

static mut STDERR_BUFFER_SPACE: u8 = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/drop/issue-23338-ensure-param-drop-order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub mod d {
pub fn max_width() -> u32 {
unsafe {
(mem::size_of_val(&trails) * 8) as u32
//~^ WARN shared reference to mutable static is discouraged [static_mut_ref]
//~^ WARN shared reference to mutable static is discouraged [static_mut_refs]
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/drop/issue-23338-ensure-param-drop-order.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | (mem::size_of_val(&trails) * 8) as u32
= note: reference of mutable static is a hard error in 2024 edition
= note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways
= note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways
= note: `#[warn(static_mut_ref)]` on by default
= note: `#[warn(static_mut_refs)]` on by default
help: 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
|
LL | (mem::size_of_val(addr_of!(trails)) * 8) as u32
Expand Down
Loading

0 comments on commit b588372

Please sign in to comment.