Skip to content

Conversation

xizheyin
Copy link
Member

@xizheyin xizheyin commented Jul 21, 2025

Fixes #139050

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 21, 2025
@xizheyin xizheyin changed the title 139050 Supress swapping lhs and rhs in equality suggestion in extern macro Jul 21, 2025
@compiler-errors
Copy link
Member

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.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2025
@xizheyin xizheyin force-pushed the 139050 branch 2 times, most recently from 2ec2014 to 749762a Compare July 21, 2025 16:16
Copy link
Member Author

@xizheyin xizheyin left a 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;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I checked both.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 21, 2025
@xizheyin
Copy link
Member Author

I submitted #144268. We can find the correct span with the newly added methods, thus not needing to suppress this suggestion.

Copy link
Member Author

@xizheyin xizheyin left a 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

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

r? compiler


use std::fmt::Debug;

macro_rules! eq_local {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should fix these whitespace issues in the first commit.

@nnethercote
Copy link
Contributor

This seems like it's doing what's it's supposed to. But it's papering over a problem, which is that the suggestion to switch the argument is incorrect -- it doesn't fix the problem. And this suggestion seems to be a new one. I don't get it in rust 1.89.0. It would be better if the suggestion wasn't given at all...

@nnethercote nnethercote added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2025
@Dylan-DPC
Copy link
Member

@xizheyin any updates on this? thanks

@rustbot
Copy link
Collaborator

rustbot commented Oct 4, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@xizheyin
Copy link
Member Author

xizheyin commented Oct 4, 2025

Sorry for slow response! @Dylan-DPC @nnethercote :)

I revised the code. My initial thinking was to provide different and more precise suggestions for user-written external libraries. However, for a minimal change, directly suppressing it is also a good approach.

In this version, I directly suppressed the lhs and rhs from external macros because we cannot obtain precise spans.

Additionally, I fixed the formatting issues in the first commit proposed by @nnethercote .

@xizheyin xizheyin added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading compiler suggestion: Swapp the equality in rustlib due to mismatched types in user code
6 participants