Disallow reference to static mut
for expressions
Add `E0796` error code. Add `static_mut_ref` lint. This is the idea for the 2024 edition.
This commit is contained in:
parent
595bc6f003
commit
2c088f9520
9 changed files with 261 additions and 0 deletions
|
@ -346,6 +346,20 @@ hir_analysis_start_not_target_feature = `#[start]` function is not allowed to ha
|
|||
hir_analysis_start_not_track_caller = `#[start]` function is not allowed to be `#[track_caller]`
|
||||
.label = `#[start]` function is not allowed to be `#[track_caller]`
|
||||
|
||||
hir_analysis_static_mut_ref = reference of mutable static is disallowed
|
||||
.label = reference of mutable static
|
||||
.note = mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
|
||||
.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 of 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
|
||||
.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
|
||||
.note = reference of mutable static is a hard error from 2024 edition
|
||||
.why_note = mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
|
||||
|
||||
hir_analysis_static_specialize = cannot specialize on `'static` lifetime
|
||||
|
||||
hir_analysis_substs_on_overridden_impl = could not resolve substs on overridden impl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue