Skip to content

Do not suggest compatible variants inside macro #142611

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xizheyin
Copy link
Contributor

@xizheyin xizheyin commented Jun 17, 2025

Fixes #142359

r? compiler

@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 Jun 17, 2025
@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 23, 2025

The test doesn't seem to actually reproduce the issue that this fixes? It never suggested to modify std in the first commit. What's up with that

@xizheyin
Copy link
Contributor Author

This may be because #139316 (comment).

@xizheyin
Copy link
Contributor Author

r? compiler

@rustbot rustbot assigned compiler-errors and unassigned BoxyUwU Jul 15, 2025
@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 16, 2025
Copy link
Contributor 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.

@rustbot ready

Comment on lines 2423 to +2426
while let hir::ExprKind::Block(block, _) = &expr.kind
&& let Some(expr_) = &block.expr
// Only traverse blocks in same context
&& expr_.span.eq_ctxt(expr.span)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This time, I find the deepest expression in the block tree while staying within the same context. This ensures that suggestions point to user-visible code.

@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 20, 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.

Incorrect suggestion for incompatible match arm types
4 participants