rust/tests/ui/consts/write_to_mut_ref_dest.rs

15 lines
178 B
Rust

//@run-pass
const FOO: &u32 = {
let mut a = 42;
{
let b: *mut u32 = &mut a;
unsafe { *b = 5; }
}
&{a}
};
fn main() {
assert_eq!(*FOO, 5);
}