Skip to content

Commit cfbc1b9

Browse files
committed
Enable creating backtraces via -Ztreat-err-as-bug when stashing errors
1 parent 1b2c53a commit cfbc1b9

File tree

1 file changed

+4
-7
lines changed
  • compiler/rustc_errors/src

1 file changed

+4
-7
lines changed

Diff for: compiler/rustc_errors/src/lib.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -768,13 +768,10 @@ impl DiagCtxt {
768768
format!("invalid level in `stash_diagnostic`: {:?}", diag.level),
769769
);
770770
}
771-
Error => {
772-
// This `unchecked_error_guaranteed` is valid. It is where the
773-
// `ErrorGuaranteed` for stashed errors originates. See
774-
// `DiagCtxtInner::drop`.
775-
#[allow(deprecated)]
776-
Some(ErrorGuaranteed::unchecked_error_guaranteed())
777-
}
771+
// We delay a bug here so that `-Ztreat-err-as-bug -Zeagerly-emit-delayed-bugs`
772+
// can be used to create a backtrace at the stashing site insted of whenever the
773+
// diagnostic context is dropped and thus delayed bugs are emitted.
774+
Error => Some(self.span_delayed_bug(span, "stashing {key:?}")),
778775
DelayedBug => return self.inner.borrow_mut().emit_diagnostic(diag),
779776
ForceWarning(_) | Warning | Note | OnceNote | Help | OnceHelp | FailureNote | Allow
780777
| Expect(_) => None,

0 commit comments

Comments
 (0)