Remove DiagCtxtInner::span_bug.

`DiagCtxt::span_bug` is different to the other `DiagCtxt::span_*`
methods. This commit makes it the same, which requires changing
`DiagCtxt::span_delayed_bug` to not do everything within the
`inner.borrow_mut()`.
This commit is contained in:
Nicholas Nethercote 2023-12-20 10:43:16 +11:00
parent 1502596ca2
commit 1f08bfa383

View file

@ -978,7 +978,7 @@ impl DiagCtxt {
} }
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! { pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
self.inner.borrow_mut().span_bug(span, msg) self.struct_span_bug(span, msg).emit()
} }
/// For documentation on this, see `Session::span_delayed_bug`. /// For documentation on this, see `Session::span_delayed_bug`.
@ -991,14 +991,14 @@ impl DiagCtxt {
sp: impl Into<MultiSpan>, sp: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>, msg: impl Into<DiagnosticMessage>,
) -> ErrorGuaranteed { ) -> ErrorGuaranteed {
let mut inner = self.inner.borrow_mut(); let treat_next_err_as_bug = self.inner.borrow().treat_next_err_as_bug();
if inner.treat_next_err_as_bug() { if treat_next_err_as_bug {
// FIXME: don't abort here if report_delayed_bugs is off // FIXME: don't abort here if report_delayed_bugs is off
inner.span_bug(sp, msg); self.span_bug(sp, msg);
} }
let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg); let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg);
diagnostic.set_span(sp); diagnostic.set_span(sp);
inner.emit_diagnostic(diagnostic).unwrap() self.emit_diagnostic(diagnostic).unwrap()
} }
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's // FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
@ -1528,14 +1528,6 @@ impl DiagCtxtInner {
self.err_count > 0 self.err_count > 0
} }
#[track_caller]
fn span_bug(&mut self, sp: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
let mut diag = Diagnostic::new(Bug, msg);
diag.set_span(sp);
self.emit_diagnostic(diag);
panic::panic_any(ExplicitBug);
}
fn failure_note(&mut self, msg: impl Into<DiagnosticMessage>) { fn failure_note(&mut self, msg: impl Into<DiagnosticMessage>) {
self.emit_diagnostic(Diagnostic::new(FailureNote, msg)); self.emit_diagnostic(Diagnostic::new(FailureNote, msg));
} }