Open
Description
Code
static mut COUNTER: u32 = 0;
unsafe fn add_to_count(inc: u32) {
unsafe {
COUNTER += inc;
}
}
fn main() {
unsafe {
add_to_count(3);
println!("COUNTER: {}", COUNTER);
}
}
Current output
error: creating a shared reference to mutable static is discouraged
Desired output
error: creating a shared reference to mutable static is not allowed
Rationale and extra context
Edition 2021 warning "warning: creating a shared reference to mutable static is discouraged" has become edition 2024 error "error: creating a shared reference to mutable static is discouraged", which is wrong.
That behaviour is no longer discouraged but it is now not allowed.
Other cases
Rust Version
rustc 1.86.0, edition 2024.
Anything else?
No response