Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from_iter_instead_of_collect / needless_collect interaction questionable #6533

Open
matthiaskrgr opened this issue Jan 1, 2021 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't L-nursery Lint: Currently in the nursery group

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jan 1, 2021

for _i in Vec::from_iter([1, 2, 3].iter()) {}

clippy will suggest to use .collect() instead of from_iter() here but blindly replacing will not work because .collect() will need some kind of type hint.

Them again

for _i in [1, 2, 3].iter().collect::<Vec<&i32>>() {}

does not trigger clippy::needless_collect (although it should!; neither does the first example) because we can iterate over

for _i in [1, 2, 3].iter() {}

directly.

@matthiaskrgr matthiaskrgr added I-false-positive Issue: The lint was triggered on code it shouldn't have I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Jan 1, 2021
@camsteffen camsteffen added the C-bug Category: Clippy is not doing the correct thing label Jan 26, 2021
@camsteffen camsteffen added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy and removed C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Feb 18, 2021
@camsteffen
Copy link
Contributor

Re-labeling as the first issue is fixed in #6657.

@y21
Copy link
Member

y21 commented Jun 16, 2023

@J-ZhengLi J-ZhengLi added the L-nursery Lint: Currently in the nursery group label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't L-nursery Lint: Currently in the nursery group
Projects
None yet
Development

No branches or pull requests

4 participants