Handle unwinding out of the closure argument of run_compiler with pending delayed bugs

This commit is contained in:
bjorn3 2024-11-28 14:47:21 +00:00
parent 401dd840ff
commit 618d4c3eeb
2 changed files with 24 additions and 17 deletions

View file

@ -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;
}