positron
positron copied to clipboard
static_mut_refs will be a hard error in the Rust 2024 edition
Positron Version:
GitHub
Steps to reproduce the issue:
cargo +nightly clippy -- -D static_mut_refs -A clippy::all -A unexpected_cfgs
What did you expect to happen?
I expect no warnings.
Were there any error messages in the output or Developer Tools console?
The 2024 edition will be released in a few months; the document says it will be available in Rust 1.82, which is supposed to be released on this October. Among the several changes (cf. a blog post related to the 2024 edition), only static_mut_refs is a new error. This isn't very urgent, but probably something that needs to be fixed.
❯ cargo +nightly clippy -- -D static_mut_refs -A clippy::all -A unexpected_cfgs
Checking ark v0.1.113 (C:\Users\Yutani\Documents\GitHub\ark\crates\ark)
error: creating a mutable reference to mutable static is discouraged
--> crates\ark\src\logger.rs:47:58
|
47 | let log_writer = non_blocking(log_file, unsafe { &mut LOG_GUARD });
| ^^^^^^^^^^^^^^ 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: requested on the command line with `-D static-mut-refs`
help: use `addr_of_mut!` instead to create a raw pointer
|
47 | let log_writer = non_blocking(log_file, unsafe { addr_of_mut!(LOG_GUARD) });
| ~~~~~~~~~~~~~~~~~~~~~~~
error: creating a mutable reference to mutable static is discouraged
--> crates\ark\src\logger.rs:80:70
|
80 | let profile_writer = non_blocking(profile_file, unsafe { &mut PROFILE_GUARD });
| ^^^^^^^^^^^^^^^^^^ 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
help: use `addr_of_mut!` instead to create a raw pointer
|
80 | let profile_writer = non_blocking(profile_file, unsafe { addr_of_mut!(PROFILE_GUARD) });
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: creating a shared reference to mutable static is discouraged
--> crates\ark\src\r_task.rs:291:21
|
291 | get_tx(unsafe { &R_MAIN_TASKS_INTERRUPT_TX })
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ shared 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 shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
help: use `addr_of!` instead to create a raw pointer
|
291 | get_tx(unsafe { addr_of!(R_MAIN_TASKS_INTERRUPT_TX) })
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: creating a shared reference to mutable static is discouraged
--> crates\ark\src\r_task.rs:294:21
|
294 | get_tx(unsafe { &R_MAIN_TASKS_IDLE_TX })
| ^^^^^^^^^^^^^^^^^^^^^ shared 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 shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
help: use `addr_of!` instead to create a raw pointer
|
294 | get_tx(unsafe { addr_of!(R_MAIN_TASKS_IDLE_TX) })
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: could not compile `ark` (lib) due to 4 previous errors