-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Supress swapping lhs and rhs in equality suggestion in extern macro #144266
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
base: master
Are you sure you want to change the base?
Conversation
If the test can't actually demonstrate the change, then there's no reason to make this into two commits. Please squash this into one. |
2ec2014
to
749762a
Compare
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.
Pretty fast review!
@rustbot ready
if rhs_expr.span.in_external_macro(sm) || lhs_expr.span.in_external_macro(sm) { | ||
return; | ||
} | ||
|
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.
Now I checked both.
I submitted #144268. We can find the correct span with the newly added methods, thus not needing to suppress this suggestion. |
Signed-off-by: xizheyin <[email protected]>
Signed-off-by: xizheyin <[email protected]>
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.
Now, we could reproduce the bug.
@rustbot ready
if let Some(rhs_span) = rhs_expr.span.find_ancestor_not_from_extern_macro(sm) | ||
&& let Some(lhs_span) = lhs_expr.span.find_ancestor_not_from_extern_macro(sm) |
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.
If the ==
is from the extern macro, it will find the first ancestor that is not from extern macro by find_ancestor_not_from_extern_macro
.
} else { | ||
// rhs_span and lhs_span are the same because it from extern macro. | ||
// we should suggest to swap two arguments of the equality | ||
err.span_help(rhs_span, "consider swapping two arguments of the equality"); | ||
} |
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.
Itrhs_span
and lhs_span
is the same, it is expand from extern macro, we use span_help
to hint.
The job Click to see the possible cause of the failure (guessed by this bot)
|
Fixes #139050
I have tried to find the initial call point via
find_oldest_ancestor_in_same_ctxt
, but it terminates inside thedebug_assert_eq
macro and doesn't get the span we were expecting.For this reason #139316 (comment) , the test can not show the diff.
I test it locally.
In master branch:
In this branch: