about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/both_borrows/outdated_local.rs
blob: 1330496bbe931095c12baf2c78559a354e208347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows

fn main() {
    let mut x = 0;
    let y: *const i32 = &x;
    x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local

    assert_eq!(unsafe { *y }, 1);
    //~[stack]^ ERROR: /read access .* tag does not exist in the borrow stack/
    //~[tree]| ERROR: /read access through .* is forbidden/

    assert_eq!(x, 1);
}