mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 17:42:47 +00:00
92 lines
4.7 KiB
Plaintext
92 lines
4.7 KiB
Plaintext
error: shared reference of mutable static is discouraged
|
|
--> $DIR/reference-of-mut-static.rs:16:18
|
|
|
|
|
LL | let _y = &X;
|
|
| ^^ 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: the lint level is defined here
|
|
--> $DIR/reference-of-mut-static.rs:6:9
|
|
|
|
|
LL | #![deny(static_mut_ref)]
|
|
| ^^^^^^^^^^^^^^
|
|
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 _y = addr_of!(X);
|
|
| ~~~~~~~~~~~
|
|
|
|
error: mutable reference of mutable static is discouraged
|
|
--> $DIR/reference-of-mut-static.rs:20:18
|
|
|
|
|
LL | let _y = &mut X;
|
|
| ^^^^^^ 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 | let _y = addr_of_mut!(X);
|
|
| ~~~~~~~~~~~~~~~
|
|
|
|
error: shared reference of mutable static is discouraged
|
|
--> $DIR/reference-of-mut-static.rs:28:22
|
|
|
|
|
LL | let ref _a = X;
|
|
| ^ 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 ref _a = addr_of!(X);
|
|
| ~~~~~~~~~~~
|
|
|
|
error: shared reference of mutable static is discouraged
|
|
--> $DIR/reference-of-mut-static.rs:32:25
|
|
|
|
|
LL | let (_b, _c) = (&X, &Y);
|
|
| ^^ 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 (_b, _c) = (addr_of!(X), &Y);
|
|
| ~~~~~~~~~~~
|
|
|
|
error: shared reference of mutable static is discouraged
|
|
--> $DIR/reference-of-mut-static.rs:32:29
|
|
|
|
|
LL | let (_b, _c) = (&X, &Y);
|
|
| ^^ 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 (_b, _c) = (&X, addr_of!(Y));
|
|
| ~~~~~~~~~~~
|
|
|
|
error: shared reference of mutable static is discouraged
|
|
--> $DIR/reference-of-mut-static.rs:38:13
|
|
|
|
|
LL | foo(&X);
|
|
| ^^ 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 | foo(addr_of!(X));
|
|
| ~~~~~~~~~~~
|
|
|
|
error: aborting due to 6 previous errors
|
|
|