-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedT-MIRType: This lint will require working with the MIRType: This lint will require working with the MIR
Description
This output is from running clippy on https://github.com/rust-lang/stdarch/blob/598e632e8f62ff5054dfe0d0fabb2a03ecee0a3d/crates/stdarch-test/src/disassembly.rs#L102-L116. The relevant snippet is
while let Some(header) = cached_header.take().or_else(|| lines.next()) {
while let Some(instruction) = lines.next() {
}
}
$ cargo clippy --fix -Z unstable-options
after fixes were automatically applied the compiler reported errors within these files:
* crates/stdarch-test/src/disassembly.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error[E0382]: borrow of moved value: `lines`
--> crates/stdarch-test/src/disassembly.rs:117:59
|
105 | let mut lines = output.lines();
| --------- move occurs because `lines` has type `std::str::Lines<'_>`, which does not implement the `Copy` trait
...
117 | while let Some(header) = cached_header.take().or_else(|| lines.next()) {
| ^^ ----- borrow occurs due to use in closure
| |
| value borrowed here after move
...
125 | for instruction in lines {
| -----
| |
| value moved here, in previous iteration of loop
| help: consider borrowing to avoid moving into the for loop: `&lines`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.
Original diagnostics will follow.
warning: this loop could be written as a `for` loop
--> crates/stdarch-test/src/disassembly.rs:125:9
|
125 | while let Some(instruction) = lines.next() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for instruction in lines`
|
= note: `#[warn(clippy::while_let_on_iterator)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
warning: this loop could be written as a `for` loop
--> crates/stdarch-test/src/disassembly.rs:125:9
|
125 | while let Some(instruction) = lines.next() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for instruction in lines`
|
= note: `#[warn(clippy::while_let_on_iterator)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedT-MIRType: This lint will require working with the MIRType: This lint will require working with the MIR