]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/stacked_borrows/aliasing_mut3.rs
adjust compile-fail error messages
[rust.git] / tests / compile-fail / stacked_borrows / aliasing_mut3.rs
1 use std::mem;
2
3 pub fn safe(_x: &mut i32, _y: &i32) {} //~ ERROR borrow stack
4
5 fn main() {
6     let mut x = 0;
7     let xref = &mut x;
8     let xraw: *mut i32 = unsafe { mem::transmute_copy(&xref) };
9     let xshr = &*xref;
10     // transmute fn ptr around so that we can avoid retagging
11     let safe_raw: fn(x: *mut i32, y: *const i32) = unsafe {
12         mem::transmute::<fn(&mut i32, &i32), _>(safe)
13     };
14     safe_raw(xraw, xshr);
15 }