]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/borrow-for-loop-head.stderr
Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper
[rust.git] / tests / ui / suggestions / borrow-for-loop-head.stderr
1 error[E0505]: cannot move out of `a` because it is borrowed
2   --> $DIR/borrow-for-loop-head.rs:4:18
3    |
4 LL |     for i in &a {
5    |              -- borrow of `a` occurs here
6 LL |         for j in a {
7    |                  ^ move out of `a` occurs here
8
9 error[E0382]: use of moved value: `a`
10   --> $DIR/borrow-for-loop-head.rs:4:18
11    |
12 LL |     let a = vec![1, 2, 3];
13    |         - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait
14 LL |     for i in &a {
15    |     ----------- inside of this loop
16 LL |         for j in a {
17    |                  ^ `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop
18    |
19 note: `into_iter` takes ownership of the receiver `self`, which moves `a`
20   --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
21 help: consider iterating over a slice of the `Vec<i32>`'s content to avoid moving into the `for` loop
22    |
23 LL |         for j in &a {
24    |                  +
25
26 error: aborting due to 2 previous errors
27
28 Some errors have detailed explanations: E0382, E0505.
29 For more information about an error, try `rustc --explain E0382`.