Files
rust/tests/ui/parser
Jonathan Brouwer 9ef76797ea Rollup merge of #150590 - ident-kw-ice, r=petrochenkov
Don't try to recover keyword as non-keyword identifier

Fixes rust-lang/rust#149692.

On beta after rust-lang/rust#146978, we ICE on

```rs
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 rust-lang/rust#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

```rs
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).
2026-01-14 22:29:56 +01:00
..
2025-04-03 21:41:58 +00:00
2025-12-10 20:31:10 +03:00
2025-12-10 23:41:19 +00:00
2025-11-08 04:51:33 +01:00
2024-12-10 11:34:13 +08:00
2025-08-28 20:05:04 +02:00
2025-08-28 20:05:04 +02:00
2023-05-05 21:44:48 +02:00
2023-05-05 21:44:48 +02:00
2025-07-25 20:38:54 +05:00
2024-11-16 20:03:31 +00:00
2025-07-31 21:25:49 +05:00
2023-05-05 11:17:14 -04:00
2025-09-15 10:48:26 -07:00
2024-10-11 11:30:08 -04:00
2025-08-09 16:27:20 +05:00
2024-11-29 06:10:15 +11:00
2024-04-21 15:43:43 -03:00
2024-04-21 15:43:43 -03:00
2024-04-21 15:43:43 -03:00
2024-04-21 15:43:43 -03:00
2025-01-07 16:04:14 +01:00
2025-01-07 16:04:14 +01:00
2025-10-01 22:45:16 +02:00
2023-10-04 01:35:07 +00:00
2023-10-04 01:35:07 +00:00
2025-07-01 15:29:29 +05:00
2025-04-25 17:02:59 +05:00
2024-11-24 19:42:33 +01:00
2024-11-24 19:42:33 +01:00
2025-11-27 14:13:58 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2023-01-19 02:25:55 +00:00
2025-12-02 18:25:13 +00:00
2025-11-27 11:19:00 -05:00
2025-12-02 18:25:13 +00:00