2018-11-15 12:49:00 -06:00
|
|
|
use std::mem;
|
|
|
|
|
2019-04-16 10:17:28 -05:00
|
|
|
pub fn safe(_x: &mut i32, _y: &i32) {} //~ ERROR borrow stack
|
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
|
2022-06-21 01:40:39 -05:00
|
|
|
let safe_raw: fn(x: *mut i32, y: *const i32) =
|
|
|
|
unsafe { mem::transmute::<fn(&mut i32, &i32), _>(safe) };
|
2018-11-15 12:49:00 -06:00
|
|
|
safe_raw(xraw, xshr);
|
2017-08-07 19:39:09 -05:00
|
|
|
}
|