new compile-fail test involving non-reborrowing-cast-to-raw
This commit is contained in:
parent
acd156d722
commit
e0adfe4d45
2 changed files with 13 additions and 1 deletions
13
tests/compile-fail/stacked_borrows/illegal_read8.rs
Normal file
13
tests/compile-fail/stacked_borrows/illegal_read8.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Make sure that creating a raw ptr next to a shared ref works
|
||||
// but the shared ref still gets invalidated when the raw ptr is used for writing.
|
||||
|
||||
fn main() { unsafe {
|
||||
use std::mem;
|
||||
let x = &mut 0;
|
||||
let y1: &i32 = mem::transmute(&*x); // launder lifetimes
|
||||
let y2 = x as *mut _;
|
||||
let _val = *y2;
|
||||
let _val = *y1;
|
||||
*y2 += 1;
|
||||
let _fail = *y1; //~ ERROR borrow stack
|
||||
} }
|
||||
|
|
@ -136,7 +136,6 @@ fn shr_and_raw() { unsafe {
|
|||
let y2 = x as *mut _;
|
||||
let _val = *y1;
|
||||
*y2 += 1;
|
||||
// TODO: Once this works, add compile-fail test that tries to read from y1 again.
|
||||
} }
|
||||
|
||||
fn disjoint_mutable_subborrows() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue