From 88453aaccfe308a30a30dc4dee95fe51edc367e0 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Wed, 29 Nov 2023 18:45:36 +0000 Subject: Avoid unnecessary pattern parse errors on `ref box` --- compiler/rustc_parse/src/parser/pat.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index ec7c312d03f..3d1d1ec8108 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -391,10 +391,10 @@ impl<'a> Parser<'a> { self.parse_pat_ident_mut(syntax_loc)? } else if self.eat_keyword(kw::Ref) { if self.check_keyword(kw::Box) { - // Suggest `box ref` and quit parsing pattern to prevent series of - // misguided diagnostics from later stages of the compiler. + // Suggest `box ref`. let span = self.prev_token.span.to(self.token.span); - return Err(self.sess.create_err(SwitchRefBoxOrder { span })); + self.bump(); + self.sess.emit_err(SwitchRefBoxOrder { span }); } // Parse ref ident @ pat / ref mut ident @ pat let mutbl = self.parse_mutability(); -- cgit 1.4.1-3-g733a5