|
1 |
| -warning: shared reference of mutable static is discouraged |
| 1 | +warning: shared reference to mutable static is discouraged |
2 | 2 | --> $DIR/static-mut-foreign.rs:35:18
|
3 | 3 | |
|
4 | 4 | LL | static_bound(&rust_dbg_static_mut);
|
5 | 5 | | ^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static
|
6 | 6 | |
|
7 | 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 |
| 8 | + = note: reference of mutable static is a hard error in 2024 edition |
| 9 | + = note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways |
| 10 | + = note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways |
10 | 11 | = note: `#[warn(static_mut_ref)]` on by default
|
11 | 12 | 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 | |
|
13 | 14 | LL | static_bound(addr_of!(rust_dbg_static_mut));
|
14 | 15 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
15 | 16 |
|
16 |
| -warning: mutable reference of mutable static is discouraged |
| 17 | +warning: mutable reference to mutable static is discouraged |
17 | 18 | --> $DIR/static-mut-foreign.rs:37:22
|
18 | 19 | |
|
19 | 20 | LL | static_bound_set(&mut rust_dbg_static_mut);
|
20 | 21 | | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static
|
21 | 22 | |
|
22 | 23 | = 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 |
| 24 | + = note: reference of mutable static is a hard error in 2024 edition |
| 25 | + = note: a shared reference supposedly lives forever, so if there is ever also a mutable reference created that is very dangerous as they can accidentally be used in overlapping ways |
| 26 | + = note: a mutable reference supposedly lives forever, so creating more than one is very dangerous and they can accidentally be used in overlapping ways |
25 | 27 | 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 | 28 | |
|
27 | 29 | LL | static_bound_set(addr_of_mut!(rust_dbg_static_mut));
|
|
0 commit comments