From 79c47278f1ec8198cb8c0ed53eda46fc43b16a0d Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Fri, 2 Jan 2026 17:27:35 +0800 Subject: [PATCH] Don't try to recover keyword as non-keyword identifier There's no sensible recovery scheme here, giving up the recovery is the right thing to do. --- compiler/rustc_parse/src/parser/item.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 26f60c96aed6..ea713b3cdade 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -408,6 +408,7 @@ impl<'a> Parser<'a> { let insert_span = ident_span.shrink_to_lo(); let ident = if self.token.is_ident() + && self.token.is_non_reserved_ident() && (!is_const || self.look_ahead(1, |t| *t == token::OpenParen)) && self.look_ahead(1, |t| { matches!(t.kind, token::Lt | token::OpenBrace | token::OpenParen)