needless_collect
has no understanding of lifetimes
#9219
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
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
needless_collect
doesn't consider if the iterator is borrowing values that are moved between thecollect
call and where the collected values are used.Lint Name
needless_collect
Reproducer
I tried this code:
I saw this happen:
needless_collect
suggests this code, which referencesoriginal
after I explicitly move it and the suggestion does not compile.I expected to see this happen:
needless_collect
should not fire here sinceoriginals
is moved after thecollect
call but before theinto_iter
call that it wants to eliminate.Version
Additional Labels
@rustbot label I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: