-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
needless_collect: Lint cases with type annotations for indirect usage and recognize BinaryHeap
#7163
Conversation
r? @flip1995 (rust-highfive 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.
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); |
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.
Since we're in a if_chain
anyway, I'd rather use
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.
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.
Good point, thanks! Fixed that also in the check_needless_collect_direct_usage fn
It may prevent future ICEs.
@bors r+ Thanks! Really nice and small fix for this issue! |
📌 Commit f79a2a3 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes #7110
changelog: needless_collect: Lint cases with type annotations for indirect usage and recognize
BinaryHeap
.