Clippy Creates broken code, while transforming .iter().filter().cloned().collect() into retain(). #11457
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
clippy fix
failed with this output:warning: failed to automatically apply fixes suggested by rustc to crate
rustc_codegen_clr
Reproducer
Examples come from my project, and I have tagged the particular version of the source code which clippy had issues with. I had tried to extract and simplify the example, but so far I could not trigger it with simpler, isolated examples.
Clippy transformed this piece of code:
Into this broken code:
In the original filter, the type of
op
is&&BaseIR
, but in the version usingretain
type ofop
is&BaseIR
.It seems like Clippy did not take that into account while changing the code.
A proper translation would look like this:
Version
Additional Labels
@rustbot label +
I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: