-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
fn main() {
let mut bad_letters = vec!['e', 't', 'o', 'i'];
for l in bad_letters {
// do something here
}
bad_letters.push('s');
}
we should suggest borrowing bad_letters
:
error[E0382]: borrow of moved value: `bad_letters`
--> src/main.rs:6:5
|
2 | 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
3 | for l in bad_letters {
| -----------
| |
| value moved here
| help: consider borrowing here: `&bad_letters`
...
6 | bad_letters.push('s');
| ^^^^^^^^^^^ value borrowed here after move
|
= note: probably some explanation about `Iterator::into_iter`
This could potentially be incorrect without further analysis, but it should be correct in the majority of the cases that newcomers would face.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.