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

Add iter_kv_map lint #9409

Merged
merged 3 commits into from
Sep 16, 2022
Merged

Add iter_kv_map lint #9409

merged 3 commits into from
Sep 16, 2022

Conversation

kartva
Copy link
Contributor

@kartva kartva commented Sep 1, 2022

fixes #9376

before after
hmap.iter().map(|(key, _)| key) hmap.keys()
hmap.iter().map(|(_, v)| v + 2) hmap.values().map(|v| v + 2)
hmap.into_iter().map(|(key, _)| key) hmap.into_keys()

Is MachineApplicable

changelog: [iter_kv_map]: added lint

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @xFrednet (or someone else) soon.

Please see the contribution instructions for more information.

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

@daira daira left a comment

Choose a reason for hiding this comment

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

Untested ACK.

@xFrednet
Copy link
Member

xFrednet commented Sep 4, 2022

Welcome, Clippy 👋

There has been a change to cargo dev update_lints on master which causes the CI fail. The fix should be as simple as rebasing and running that comment. 🙃

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Overall looks good to me and I really like this lint! I made some style related comments, which should be simple to fix. You're welcome to reach out if you need any help with them :)

clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
tests/ui/iter_kv_map.rs Show resolved Hide resolved
tests/ui/iter_kv_map.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/iter_kv_map.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/iter_kv_map.rs Show resolved Hide resolved
clippy_lints/src/methods/iter_kv_map.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/iter_kv_map.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/iter_kv_map.rs Outdated Show resolved Hide resolved
@kartva kartva force-pushed the iter_kv_map branch 2 times, most recently from 998b78a to 702a525 Compare September 7, 2022 13:15
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

You seem to have resolved some comments, even if they haven't been addressed or a comment why you think that they don't apply. I've now unresolved them. If you have questions or are unsure what I mean by them, please say so. Please tell me, if I misunderstood something.

This review sadly took some time, I'll try to reply faster next time.

Another note, Clippy uses rusts no merge commit policy. Merge commits are fine for now, but will need to be dropped or squashed before the merge. That's a bridge we can cross when we come to it 🙃

tests/ui/iter_kv_map.rs Outdated Show resolved Hide resolved
@xFrednet
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Sep 11, 2022
@kartva
Copy link
Contributor Author

kartva commented Sep 11, 2022

You seem to have resolved some comments, even if they haven't been addressed

Really sorry - I don't know what was going through my mind when I did that! Rest assured, I'll try to be more attentive moving forwards.

This review sadly took some time, I'll try to reply faster next time.

Please don't say that - I'm used to reviews taking a week, so this was super quick for me.

Clippy uses rusts no merge commit policy.

Ah, acknowledged. Should I squash/rebase right now?

@xFrednet
Copy link
Member

Really sorry - I don't know what was going through my mind when I did that! Rest assured, I'll try to be more attentive moving forwards.

No worries, I was just confused. This happens every once in a while :)

This review sadly took some time, I'll try to reply faster next time.

Please don't say that - I'm used to reviews taking a week, so this was super quick for me.

Thank you for the encouragement! I try to review every PR within 5 days. But life got the better of me, so now I'm just catching up on everything :). I'll give this a full review over the week :)

Ah, acknowledged. Should I squash/rebase right now?

You can do that, like you did, if I see it correctly. For larger PR it's better to wait until the review is done since GitHub is a bit iffy when it comes to linking old review comments to rebased code. But I remember them in this case, and they should all be addressed.

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Alright, this version already looks good to me. I had a few more suggestions for test, and then we can get this merged.

Could you also squash your commits? It's fine to have more than one if they're named properly, or just to have one review commit. 🙃

Small side note: I ran this on 26 Crates with our lintcheck, and it identified 5 cases, which were all correct. So it looks like time implementation is good to go 🎉

clippy_lints/src/methods/iter_kv_map.rs Outdated Show resolved Hide resolved
tests/ui/iter_kv_map.rs Show resolved Hide resolved
added binding annotations for all lines
@kartva
Copy link
Contributor Author

kartva commented Sep 15, 2022

Could you also squash your commits?

Squashed.

I ran this on 26 Crates with our lintcheck, and it identified 5 cases

Huh, and here I thought this was too niche a lint. Happy to hear that!

@kartva
Copy link
Contributor Author

kartva commented Sep 15, 2022

Oof, a pre-commit hook is correcting |(_, val)| {val} to |(_, val)| val. Even worse, adding #[rustfmt::skip] doesn't help because then it disables the rustfix tests. Trying to add the attribute to the statement shows me that that feature is still in nightly.

Would it be fine to just skip this test? @xFrednet

@xFrednet
Copy link
Member

Oof, a pre-commit hook is correcting |(_, val)| {val} to |(_, val)| val. Even worse, adding #[rustfmt::skip] doesn't help because then it disables the rustfix tests. Trying to add the attribute to the statement shows me that that feature is still in nightly.

Would it be fine to just skip this test? @xFrednet

Alright, then it's fine if we skip that test. Could you fix the CI? Then we can merge it :)

@xFrednet
Copy link
Member

Looks good to me, thank you for this implementation. The lint will be a great addition to Clippy. I hope you had fun while working on Clippy 🙃

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 16, 2022

📌 Commit c6219b2 has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Sep 16, 2022

⌛ Testing commit c6219b2 with merge 481dc2e...

@bors
Copy link
Collaborator

bors commented Sep 16, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 481dc2e to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint map.iter().map(|(_,v)| v)
6 participants