From 50ca5ef07f893d5bd797c2b35f51f0ed301605c0 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Fri, 13 Oct 2023 22:43:48 +0000 Subject: When encountering unclosed delimiters during parsing, check for diff markers Fix #116252. --- compiler/rustc_parse/src/parser/diagnostics.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 7b5bb319ed8..2a8eb6edd23 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -2808,8 +2808,15 @@ impl<'a> Parser<'a> { } pub fn recover_diff_marker(&mut self) { + if let Err(mut err) = self.err_diff_marker() { + err.emit(); + FatalError.raise(); + } + } + + pub fn err_diff_marker(&mut self) -> PResult<'a, ()> { let Some(start) = self.diff_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt) else { - return; + return Ok(()); }; let mut spans = Vec::with_capacity(3); spans.push(start); @@ -2856,8 +2863,7 @@ impl<'a> Parser<'a> { "for an explanation on these markers from the `git` documentation, visit \ ", ); - err.emit(); - FatalError.raise() + Err(err) } /// Parse and throw away a parenthesized comma separated -- cgit 1.4.1-3-g733a5