while_let_on_iterator causes compile error #5844
Labels
C-bug
Category: Clippy is not doing the correct thing
C-enhancement
Category: Enhancement of lints, like adding more cases or adding help messages
I-false-positive
Issue: The lint was triggered on code it shouldn't have
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
L-suggestion
Lint: Improving, adding or fixing lint suggestions
T-MIR
Type: This lint will require working with the MIR
With this code:
I expected to see this happen: No suggestion or a suggestion which doesn't cause a compile error
Instead, this happened: Clippy makes this suggestion which causes a compile error:
which leads to the following compilation error
Following that suggestion by borrowing there doesn't fix the issue, as it then suggests you remove the borrow due to
&iter
not being an iterable.However, borrowing mutably (adding
&mut
) results in code which compiles and passes clippy. It would be nice if clippy could have this&mut
in the original suggestion (though I don't know enough about the borrow checker to know how easy that would be to implement).Here it is on the playground
Meta
cargo clippy -V
: clippy 0.0.212 (5c1f21c 2020-07-13)rustc -Vv
:rustc 1.45.0 (5c1f21c3b 2020-07-13)
binary: rustc
commit-hash: 5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2
commit-date: 2020-07-13
host: x86_64-unknown-linux-gnu
release: 1.45.0
LLVM version: 10.0
The text was updated successfully, but these errors were encountered: