-
Notifications
You must be signed in to change notification settings - Fork 1.6k
new lint: explicit_into_iter_fn_arg
#10814
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
Conversation
r? @llogiq (rustbot has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good in general, I only have a scant few suggestions.
☔ The latest upstream changes (presumably #10810) made this pull request unmergeable. Please resolve the merge conflicts. |
One small idea for improvement: If there are multiple @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
[`useless_conversion`]: pluralize if there are multiple `.into_iter()` calls context: #10814 (comment) changelog: [`useless_conversion`]: pluralize if there are multiple `.into_iter()` calls in the chain r? `@llogiq`
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro Fixes #11065 (which is actually two issues: an ICE and a false positive) It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes #11065 (comment)). It *also* makes sure that the expression is not part of a macro call (fixes #11065 (comment)). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore) changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP) r? `@llogiq` (reviewed #10814, which introduced these issues)
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro Fixes rust-lang#11065 (which is actually two issues: an ICE and a false positive) It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes rust-lang#11065 (comment)). It *also* makes sure that the expression is not part of a macro call (fixes rust-lang#11065 (comment)). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore) changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP) r? `@llogiq` (reviewed rust-lang#10814, which introduced these issues)
Closes #10743.
This adds a lint that looks for
.into_iter()
calls in a call expression to a function that already expects anIntoIterator
. In those cases, explicitly calling.into_iter()
is unnecessary.There were a few instances of this in clippy itself so I fixed those as well in this PR.
changelog: new lint [
explicit_into_iter_fn_arg
]