]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/stacked_borrows/shr_frozen_violation1.rs
adjust compile-fail error messages
[rust.git] / tests / compile-fail / stacked_borrows / shr_frozen_violation1.rs
1 fn foo(x: &mut i32) -> i32 {
2   *x = 5;
3   unknown_code(&*x);
4   *x // must return 5
5 }
6
7 fn main() {
8     println!("{}", foo(&mut 0));
9 }
10
11 fn unknown_code(x: &i32) {
12     unsafe { *(x as *const i32 as *mut i32) = 7; } //~ ERROR borrow stack
13 }