mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
27 lines
1.2 KiB
Plaintext
27 lines
1.2 KiB
Plaintext
warning: shared reference of mutable static is discouraged
|
|
--> $DIR/reference-of-mut-static-safe.rs:9:14
|
|
|
|
|
LL | let _x = &X;
|
|
| ^^ shared reference of mutable static
|
|
|
|
|
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
|
= note: reference of mutable static is a hard error from 2024 edition
|
|
= note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
|
|
= note: `#[warn(static_mut_ref)]` 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 | let _x = addr_of!(X);
|
|
| ~~~~~~~~~~~
|
|
|
|
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
|
|
--> $DIR/reference-of-mut-static-safe.rs:9:15
|
|
|
|
|
LL | let _x = &X;
|
|
| ^ use of mutable static
|
|
|
|
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
|
|
|
|
error: aborting due to 1 previous error; 1 warning emitted
|
|
|
|
For more information about this error, try `rustc --explain E0133`.
|