about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-09-30 23:38:25 +0200
committerGitHub <noreply@github.com>2022-09-30 23:38:25 +0200
commit9ec772e2230ad0bba99115408822253a24272150 (patch)
tree1ec53ccc9a292c9a972c57e2731e547e8453fafc /compiler/rustc_errors/src
parentc07ebeb74bdcc61a432c873035a0623df5465894 (diff)
parente8f1bfe1937c51c1a408c98cf810d10ead454314 (diff)
downloadrust-9ec772e2230ad0bba99115408822253a24272150.tar.gz
rust-9ec772e2230ad0bba99115408822253a24272150.zip
Rollup merge of #102373 - Nilstrieb:cannot-get-layout-of-branch-error, r=cjgillot
Flush delayed bugs before codegen

Sometimes it can happen that invalid code like a TyKind::Error makes its way through the compiler without triggering any errors (this is always a bug in rustc but bugs do happen sometimes :)). These ICEs will manifest in the backend like as cg_llvm not being able to get the layout of `[type error]`, which makes it hard to debug. By flushing before codegen, we display all the delayed bugs, making it easier to trace it to the root of the problem.

I tried this on #102366 and it showed tons of of delayed bugs and no error in cg_llvm, so it seems to be working.
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/lib.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index d3effb7c1c0..a27c88a2a41 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1134,6 +1134,12 @@ impl Handler {
         );
         std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations)
     }
+
+    pub fn flush_delayed(&self) {
+        let mut inner = self.inner.lock();
+        let bugs = std::mem::replace(&mut inner.delayed_span_bugs, Vec::new());
+        inner.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued");
+    }
 }
 
 impl HandlerInner {