rust/tests/ui/consts/write_to_mut_ref_dest.rs
2024-09-15 09:51:32 +02:00

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);
}