retarget(&mut target_alias, target);
// now `target_alias` points to the same thing as `target`
*target = 13;
- let _val = *target_alias; //~ ERROR does not exist on the borrow stack
+ let _val = *target_alias; //~ ERROR borrow stack
}
use std::mem;
-pub fn safe(_x: &mut i32, _y: &i32) {} //~ ERROR does not exist on the borrow stack
+pub fn safe(_x: &mut i32, _y: &i32) {} //~ ERROR borrow stack
fn main() {
let mut x = 0;
unknown_code_2();
// We know this will return 5
- *our //~ ERROR does not exist on the borrow stack
+ *our //~ ERROR borrow stack
}
// Now comes the evil context
let v1 = safe::as_mut_slice(&v);
let _v2 = safe::as_mut_slice(&v);
v1[1] = 5;
- //~^ ERROR does not exist on the borrow stack
+ //~^ ERROR borrow stack
}
assert!(mid <= len);
(from_raw_parts_mut(ptr, len - mid), // BUG: should be "mid" instead of "len - mid"
- //~^ ERROR does not exist on the borrow stack
+ //~^ ERROR borrow stack
from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
}
}
let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok...
callee(xraw);
let _val = *xref; // ...but any use of raw will invalidate our ref.
- //~^ ERROR: does not exist on the borrow stack
+ //~^ ERROR: borrow stack
}
fn callee(xraw: *mut i32) {
let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok...
callee(xraw);
let _val = *xref; // ...but any use of raw will invalidate our ref.
- //~^ ERROR: does not exist on the borrow stack
+ //~^ ERROR: borrow stack
}
fn callee(xraw: *mut i32) {
callee(xref1_sneaky);
// ... though any use of it will invalidate our ref.
let _val = *xref2;
- //~^ ERROR: does not exist on the borrow stack
+ //~^ ERROR: borrow stack
}
fn callee(xref1: usize) {
let xraw = xref1 as *mut _;
let xref2 = unsafe { &mut *xraw };
let _val = unsafe { *xraw }; // use the raw again, this invalidates xref2 *even* with the special read except for uniq refs
- let _illegal = *xref2; //~ ERROR does not exist on the borrow stack
+ let _illegal = *xref2; //~ ERROR borrow stack
}
let _val = *xref; // we can even still use our mutable reference
mem::forget(unsafe { ptr::read(xshr) }); // but after reading through the shared ref
let _val = *xref; // the mutable one is dead and gone
- //~^ ERROR does not exist on the borrow stack
+ //~^ ERROR borrow stack
}
let x : *mut u32 = xref as *const _ as *mut _;
unsafe { *x = 42; } // invalidates shared ref, activates raw
}
- let _x = *xref; //~ ERROR is not frozen
+ let _x = *xref; //~ ERROR borrow stack
}
let target2 = target as *mut _;
drop(&mut *target); // reborrow
// Now make sure our ref is still the only one.
- unsafe { *target2 = 13; } //~ ERROR does not exist on the borrow stack
+ unsafe { *target2 = 13; } //~ ERROR borrow stack
let _val = *target;
}
// Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref.
let r#ref = ⌖ // freeze
let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag
- unsafe { *ptr = 42; } //~ ERROR does not exist on the borrow stack
+ unsafe { *ptr = 42; } //~ ERROR borrow stack
let _val = *r#ref;
}
let ptr = reference as *const _ as *mut i32; // raw ptr, with raw tag
let _mut_ref: &mut i32 = unsafe { mem::transmute(ptr) }; // &mut, with raw tag
// Now we retag, making our ref top-of-stack -- and, in particular, unfreezing.
- let _val = *reference; //~ ERROR is not frozen
+ let _val = *reference; //~ ERROR borrow stack
}
callee(xraw);
// ... though any use of raw value will invalidate our ref.
let _val = *xref;
- //~^ ERROR: does not exist on the borrow stack
+ //~^ ERROR: borrow stack
}
fn callee(xraw: *mut i32) {
let xref = unsafe { &mut *xraw };
let xref_in_mem = Box::new(xref);
let _val = unsafe { *xraw }; // invalidate xref
- let _val = *xref_in_mem; //~ ERROR does not exist on the borrow stack
+ let _val = *xref_in_mem; //~ ERROR borrow stack
}
let xref = unsafe { &*xraw };
let xref_in_mem = Box::new(xref);
unsafe { *xraw = 42 }; // unfreeze
- let _val = *xref_in_mem; //~ ERROR is not frozen
+ let _val = *xref_in_mem; //~ ERROR borrow stack
}
} }
fn unknown_code_2() { unsafe {
- *LEAK = 7; //~ ERROR barrier
+ *LEAK = 7; //~ ERROR borrow stack
} }
fn main() {
let y: *const i32 = &x;
x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local
- assert_eq!(unsafe { *y }, 1); //~ ERROR does not exist on the borrow stack
+ assert_eq!(unsafe { *y }, 1); //~ ERROR borrow stack
assert_eq!(x, 1);
}
let xraw = x as *mut _;
let xref = unsafe { &mut *xraw };
let _val = unsafe { *xraw }; // invalidate xref
- foo(xref); //~ ERROR does not exist on the borrow stack
+ foo(xref); //~ ERROR borrow stack
}
let xraw = x as *mut _;
let xref = unsafe { &*xraw };
unsafe { *xraw = 42 }; // unfreeze
- foo(xref); //~ ERROR is not frozen
+ foo(xref); //~ ERROR borrow stack
}
fn fun2() {
// Now we use a pointer we are not allowed to use
- let _x = unsafe { *PTR }; //~ ERROR does not exist on the borrow stack
+ let _x = unsafe { *PTR }; //~ ERROR borrow stack
}
fn main() {
let xraw = x as *mut (i32, i32);
let ret = unsafe { &mut (*xraw).1 };
let _val = unsafe { *xraw }; // invalidate xref
- ret //~ ERROR does not exist on the borrow stack
+ ret //~ ERROR borrow stack
}
fn main() {
let xraw = x as *mut (i32, i32);
let ret = Some(unsafe { &mut (*xraw).1 });
let _val = unsafe { *xraw }; // invalidate xref
- ret //~ ERROR does not exist on the borrow stack
+ ret //~ ERROR borrow stack
}
fn main() {
let xraw = x as *mut (i32, i32);
let ret = (unsafe { &mut (*xraw).1 },);
let _val = unsafe { *xraw }; // invalidate xref
- ret //~ ERROR does not exist on the borrow stack
+ ret //~ ERROR borrow stack
}
fn main() {
let xraw = x as *mut (i32, i32);
let ret = unsafe { &(*xraw).1 };
unsafe { *xraw = (42, 23) }; // unfreeze
- ret //~ ERROR is not frozen
+ ret //~ ERROR borrow stack
}
fn main() {
let xraw = x as *mut (i32, i32);
let ret = Some(unsafe { &(*xraw).1 });
unsafe { *xraw = (42, 23) }; // unfreeze
- ret //~ ERROR is not frozen
+ ret //~ ERROR borrow stack
}
fn main() {
let xraw = x as *mut (i32, i32);
let ret = (unsafe { &(*xraw).1 },);
unsafe { *xraw = (42, 23) }; // unfreeze
- ret //~ ERROR is not frozen
+ ret //~ ERROR borrow stack
}
fn main() {
println!("{}", foo(&mut 0));
}
-// If we replace the `*const` by `&`, my current dev version of miri
-// *does* find the problem, but not for a good reason: It finds it because
-// of barriers, and we shouldn't rely on unknown code using barriers.
-fn unknown_code(x: *const i32) {
- unsafe { *(x as *mut i32) = 7; } //~ ERROR barrier
+fn unknown_code(x: &i32) {
+ unsafe { *(x as *const i32 as *mut i32) = 7; } //~ ERROR borrow stack
}
#[allow(mutable_transmutes)]
fn main() {
let _x = unsafe {
- std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR mutable reference with frozen tag
+ std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR borrow stack
};
}
let _raw: *mut i32 = unsafe { mem::transmute(&mut x[0]) };
// `raw` still carries a tag, so we get another pointer to the same location that does not carry a tag
let raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
- unsafe { *raw = 13; } //~ ERROR does not exist on the borrow stack
+ unsafe { *raw = 13; } //~ ERROR borrow stack
}
let mut x = 42;
let raw = &mut x as *mut i32 as usize as *mut i32;
let _ptr = &mut x;
- unsafe { *raw = 13; } //~ ERROR does not exist on the borrow stack
+ unsafe { *raw = 13; } //~ ERROR borrow stack
}