]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / borrowck / borrowck-for-loop-head-linkage.nll.stderr
1 error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable
2   --> $DIR/borrowck-for-loop-head-linkage.rs:17:9
3    |
4 LL |     for &x in &vector {
5    |               -------
6    |               |
7    |               immutable borrow occurs here
8    |               borrow used here, in later iteration of loop
9 LL |         let cap = vector.capacity();
10 LL |         vector.extend(repeat(0));      //~ ERROR cannot borrow
11    |         ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
12
13 error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable
14   --> $DIR/borrowck-for-loop-head-linkage.rs:18:9
15    |
16 LL |     for &x in &vector {
17    |               -------
18    |               |
19    |               immutable borrow occurs here
20    |               borrow used here, in later iteration of loop
21 ...
22 LL |         vector[1] = 5;   //~ ERROR cannot borrow
23    |         ^^^^^^ mutable borrow occurs here
24
25 error: aborting due to 2 previous errors
26
27 For more information about this error, try `rustc --explain E0502`.