-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix invalid suggestions on unit range bindings #97505
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
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
let suggestion = if exp_found.found.is_unit() { | ||
let exp_str = format!("{:?}", expected_def); | ||
|
||
// `RangeInclusive`'s fields are private, we have to call methods instead. | ||
if exp_str.contains("core::ops::RangeInclusive") | ||
|| exp_str.contains("std::ops::RangeInclusive") | ||
{ |
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 think this is the right approach. I would instead add a &hir::Expr
(or a HirId
to get the expression back) to Pattern
so that we can then call .precedence()
and compare it to ExprPrecedence::Field
. This will work regardless of the types. Also, with access to the expression itself, it'd be nice to see if notice these kind of range literals to suggest changing the range to the start or end, instead of constructing the range and then field accessing one of those.
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.
Thanks, I've tried to implement your suggestion but it would be a bigger change than I thought. I'm going to ask some questions on Zulip once I get some time to summarize them!
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.
Switching to waiting on author then :) Feel free to request a review when ready, thanks!
@rustbot author
☔ The latest upstream changes (presumably #105486) made this pull request unmergeable. Please resolve the merge conflicts. |
@JohnTitor any updates on this pr? |
Totally forgot about this PR, sorry! Since the branch is quite old and I'm not sure when I have time to work on this, I'm going to close for now. |
No worries. Thanks for the update |
Fixes #93122