]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs
Add 'src/tools/rust-analyzer/' from commit '977e12a0bdc3e329af179ef3a9d466af9eb613bb'
[rust.git] / src / test / ui / borrowck / two-phase-cannot-nest-mut-self-calls.rs
1 // This is the third counter-example from Niko's blog post
2 // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/
3 //
4 // It shows that not all nested method calls on `self` are magically
5 // allowed by this change. In particular, a nested `&mut` borrow is
6 // still disallowed.
7
8 fn main() {
9
10
11     let mut vec = vec![0, 1];
12     vec.get({
13
14         vec.push(2);
15         //~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
16
17         0
18     });
19 }