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-12-12 12:19:09 +01:00
2025-08-18 21:57:11 +08:00
2025-12-25 20:56:03 +00:00
2025-12-10 20:31:10 +03:00
2026-01-02 17:26:41 +08:00
2025-12-03 18:09:40 +00:00
2025-12-10 23:41:19 +00:00
2026-01-05 12:31:42 +08:00
2025-11-08 04:51:33 +01:00
2025-11-24 19:36:20 +08:00
2025-12-02 18:25:13 +00:00
2025-12-10 23:41:19 +00:00
2025-12-10 23:41:19 +00:00
2025-08-05 07:10:31 +05:00
2025-12-10 23:41:19 +00:00
2025-12-10 23:41:19 +00:00
2025-06-13 18:13:34 +02:00
2025-06-13 18:13:34 +02:00
2025-06-13 18:13:34 +02:00
2025-08-28 20:05:04 +02:00
2025-08-28 20:05:04 +02:00
2025-07-15 12:00:46 +08:00
2025-11-08 04:51:33 +01:00
2025-06-11 17:11:58 +02:00
2025-06-11 17:11:58 +02:00
2025-06-03 13:28:38 +02:00
2025-06-26 13:46:45 +00:00
2025-06-29 04:56:28 +02:00
2025-04-18 15:57:29 +02:00
2025-12-16 02:10:08 +09:00
2025-12-16 02:10:08 +09:00
2025-12-10 23:41:19 +00:00
2025-10-11 21:59:51 -04:00
2025-10-11 21:59:51 -04:00
2025-04-17 19:45:28 +08:00
2025-12-02 18:25:13 +00:00
2025-08-11 16:58:21 -05:00
2025-08-11 16:58:21 -05:00
2025-04-18 15:57:29 +02:00
2025-07-18 20:34:58 +08:00
2025-07-18 20:34:58 +08:00
2025-05-07 22:56:14 +08:00
2025-05-07 22:56:14 +08:00
2025-04-30 10:44:24 +03:00
2025-04-30 10:44:24 +03:00
2025-06-16 23:07:11 +08:00
2025-06-16 23:07:11 +08:00
2025-07-05 00:45:24 +05:00
2025-07-25 20:38:54 +05:00
2025-06-03 11:45:58 +02:00
2025-12-02 18:25:13 +00:00
2025-12-09 17:29:23 +00:00
2025-07-31 21:25:49 +05:00
2025-09-02 00:02:16 +00:00
2025-09-02 00:02:16 +00:00
2025-09-15 10:48:26 -07:00
2025-08-31 01:43:57 +00:00
2025-08-31 01:43:57 +00:00
2025-04-22 00:53:12 +05:00
2025-04-22 00:53:12 +05:00
2025-04-22 00:53:12 +05:00
2025-04-22 00:53:12 +05:00
2025-04-22 00:53:12 +05:00
2025-06-03 11:45:58 +02:00
2025-08-07 21:39:00 +00:00
2025-05-03 22:49:23 +03:00
2025-05-03 22:49:23 +03:00
2025-06-03 11:45:58 +02:00
2025-12-02 18:25:13 +00:00
2025-08-09 16:27:20 +05:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-11-08 07:37:15 +01:00
2025-10-18 21:17:48 +02:00
2025-10-18 21:17:48 +02:00
2025-07-10 18:47:20 +05:00
2025-10-11 20:50:21 +00:00
2025-10-11 20:50:21 +00:00
2025-10-11 20:50:21 +00:00
2025-09-12 14:45:12 -04:00
2025-09-12 14:45:12 -04:00
2025-08-14 21:31:47 +08:00
2025-08-14 21:31:47 +08:00
2025-12-10 23:41:19 +00:00
2025-11-28 20:02:38 +01:00
2025-04-10 09:56:37 +02:00
2025-12-09 17:29:23 +00:00
2025-10-31 18:24:10 +00:00
2025-10-31 18:24:10 +00:00
2025-10-31 18:24:10 +00:00
2025-08-14 21:31:47 +08:00
2025-05-16 12:40:04 +02:00
2025-05-16 12:40:04 +02:00
2025-05-16 12:40:04 +02:00
2025-10-01 22:45:16 +02:00
2025-10-02 20:24:34 +02:00
2025-12-23 21:13:24 +09:00
2025-12-23 21:13:24 +09:00
2025-06-30 11:23:01 +05:00
2025-04-30 10:44:24 +03:00
2025-04-30 10:44:24 +03:00
2025-07-01 15:29:29 +05:00
2025-08-14 21:31:47 +08:00
2025-04-25 17:02:59 +05:00
2025-04-25 17:02:59 +05:00
2025-04-25 17:02:59 +05:00
2025-11-24 19:36:20 +08:00
2025-11-24 19:36:20 +08:00
2025-08-27 00:23:26 -04:00
2025-08-14 21:31:47 +08:00
2025-05-09 15:31:27 +00:00
2025-10-11 21:59:51 -04:00
2025-06-03 11:45:58 +02:00
2025-06-03 11:45:58 +02:00
2025-06-28 17:04:16 +05:00
2025-08-22 13:16:44 +08:00
2025-08-22 13:16:44 +08:00
2025-04-18 15:57:29 +02:00
2025-04-18 15:57:29 +02:00
2025-12-22 13:55:49 +00:00
2025-08-14 21:31:36 +08:00
2025-08-14 21:31:47 +08:00
2025-07-13 00:03:31 +05:00
2025-05-14 13:32:59 +01:00
2025-05-14 13:32:59 +01:00
2025-06-03 13:28:38 +02:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-07-01 19:00:21 +00:00
2025-07-01 19:00:21 +00:00
2025-08-16 16:15:58 +02:00
2025-08-16 16:15:58 +02:00
2025-08-16 16:15:58 +02:00
2025-11-27 14:13:58 -05: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
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-09-26 15:33:48 +02:00
2025-09-26 15:33:48 +02:00
2025-08-18 21:57:11 +08:00
2025-08-18 21:57:11 +08:00
2025-12-10 23:41:19 +00:00
2025-09-24 21:31:23 +00:00
2025-09-24 21:31:23 +00:00
2025-07-31 13:55:59 +08:00
2025-07-05 03:46:08 +05:00
2025-07-05 03:46:08 +05:00
2025-07-05 03:46:08 +05:00
2025-12-23 21:13:24 +09:00
2025-12-23 21:13:24 +09:00
2025-07-23 13:48:04 +02:00
2025-05-27 15:57:41 +00:00
2025-05-27 15:57:41 +00:00
2025-06-30 11:50:19 +05:00
2025-06-30 11:23:01 +05:00
2025-10-11 21:59:51 -04:00
2025-10-11 21:59:51 -04:00
2025-12-02 18:25:13 +00:00
2025-12-02 18:25:13 +00:00
2025-04-13 21:48:53 +03:00
2025-04-13 21:48:53 +03:00
2025-12-04 10:51:34 +01:00
2025-12-04 10:51:34 +01:00
2025-11-10 14:33:56 +01:00
2025-11-27 11:19:00 -05:00
2025-12-02 18:25:13 +00:00