rust/tests/compile-fail-fullmir/stacked_borrows/aliasing_mut3.rs

18 lines
472 B
Rust
Raw Normal View History

#![allow(unused_variables)]
2018-11-15 12:49:00 -06:00
use std::mem;
pub fn safe(x: &mut i32, y: &i32) {} //~ ERROR does not exist on the stack
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: *mut i32, y: *const i32) = unsafe {
mem::transmute::<fn(&mut i32, &i32), _>(safe)
};
safe_raw(xraw, xshr);
}