Skip to content

lint unnecessary .into_iter() #1094

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

Closed
zackmdavis opened this issue Jul 13, 2016 · 0 comments · Fixed by #1250
Closed

lint unnecessary .into_iter() #1094

zackmdavis opened this issue Jul 13, 2016 · 0 comments · Fixed by #1250
Labels
A-lint Area: New lints 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 T-middle Type: Probably requires verifiying types

Comments

@zackmdavis
Copy link
Member

for loops implicitly call .into_iter() on that which is being iterated over, but if someone didn't know this, they might have written .into_iter() themselves (this is not merely a hypothetical scenario), which is surely bad style.

Example of code that should get a warning (but does not as of Clippy v. 0.0.79):

fn main() {
    let my_vec = vec![1, 2, 3, 4];
    for i in my_vec.into_iter() {
        println!("{}", i);
    }
}

(could be just for i in my_vec {)

I'm guessing the implementation would probably be pretty similar to that of the existing explicit_iter_loop lint?

@mcarton mcarton added good-first-issue These issues are a good way to get started with Clippy T-middle Type: Probably requires verifiying types C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages A-lint Area: New lints labels Jul 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints 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 T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants