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

explicit_iter_loop should warn &[T].iter() #1518

Closed
malbarbo opened this issue Feb 7, 2017 · 2 comments · Fixed by #10416
Closed

explicit_iter_loop should warn &[T].iter() #1518

malbarbo opened this issue Feb 7, 2017 · 2 comments · Fixed by #10416
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't T-middle Type: Probably requires verifiying types

Comments

@malbarbo
Copy link

malbarbo commented Feb 7, 2017

fn main() {
    let s = &[1, 2, 3, 4];
    for a in s.iter() { // .iter() is not necessary
        println!("{:?}", a);
    }
}
@mcarton mcarton added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages T-middle Type: Probably requires verifiying types labels Feb 7, 2017
@llogiq
Copy link
Contributor

llogiq commented Feb 7, 2017

As long as s Derefs to a slice.

@retep998
Copy link
Member

retep998 commented Oct 7, 2020

This lint should also apply to for foo in bar.iter() when bar: &Vec<T> but it currently does not.

@camsteffen camsteffen added I-false-negative Issue: The lint should have been triggered on code, but wasn't C-bug Category: Clippy is not doing the correct thing and removed C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Nov 13, 2021
@bors bors closed this as completed in 841f219 Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants