2019-03-14 18:09:47 -05:00
|
|
|
error[E0505]: cannot move out of `a` because it is borrowed
|
|
|
|
--> $DIR/borrow-for-loop-head.rs:4:18
|
|
|
|
|
|
|
|
|
LL | for i in &a {
|
2019-04-22 02:40:08 -05:00
|
|
|
| -- borrow of `a` occurs here
|
2019-03-14 18:09:47 -05:00
|
|
|
LL | for j in a {
|
|
|
|
| ^ move out of `a` occurs here
|
|
|
|
|
|
|
|
error[E0382]: use of moved value: `a`
|
|
|
|
--> $DIR/borrow-for-loop-head.rs:4:18
|
|
|
|
|
|
2019-04-22 02:40:08 -05:00
|
|
|
LL | let a = vec![1, 2, 3];
|
2020-09-02 02:40:56 -05:00
|
|
|
| - move occurs because `a` has type `Vec<i32>`, which does not implement the `Copy` trait
|
2019-04-22 02:40:08 -05:00
|
|
|
LL | for i in &a {
|
2019-03-14 18:09:47 -05:00
|
|
|
LL | for j in a {
|
2019-05-24 20:23:43 -05:00
|
|
|
| ^
|
|
|
|
| |
|
2020-12-22 21:15:40 -06:00
|
|
|
| `a` moved due to this implicit call to `.into_iter()`, in previous iteration of loop
|
2019-05-24 20:23:43 -05:00
|
|
|
| help: consider borrowing to avoid moving into the for loop: `&a`
|
2020-12-22 21:15:40 -06:00
|
|
|
|
|
2021-01-08 13:57:28 -06:00
|
|
|
note: this function takes ownership of the receiver `self`, which moves `a`
|
2020-12-22 21:15:40 -06:00
|
|
|
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
|
|
|
|
|
|
|
|
LL | fn into_iter(self) -> Self::IntoIter;
|
|
|
|
| ^^^^
|
2019-03-14 18:09:47 -05:00
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
2019-04-17 12:26:38 -05:00
|
|
|
Some errors have detailed explanations: E0382, E0505.
|
2019-03-14 18:09:47 -05:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|