Skip to content

Lint unnecessary .into_iter() in function arguments #10743

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
yongqli opened this issue May 4, 2023 · 1 comment · Fixed by #10814
Closed

Lint unnecessary .into_iter() in function arguments #10743

yongqli opened this issue May 4, 2023 · 1 comment · Fixed by #10814
Assignees
Labels
A-lint Area: New lints

Comments

@yongqli
Copy link

yongqli commented May 4, 2023

What it does

If someone didn't know that various functions can take an impl IntoIterator instead of an impl Iterator for their arguments, they might have wrote useless explicit .into_iter()s.

See also #1094

Lint Name

explicit_into_iter_fn_arg

Category

pedantic

Advantage

No response

Drawbacks

No response

Example

fn main() {
    let mut v = vec![];
    v.extend(vec![0].into_iter());
}

Could be written as:

fn main() {
    let mut v = vec![];
    v.extend(vec![0]);
}
@yongqli yongqli added the A-lint Area: New lints label May 4, 2023
@y21
Copy link
Member

y21 commented May 22, 2023

@rustbot claim

I feel like instead of adding a new lint for this, we could just add it to the existing useless_conversion lint that you linked? Seems like another relevant case that it could handle
Edit: nevermind, I took a closer look at useless_conversion and it doesn't seem too related now that I think about it, so a new lint seems fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants