rust/tests/ui/statics/static-mut-xc.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.7 KiB
Plaintext
Raw Normal View History

warning: shared reference of mutable static is discouraged
--> $DIR/static-mut-xc.rs:28:18
|
LL | static_bound(&static_mut_xc::a);
| ^^^^^^^^^^^^^^^^^ 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 | static_bound(addr_of!(static_mut_xc::a));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: mutable reference of mutable static is discouraged
--> $DIR/static-mut-xc.rs:30:22
|
LL | static_bound_set(&mut static_mut_xc::a);
| ^^^^^^^^^^^^^^^^^^^^^ mutable 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: 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 | static_bound_set(addr_of_mut!(static_mut_xc::a));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: 2 warnings emitted