]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/suggest-storing-local-var-for-vector.stderr
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / suggest-storing-local-var-for-vector.stderr
1 error[E0502]: cannot borrow `vec` as immutable because it is also borrowed as mutable
2   --> $DIR/suggest-storing-local-var-for-vector.rs:3:9
3    |
4 LL |     vec[vec.len() - 1] = 123;
5    |     ----^^^^^^^^^-----
6    |     |   |
7    |     |   immutable borrow occurs here
8    |     mutable borrow occurs here
9    |     mutable borrow later used here
10    |
11 help: try adding a local storing this...
12   --> $DIR/suggest-storing-local-var-for-vector.rs:3:9
13    |
14 LL |     vec[vec.len() - 1] = 123;
15    |         ^^^^^^^^^
16 help: ...and then using that local here
17   --> $DIR/suggest-storing-local-var-for-vector.rs:3:5
18    |
19 LL |     vec[vec.len() - 1] = 123;
20    |     ^^^^^^^^^^^^^^^^^^
21
22 error: aborting due to previous error
23
24 For more information about this error, try `rustc --explain E0502`.