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

needless_collect enhancements #7188

Merged
merged 4 commits into from
May 13, 2021

Conversation

mgacek8
Copy link
Contributor

@mgacek8 mgacek8 commented May 7, 2021

fixes #7164
changelog: needless_collect: For BTreeMap and HashMap lint only is_empty, as len might produce different results than iter's count
changelog: needless_collect: Lint LinkedList and BinaryHeap in direct usage case as well

- `len` might produce different results than `count`
- they don't have `contain` but `contains_key` method
Those two types are supported already when used indirectly.
This commit adds support for direct usage as well.
@rust-highfive
Copy link

r? @phansch

(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 May 7, 2021
@mgacek8 mgacek8 changed the title Issue 7164 needless_collect enhancements May 7, 2021
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.

The rest of the implementation looks good to me 🙃

clippy_lints/src/loops/needless_collect.rs Outdated Show resolved Hide resolved
clippy_lints/src/loops/needless_collect.rs Outdated Show resolved Hide resolved
+ small code refactor - using early returns.
@xFrednet
Copy link
Member

Your changes look good to me. You can resolve my comments 🙃

@flip1995
Copy link
Member

@bors r=xFrednet,flip1995

Thanks! And thanks for reviewing @xFrednet!

@bors
Copy link
Collaborator

bors commented May 13, 2021

📌 Commit b249290 has been approved by xFrednet,flip1995

@bors
Copy link
Collaborator

bors commented May 13, 2021

⌛ Testing commit b249290 with merge 10db5a6...

@bors
Copy link
Collaborator

bors commented May 13, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet,flip1995
Pushing 10db5a6 to master...

@bors bors merged commit 10db5a6 into rust-lang:master May 13, 2021
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.

FP: needless_collect for HashMap and BTreeMap
6 participants