2018-10-17 09:55:59 -05:00
|
|
|
// This makes a ref that was passed to us via &mut alias with things it should not alias with
|
|
|
|
fn retarget(x: &mut &u32, target: &mut u32) {
|
2022-06-21 01:40:39 -05:00
|
|
|
unsafe {
|
|
|
|
*x = &mut *(target as *mut _);
|
|
|
|
}
|
2018-10-17 09:55:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let target = &mut 42;
|
|
|
|
let mut target_alias = &42; // initial dummy value
|
|
|
|
retarget(&mut target_alias, target);
|
|
|
|
// now `target_alias` points to the same thing as `target`
|
|
|
|
*target = 13;
|
2022-07-13 17:59:33 -05:00
|
|
|
let _val = *target_alias; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
2018-10-17 09:55:59 -05:00
|
|
|
}
|