|
| 1 | +error: shared reference of mutable static is discouraged |
| 2 | + --> $DIR/reference-of-mut-static.rs:16:18 |
| 3 | + | |
| 4 | +LL | let _y = &X; |
| 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: the lint level is defined here |
| 11 | + --> $DIR/reference-of-mut-static.rs:6:9 |
| 12 | + | |
| 13 | +LL | #![deny(static_mut_ref)] |
| 14 | + | ^^^^^^^^^^^^^^ |
| 15 | +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 |
| 16 | + | |
| 17 | +LL | let _y = addr_of!(X); |
| 18 | + | ~~~~~~~~~~~ |
| 19 | + |
| 20 | +error: mutable reference of mutable static is discouraged |
| 21 | + --> $DIR/reference-of-mut-static.rs:20:18 |
| 22 | + | |
| 23 | +LL | let _y = &mut X; |
| 24 | + | ^^^^^^ mutable reference of mutable static |
| 25 | + | |
| 26 | + = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> |
| 27 | + = note: reference of mutable static is a hard error from 2024 edition |
| 28 | + = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior |
| 29 | +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 |
| 30 | + | |
| 31 | +LL | let _y = addr_of_mut!(X); |
| 32 | + | ~~~~~~~~~~~~~~~ |
| 33 | + |
| 34 | +error: shared reference of mutable static is discouraged |
| 35 | + --> $DIR/reference-of-mut-static.rs:28:22 |
| 36 | + | |
| 37 | +LL | let ref _a = X; |
| 38 | + | ^ shared reference of mutable static |
| 39 | + | |
| 40 | + = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> |
| 41 | + = note: reference of mutable static is a hard error from 2024 edition |
| 42 | + = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior |
| 43 | +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 |
| 44 | + | |
| 45 | +LL | let ref _a = addr_of!(X); |
| 46 | + | ~~~~~~~~~~~ |
| 47 | + |
| 48 | +error: shared reference of mutable static is discouraged |
| 49 | + --> $DIR/reference-of-mut-static.rs:32:25 |
| 50 | + | |
| 51 | +LL | let (_b, _c) = (&X, &Y); |
| 52 | + | ^^ shared reference of mutable static |
| 53 | + | |
| 54 | + = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> |
| 55 | + = note: reference of mutable static is a hard error from 2024 edition |
| 56 | + = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior |
| 57 | +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 |
| 58 | + | |
| 59 | +LL | let (_b, _c) = (addr_of!(X), &Y); |
| 60 | + | ~~~~~~~~~~~ |
| 61 | + |
| 62 | +error: shared reference of mutable static is discouraged |
| 63 | + --> $DIR/reference-of-mut-static.rs:32:29 |
| 64 | + | |
| 65 | +LL | let (_b, _c) = (&X, &Y); |
| 66 | + | ^^ shared reference of mutable static |
| 67 | + | |
| 68 | + = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> |
| 69 | + = note: reference of mutable static is a hard error from 2024 edition |
| 70 | + = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior |
| 71 | +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 |
| 72 | + | |
| 73 | +LL | let (_b, _c) = (&X, addr_of!(Y)); |
| 74 | + | ~~~~~~~~~~~ |
| 75 | + |
| 76 | +error: shared reference of mutable static is discouraged |
| 77 | + --> $DIR/reference-of-mut-static.rs:38:13 |
| 78 | + | |
| 79 | +LL | foo(&X); |
| 80 | + | ^^ shared reference of mutable static |
| 81 | + | |
| 82 | + = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> |
| 83 | + = note: reference of mutable static is a hard error from 2024 edition |
| 84 | + = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior |
| 85 | +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 |
| 86 | + | |
| 87 | +LL | foo(addr_of!(X)); |
| 88 | + | ~~~~~~~~~~~ |
| 89 | + |
| 90 | +error: aborting due to 6 previous errors |
| 91 | + |
0 commit comments