mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
65 lines
2.9 KiB
Plaintext
65 lines
2.9 KiB
Plaintext
warning: shared reference of mutable static is discouraged
|
|
--> $DIR/safe-extern-statics-mut.rs:12:14
|
|
|
|
|
LL | let rb = &B;
|
|
| ^^ 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 rb = addr_of!(B);
|
|
| ~~~~~~~~~~~
|
|
|
|
warning: shared reference of mutable static is discouraged
|
|
--> $DIR/safe-extern-statics-mut.rs:15:15
|
|
|
|
|
LL | let xrb = &XB;
|
|
| ^^^ 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
|
|
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 xrb = addr_of!(XB);
|
|
| ~~~~~~~~~~~~
|
|
|
|
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
|
|
--> $DIR/safe-extern-statics-mut.rs:11:13
|
|
|
|
|
LL | let b = B;
|
|
| ^ use of mutable static
|
|
|
|
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
|
|
|
|
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
|
|
--> $DIR/safe-extern-statics-mut.rs:12:15
|
|
|
|
|
LL | let rb = &B;
|
|
| ^ use of mutable static
|
|
|
|
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
|
|
|
|
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
|
|
--> $DIR/safe-extern-statics-mut.rs:14:14
|
|
|
|
|
LL | let xb = XB;
|
|
| ^^ use of mutable static
|
|
|
|
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
|
|
|
|
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
|
|
--> $DIR/safe-extern-statics-mut.rs:15:16
|
|
|
|
|
LL | let xrb = &XB;
|
|
| ^^ 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 4 previous errors; 2 warnings emitted
|
|
|
|
For more information about this error, try `rustc --explain E0133`.
|