iter_cloned_collect false positive with custom From/IntoIterator impl #9119
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
When
FromIterator
is implemented for a type inside an another iterator,.collect()
is able to do run the inner iterator as well. Clippy doesn't recognize this case, and instead assumes that.iter().cloned().collect()
to aVec<_>
always has the same resulting type thanto_vec()
. This also occurs with.iter().copied().collect()
.Lint Name
iter_cloned_collect and iter_cloned_collect
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
No warning, as the
to_vec
cannot do the required conversion.Version
Additional Labels
@rustbot label +l-suggestion-causes-error
The text was updated successfully, but these errors were encountered: