rust/tests/fail/stacked_borrows/illegal_write6.rs
2022-06-21 11:46:09 -07:00

15 lines
242 B
Rust

fn main() {
let x = &mut 0u32;
let p = x as *mut u32;
foo(x, p);
}
fn foo(a: &mut u32, y: *mut u32) -> u32 {
*a = 1;
let _b = &*a;
unsafe {
*y = 2;
} //~ ERROR: not granting access to tag
return *a;
}