mirror of
https://git.proxmox.com/git/rustc
synced 2025-05-02 11:37:50 +00:00
62 lines
2.8 KiB
Plaintext
62 lines
2.8 KiB
Plaintext
warning: creating a mutable reference to mutable static is discouraged
|
|
--> $DIR/thread-local-static.rs:10:23
|
|
|
|
|
LL | std::mem::swap(x, &mut STATIC_VAR_2)
|
|
| ^^^^^^^^^^^^^^^^^ mutable reference to mutable static
|
|
|
|
|
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
|
= note: this will be a hard error in the 2024 edition
|
|
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
|
= note: `#[warn(static_mut_refs)]` on by default
|
|
help: use `addr_of_mut!` instead to create a raw pointer
|
|
|
|
|
LL | std::mem::swap(x, addr_of_mut!(STATIC_VAR_2))
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
|
|
--> $DIR/thread-local-static.rs:10:28
|
|
|
|
|
LL | std::mem::swap(x, &mut STATIC_VAR_2)
|
|
| ^^^^^^^^^^^^ use of mutable static
|
|
|
|
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
|
|
|
|
error[E0658]: mutable references are not allowed in constant functions
|
|
--> $DIR/thread-local-static.rs:8:12
|
|
|
|
|
LL | const fn g(x: &mut [u32; 8]) {
|
|
| ^
|
|
|
|
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
|
|
error[E0625]: thread-local statics cannot be accessed at compile-time
|
|
--> $DIR/thread-local-static.rs:10:28
|
|
|
|
|
LL | std::mem::swap(x, &mut STATIC_VAR_2)
|
|
| ^^^^^^^^^^^^
|
|
|
|
error[E0013]: constant functions cannot refer to statics
|
|
--> $DIR/thread-local-static.rs:10:28
|
|
|
|
|
LL | std::mem::swap(x, &mut STATIC_VAR_2)
|
|
| ^^^^^^^^^^^^
|
|
|
|
|
= help: consider extracting the value of the `static` to a `const`, and referring to that
|
|
|
|
error[E0658]: mutable references are not allowed in constant functions
|
|
--> $DIR/thread-local-static.rs:10:23
|
|
|
|
|
LL | std::mem::swap(x, &mut STATIC_VAR_2)
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
|
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
|
|
error: aborting due to 5 previous errors; 1 warning emitted
|
|
|
|
Some errors have detailed explanations: E0013, E0133, E0625, E0658.
|
|
For more information about an error, try `rustc --explain E0013`.
|