about summary refs log tree commit diff
path: root/compiler/rustc_parse
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-01-05 16:38:04 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-01-08 16:07:14 +1100
commit4752a923af2a0e26b2da0861e4a8f1f6c35b6d56 (patch)
tree544820bebe8fe99599e332b614dde5d52e0692f1 /compiler/rustc_parse
parentd406278180f1cd7792f50be890658f2739c621fb (diff)
downloadrust-4752a923af2a0e26b2da0861e4a8f1f6c35b6d56.tar.gz
rust-4752a923af2a0e26b2da0861e4a8f1f6c35b6d56.zip
Remove `DiagnosticBuilder::delay_as_bug_without_consuming`.
The existing uses are replaced in one of three ways.
- In a function that also has calls to `emit`, just rearrange the code
  so that exactly one of `delay_as_bug` or `emit` is called on every
  path.
- In a function returning a `DiagnosticBuilder`, use
  `downgrade_to_delayed_bug`. That's good enough because it will get
  emitted later anyway.
- In `unclosed_delim_err`, one set of errors is being replaced with
  another set, so just cancel the original errors.
Diffstat (limited to 'compiler/rustc_parse')
-rw-r--r--compiler/rustc_parse/src/lexer/mod.rs2
-rw-r--r--compiler/rustc_parse/src/lexer/tokentrees.rs6
-rw-r--r--compiler/rustc_parse/src/parser/pat.rs7
3 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs
index d08f31e69d8..a45bc581240 100644
--- a/compiler/rustc_parse/src/lexer/mod.rs
+++ b/compiler/rustc_parse/src/lexer/mod.rs
@@ -67,7 +67,7 @@ pub(crate) fn parse_token_trees<'a>(
     let (stream, res, unmatched_delims) =
         tokentrees::TokenTreesReader::parse_all_token_trees(string_reader);
     match res {
-        Ok(_open_spacing) if unmatched_delims.is_empty() => Ok(stream),
+        Ok(()) if unmatched_delims.is_empty() => Ok(stream),
         _ => {
             // Return error if there are unmatched delimiters or unclosed delimiters.
             // We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch
diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs
index 72f76cd8975..64b3928689a 100644
--- a/compiler/rustc_parse/src/lexer/tokentrees.rs
+++ b/compiler/rustc_parse/src/lexer/tokentrees.rs
@@ -277,9 +277,9 @@ impl<'a> TokenTreesReader<'a> {
             parser.bump();
         }
         if !diff_errs.is_empty() {
-            errs.iter_mut().for_each(|err| {
-                err.delay_as_bug_without_consuming();
-            });
+            for err in errs {
+                err.cancel();
+            }
             return diff_errs;
         }
         return errs;
diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs
index a6804b99204..00dc307ab60 100644
--- a/compiler/rustc_parse/src/parser/pat.rs
+++ b/compiler/rustc_parse/src/parser/pat.rs
@@ -242,7 +242,7 @@ impl<'a> Parser<'a> {
                 Some(TopLevelOrPatternNotAllowedSugg::WrapInParens { span, pat })
             };
 
-            let mut err = self.dcx().create_err(match syntax_loc {
+            let err = self.dcx().create_err(match syntax_loc {
                 PatternLocation::LetBinding => {
                     TopLevelOrPatternNotAllowed::LetBinding { span, sub }
                 }
@@ -251,9 +251,10 @@ impl<'a> Parser<'a> {
                 }
             });
             if trailing_vert {
-                err.delay_as_bug_without_consuming();
+                err.delay_as_bug();
+            } else {
+                err.emit();
             }
-            err.emit();
         }
 
         Ok((pat, colon))