-
Notifications
You must be signed in to change notification settings - Fork 1.8k
unnecessary_fold improvements
#13475
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
Conversation
…tion and loosen turbofish rules
…iants to make sure the logic is correct
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Centri3 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
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.
Just a couple nits, thanks!
|
|
||
| let turbofish = if replacement.has_generic_return { | ||
| format!("::<{}>", cx.typeck_results().expr_ty_adjusted(right_expr).peel_refs()) | ||
| format!("::<{}>", cx.typeck_results().expr_ty(expr)) |
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.
Does this change make any difference? More specifically was the original code unnecessary
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.
I think I did it to be consistent with the new function I made, where there is no right_expr. And it is more straightforward and sure to work, as the type argument to sum and product is exactly the return type, which is the type of the whole expression.
| if let hir::Node::Block(block) = parent | ||
| && let grandparent = cx.tcx.parent_hir_node(block.hir_id) | ||
| && let hir::Node::Expr(grandparent_expr) = grandparent | ||
| && let ggparent = cx.tcx.parent_hir_node(grandparent_expr.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.
Probably better to iterate over the parents? is there any reason simply getting the containing item doesn't work?
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.
I don't know, I don't understand this infrastructure so well so my first try was probably not the best way to do it.
|
Hey @viliml, been almost a month and I'm pinging from triage. Has there been any progress? The implementation looks great to me beyond some small changes. Is there anything you're stuck on or have any questions? |
|
Hey @viliml, another ping. The last message still applies but at this point, if you don't have the time, is it ok/preferred if I push to your branch any nits I have said or find? |
|
@rustbot author |
|
☔ The latest upstream changes (possibly d28d234) made this pull request unmergeable. Please resolve the merge conflicts. |
|
bumping @viliml again :3 |
Co-authored-by: Catherine Flores <[email protected]>
|
Oh, I'm sorry for not responding to your pings. I did this mostly just for fun and to see how Clippy works from the inside, so I kinda forgot about it afterwards and didn't check my notifications.
Yes, it's OK, that's why I checked the "allow commits by maintainers" option. |
Made it recognize std::ops::Add::add and std::ops::Mul::mul, as well as prevented it from adding a turbofish when it is the return value of a function with a known return type.
changelog: none