]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs
Unit test from #57866.
[rust.git] / src / test / ui / borrowck / two-phase-reservation-sharing-interference-2.rs
1 // compile-flags: -Z borrowck=mir -Z two-phase-borrows
2
3 // This is similar to two-phase-reservation-sharing-interference.rs
4 // in that it shows a reservation that overlaps with a shared borrow.
5 //
6 // Currently, this test fails with lexical lifetimes, but succeeds
7 // with non-lexical lifetimes. (The reason is because the activation
8 // of the mutable borrow ends up overlapping with a lexically-scoped
9 // shared borrow; but a non-lexical shared borrow can end before the
10 // activation occurs.)
11 //
12 // So this test is just making a note of the current behavior.
13
14 #![feature(rustc_attrs)]
15
16 #[rustc_error]
17 fn main() { //~ ERROR compilation successful
18     let mut v = vec![0, 1, 2];
19     let shared = &v;
20
21     v.push(shared.len());
22
23     assert_eq!(v, [0, 1, 2, 3]);
24 }