2018-11-15 12:49:00 -06:00
|
|
|
use std::mem;
|
|
|
|
|
2018-12-02 04:26:09 -06:00
|
|
|
pub fn safe(_x: &i32, _y: &mut i32) {} //~ ERROR barrier
|
2017-08-07 19:39:09 -05:00
|
|
|
|
|
|
|
fn main() {
|
2018-11-15 12:49:00 -06:00
|
|
|
let mut x = 0;
|
|
|
|
let xref = &mut x;
|
|
|
|
let xraw: *mut i32 = unsafe { mem::transmute_copy(&xref) };
|
|
|
|
let xshr = &*xref;
|
|
|
|
// transmute fn ptr around so that we can avoid retagging
|
|
|
|
let safe_raw: fn(x: *const i32, y: *mut i32) = unsafe {
|
|
|
|
mem::transmute::<fn(&i32, &mut i32), _>(safe)
|
|
|
|
};
|
|
|
|
safe_raw(xshr, xraw);
|
2017-08-07 19:39:09 -05:00
|
|
|
}
|