2018-11-15 12:49:00 -06:00
|
|
|
fn inner(x: *mut i32, _y: &i32) {
|
|
|
|
// If `x` and `y` alias, retagging is fine with this... but we really
|
|
|
|
// shouldn't be allowed to write to `x` at all because `y` was assumed to be
|
|
|
|
// immutable for the duration of this call.
|
2019-04-17 07:57:13 -05:00
|
|
|
unsafe { *x = 0 }; //~ ERROR protect
|
2018-11-15 12:49:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = 0;
|
|
|
|
let xraw = &mut x as *mut _;
|
|
|
|
let xref = unsafe { &*xraw };
|
|
|
|
inner(xraw, xref);
|
|
|
|
}
|