rust/tests/ui/consts/write_to_mut_ref_dest.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
178 B
Rust
Raw Normal View History

2024-08-17 12:19:34 +00:00
//@run-pass
const FOO: &u32 = {
let mut a = 42;
{
2024-08-17 12:19:34 +00:00
let b: *mut u32 = &mut a;
unsafe { *b = 5; }
}
&{a}
};
2024-08-17 12:19:34 +00:00
fn main() {
assert_eq!(*FOO, 5);
}