1 // Make sure we cannot use raw ptrs that got transmuted from mutable references
2 // (i.e, no EscapeToRaw happened).
3 // We could, in principle, do EscapeToRaw lazily to allow this code, but that
4 // would no alleviate the need for EscapeToRaw (see `ref_raw_int_raw` in
5 // `run-pass/stacked-borrows.rs`), and thus increase overall complexity.
6 use std::mem;
7 
main()8 fn main() {
9     let mut x: [i32; 2] = [42, 43];
10     let _raw: *mut i32 = unsafe { mem::transmute(&mut x[0]) };
11     // `raw` still carries a tag, so we get another pointer to the same location that does not carry a tag
12     let raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
13     unsafe { *raw = 13; } //~ ERROR borrow stack
14 }
15