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
@nnethercote
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 13, 2025

📌 Commit 94d6601 has been approved by nnethercote

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 13, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 13, 2025
Supress swapping lhs and rhs in equality suggestion in extern macro

Fixes rust-lang#139050
bors added a commit that referenced this pull request Oct 13, 2025
Rollup of 7 pull requests

Successful merges:

 - #144266 (Supress swapping lhs and rhs in equality suggestion in extern macro )
 - #147471 (Assert that non-extended temporaries and `super let` bindings have scopes)
 - #147533 (Renumber return local after state transform)
 - #147566 (rewrite outlives placeholder constraints to outlives static when handling opaque types)
 - #147613 (Make logging filters work again by moving EnvFilter into its own layer)
 - #147615 (reduce calls to attr.span() in old doc attr parsing)
 - #147636 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8521985 into rust-lang:master Oct 13, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 13, 2025
rust-timer added a commit that referenced this pull request Oct 13, 2025
Rollup merge of #144266 - xizheyin:139050, r=nnethercote

Supress swapping lhs and rhs in equality suggestion in extern macro

Fixes #139050
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Oct 15, 2025
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#144266 (Supress swapping lhs and rhs in equality suggestion in extern macro )
 - rust-lang/rust#147471 (Assert that non-extended temporaries and `super let` bindings have scopes)
 - rust-lang/rust#147533 (Renumber return local after state transform)
 - rust-lang/rust#147566 (rewrite outlives placeholder constraints to outlives static when handling opaque types)
 - rust-lang/rust#147613 (Make logging filters work again by moving EnvFilter into its own layer)
 - rust-lang/rust#147615 (reduce calls to attr.span() in old doc attr parsing)
 - rust-lang/rust#147636 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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

7 participants