]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / 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 }