|
| 1 | +warning: shared reference of mutable static is discouraged |
| 2 | + --> $DIR/static-mut-foreign.rs:35:18 |
| 3 | + | |
| 4 | +LL | static_bound(&rust_dbg_static_mut); |
| 5 | + | ^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static |
| 6 | + | |
| 7 | + = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> |
| 8 | + = note: reference of mutable static is a hard error from 2024 edition |
| 9 | + = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior |
| 10 | + = note: `#[warn(static_mut_ref)]` on by default |
| 11 | +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 |
| 12 | + | |
| 13 | +LL | static_bound(addr_of!(rust_dbg_static_mut)); |
| 14 | + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 15 | + |
| 16 | +warning: mutable reference of mutable static is discouraged |
| 17 | + --> $DIR/static-mut-foreign.rs:37:22 |
| 18 | + | |
| 19 | +LL | static_bound_set(&mut rust_dbg_static_mut); |
| 20 | + | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static |
| 21 | + | |
| 22 | + = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> |
| 23 | + = note: reference of mutable static is a hard error from 2024 edition |
| 24 | + = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior |
| 25 | +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 |
| 26 | + | |
| 27 | +LL | static_bound_set(addr_of_mut!(rust_dbg_static_mut)); |
| 28 | + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 29 | + |
| 30 | +warning: 2 warnings emitted |
| 31 | + |
0 commit comments