]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/stacked_borrows/pass_invalid_shr.rs
adjust compile-fail error messages
[rust.git] / tests / compile-fail / stacked_borrows / pass_invalid_shr.rs
1 // Make sure that we cannot pass by argument a `&` that got already invalidated.
2 fn foo(_: &i32) {}
3
4 fn main() {
5     let x = &mut 42;
6     let xraw = x as *mut _;
7     let xref = unsafe { &*xraw };
8     unsafe { *xraw = 42 }; // unfreeze
9     foo(xref); //~ ERROR borrow stack
10 }