]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/illegal_write6.rs
Rollup merge of #102406 - mejrs:missing_copy, r=wesleywiser
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / illegal_write6.rs
1 fn main() {
2     let x = &mut 0u32;
3     let p = x as *mut u32;
4     foo(x, p);
5 }
6
7 fn foo(a: &mut u32, y: *mut u32) -> u32 {
8     *a = 1;
9     let _b = &*a;
10     unsafe { *y = 2 }; //~ ERROR: /not granting access .* because that would remove .* which is strongly protected/
11     return *a;
12 }