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: Lint cases with type annotations for indirect usage and recognize BinaryHeap #7163

Conversation

mgacek8
Copy link
Contributor

@mgacek8 mgacek8 commented May 4, 2021

fixes #7110
changelog: needless_collect: Lint cases with type annotations for indirect usage and recognize BinaryHeap.

@rust-highfive
Copy link

r? @flip1995

(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 4, 2021
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

LGTM overall.

if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0);
if let ty = cx.typeck_results().node_type(ty.hir_id);
if let Some(hir_id) = get_hir_id(*ty, method_name.args);
if let ty = cx.typeck_results().node_type(hir_id);
Copy link
Member

Choose a reason for hiding this comment

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

Since we're in a if_chain anyway, I'd rather use

Suggested change
if let ty = cx.typeck_results().node_type(hir_id);
if let Some(ty) = cx.typeck_results().node_type_opt(hir_id);

here. This may prevent future ICEs.

Copy link
Contributor Author

@mgacek8 mgacek8 May 5, 2021

Choose a reason for hiding this comment

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

Good point, thanks! Fixed that also in the check_needless_collect_direct_usage fn

@flip1995 flip1995 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 May 5, 2021
@flip1995
Copy link
Member

flip1995 commented May 5, 2021

@bors r+

Thanks! Really nice and small fix for this issue!

@bors
Copy link
Contributor

bors commented May 5, 2021

📌 Commit f79a2a3 has been approved by flip1995

@bors
Copy link
Contributor

bors commented May 5, 2021

⌛ Testing commit f79a2a3 with merge 0baf6bf...

@bors
Copy link
Contributor

bors commented May 5, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 0baf6bf 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.

Suggest Iterator::count instead of collecting + len
4 participants