forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#61144 - estebank:issue-61108, r=matthewjasper
Suggest borrowing for loop head on move error Fix rust-lang#61108.
- Loading branch information
Showing
4 changed files
with
39 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fn main() { | ||
let mut bad_letters = vec!['e', 't', 'o', 'i']; | ||
for l in bad_letters { | ||
// something here | ||
} | ||
bad_letters.push('s'); //~ ERROR borrow of moved value: `bad_letters` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0382]: borrow of moved value: `bad_letters` | ||
--> $DIR/issue-61108.rs:6:5 | ||
| | ||
LL | let mut bad_letters = vec!['e', 't', 'o', 'i']; | ||
| --------------- move occurs because `bad_letters` has type `std::vec::Vec<char>`, which does not implement the `Copy` trait | ||
LL | for l in bad_letters { | ||
| ----------- | ||
| | | ||
| value moved here | ||
| help: consider borrowing to avoid moving into the for loop: `&bad_letters` | ||
... | ||
LL | bad_letters.push('s'); | ||
| ^^^^^^^^^^^ value borrowed here after move | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0382`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters