about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-11-28 14:47:21 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-12-06 18:42:31 +0000
commit618d4c3eeb9a9f410f35b666e8b929056f820987 (patch)
tree1692bcdb0f7315280949aa7745ad3eb9adb5f5b5 /compiler/rustc_errors/src
parent401dd840ff301f13c4006132cc4e4eb80e9702eb (diff)
downloadrust-618d4c3eeb9a9f410f35b666e8b929056f820987.tar.gz
rust-618d4c3eeb9a9f410f35b666e8b929056f820987.zip
Handle unwinding out of the closure argument of run_compiler with pending delayed bugs
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/lib.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 8eb55e30847..6232c875ee8 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -622,9 +622,7 @@ impl Drop for DiagCtxtInner {
         // Important: it is sound to produce an `ErrorGuaranteed` when emitting
         // delayed bugs because they are guaranteed to be emitted here if
         // necessary.
-        if self.err_guars.is_empty() {
-            self.flush_delayed()
-        }
+        self.flush_delayed();
 
         // Sanity check: did we use some of the expensive `trimmed_def_paths` functions
         // unexpectedly, that is, without producing diagnostics? If so, for debugging purposes, we
@@ -1705,7 +1703,13 @@ impl DiagCtxtInner {
         // eventually happened.
         assert!(self.stashed_diagnostics.is_empty());
 
+        if !self.err_guars.is_empty() {
+            // If an error happened already. We shouldn't expose delayed bugs.
+            return;
+        }
+
         if self.delayed_bugs.is_empty() {
+            // Nothing to do.
             return;
         }