2018-11-07 14:08:20 -06:00
|
|
|
// Using a raw invalidates derived `&mut` even for reading.
|
|
|
|
fn main() {
|
|
|
|
let mut x = 2;
|
|
|
|
let xref1 = &mut x;
|
|
|
|
let xraw = xref1 as *mut _;
|
|
|
|
let xref2 = unsafe { &mut *xraw };
|
|
|
|
let _val = unsafe { *xraw }; // use the raw again, this invalidates xref2 *even* with the special read except for uniq refs
|
2019-02-12 03:51:03 -06:00
|
|
|
let _illegal = *xref2; //~ ERROR does not exist on the borrow stack
|
2018-11-07 14:08:20 -06:00
|
|
|
}
|