mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 05:57:03 +03:00
new compile-fail test involving non-reborrowing-cast-to-raw
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user