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

improve [for_loops_over_fallibles] to detect the usage of iter, iter_mut and into_iterator #8941

Merged
merged 2 commits into from
Jun 5, 2022

Conversation

DevAccentor
Copy link
Contributor

fix #6762

detects code like

for _ in option.iter() {
    //..
}

changelog: Improve [for_loops_over_fallibles] to detect for _ in option.iter() {} or using iter_mut() or into_iterator().

@rust-highfive
Copy link

r? @llogiq

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 4, 2022
Copy link
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making clippy better! I have but a small nit, otherwise it looks merge-worthy.

Comment on lines 23 to 32
// check over a `Result`
for x in result.into_iter() {
println!("{}", x);
}

// check over a `Result`
for x in result.iter_mut() {
println!("{}", x);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have switched the order of those. If result wasn't Copy, this would consume it before borrowing it mutably.

@llogiq
Copy link
Contributor

llogiq commented Jun 5, 2022

Thanks! 👍

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 5, 2022

📌 Commit 3737abe has been approved by llogiq

@bors
Copy link
Collaborator

bors commented Jun 5, 2022

⌛ Testing commit 3737abe with merge 3e52dee...

@bors
Copy link
Collaborator

bors commented Jun 5, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing 3e52dee to master...

@bors bors merged commit 3e52dee into rust-lang:master Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opt-in warn when using iter()-like methods on Option or Result
4 participants