about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-10-13 22:43:48 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-10-30 00:56:46 +0000
commit50ca5ef07f893d5bd797c2b35f51f0ed301605c0 (patch)
treec55c714d1089830a04a7f7b83bf1fdf97c867b22 /compiler/rustc_parse/src/parser
parent608e9682f0a6482903de8d3332770104a0ad943c (diff)
downloadrust-50ca5ef07f893d5bd797c2b35f51f0ed301605c0.tar.gz
rust-50ca5ef07f893d5bd797c2b35f51f0ed301605c0.zip
When encountering unclosed delimiters during parsing, check for diff markers
Fix #116252.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs12
1 files changed, 9 insertions, 3 deletions
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 \
              <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
         );
-        err.emit();
-        FatalError.raise()
+        Err(err)
     }
 
     /// Parse and throw away a parenthesized comma separated