rust/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr

28 lines
1.0 KiB
Plaintext
Raw Normal View History

2018-08-08 07:28:26 -05:00
error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-for-loop-head-linkage.rs:17:9
|
LL | for &x in &vector {
| ------
| | |
| | immutable borrow ends here
| immutable borrow occurs here
LL | let cap = vector.capacity();
LL | vector.extend(repeat(0)); //~ ERROR cannot borrow
| ^^^^^^ mutable borrow occurs here
error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-for-loop-head-linkage.rs:18:9
|
LL | for &x in &vector {
| ------
| | |
| | immutable borrow ends here
| immutable borrow occurs here
...
LL | vector[1] = 5; //~ ERROR cannot borrow
| ^^^^^^ mutable borrow occurs here
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0502`.