Closed
Description
Given the following code:
use std::sync::Mutex;
const FOO: Mutex<u64> = Mutex::new(0);
fn main() {
{
let foo = &FOO;
let a: &mut u64 = &mut foo.lock().unwrap();
*a = 1;
}
println!("{:?}", &FOO);
}
The current output is:
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 0.86s
Running `target/debug/playground`
Mutex { data: 0, poisoned: false, .. }
The const expression causes every site to have their own Mutex<T>
, which never makes any sense. Imho this should raise a warning, or even an error.