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