rust/tests/ui/static/reference-to-mut-static-safe.rs
Obei Sideg 408eeae59d Improve wording of static_mut_ref
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-18 06:01:40 +03:00

14 lines
428 B
Rust

//@ revisions: e2021 e2024
//@ [e2021] edition:2021
//@ [e2024] compile-flags: --edition 2024 -Z unstable-options
fn main() {
static mut X: i32 = 1;
let _x = &X;
//[e2024]~^ creating a shared reference to a mutable static [E0796]
//[e2021]~^^ use of mutable static is unsafe and requires unsafe function or block [E0133]
//[e2021]~^^^ shared reference to mutable static is discouraged [static_mut_refs]
}