Skip to content

Conversation

@jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Jan 2, 2026

Fixes #149692.

On beta after #146978, we ICE on

macro_rules! m {
    ($id:item()) => {}
}

m!(Self());

where Self in the macro invocation is a keyword not a "normal" identifier, while attempting to recover an missing keyword before an identifier. Except, Self is a keyword, so trying to parse that as a non-reserved identifier expectedly fails.

I suspect #146978 merely unmasked a possible code path to hit this case; this logic has been so for a good while. Previously, on stable, the error message looks something like

error: expected identifier, found keyword `Self`
 --> src/lib.rs:5:4
  |
5 | m!(Self());
  |    ^^^^ expected identifier, found keyword

error: missing `fn` or `struct` for function or struct definition
 --> src/lib.rs:5:4
  |
2 |     ($id:item()) => {}
  |      -------- while parsing argument for this `item` macro fragment
...
5 | m!(Self());
  |    ^^^^
  |
help: if you meant to call a macro, try
  |
5 | m!(Self!());
  |        +

I considered restoring this diagnostic, but I'm not super convinced it's worth the complexity (and to me, it's not super clear what the user actually intended here).

There's no sensible recovery scheme here, giving up the recovery is the
right thing to do.
@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 Jan 2, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 2, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 2, 2026

Hm actually wait the previous error message does make sense, it's just the suggestion, let me see.

EDIT: hm, not very convinced it's worth it.

@jieyouxu jieyouxu marked this pull request as draft January 2, 2026 09:53
@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 Jan 2, 2026
@jieyouxu jieyouxu marked this pull request as ready for review January 2, 2026 10:31
@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 Jan 2, 2026
@petrochenkov
Copy link
Contributor

@bors r+

@rust-bors rust-bors bot 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 Jan 14, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 14, 2026

📌 Commit 79c4727 has been approved by petrochenkov

It is now in the queue for this repository.

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.

ICE parse_expected_identifier_found_keyword_str

3 participants