Skip to content

Commit ec2db0e

Browse files
committed
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()`.
1 parent 2fc3160 commit ec2db0e

File tree

1 file changed

+5
-13
lines changed
  • compiler/rustc_errors/src

1 file changed

+5
-13
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ impl DiagCtxt {
978978
}
979979

980980
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
981-
self.inner.borrow_mut().span_bug(span, msg)
981+
self.struct_span_bug(span, msg).emit()
982982
}
983983

984984
/// For documentation on this, see `Session::span_delayed_bug`.
@@ -991,14 +991,14 @@ impl DiagCtxt {
991991
sp: impl Into<MultiSpan>,
992992
msg: impl Into<DiagnosticMessage>,
993993
) -> ErrorGuaranteed {
994-
let mut inner = self.inner.borrow_mut();
995-
if inner.treat_next_err_as_bug() {
994+
let treat_next_err_as_bug = self.inner.borrow().treat_next_err_as_bug();
995+
if treat_next_err_as_bug {
996996
// FIXME: don't abort here if report_delayed_bugs is off
997-
inner.span_bug(sp, msg);
997+
self.span_bug(sp, msg);
998998
}
999999
let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg);
10001000
diagnostic.set_span(sp);
1001-
inner.emit_diagnostic(diagnostic).unwrap()
1001+
self.emit_diagnostic(diagnostic).unwrap()
10021002
}
10031003

10041004
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
@@ -1528,14 +1528,6 @@ impl DiagCtxtInner {
15281528
self.err_count > 0
15291529
}
15301530

1531-
#[track_caller]
1532-
fn span_bug(&mut self, sp: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
1533-
let mut diag = Diagnostic::new(Bug, msg);
1534-
diag.set_span(sp);
1535-
self.emit_diagnostic(diag);
1536-
panic::panic_any(ExplicitBug);
1537-
}
1538-
15391531
fn failure_note(&mut self, msg: impl Into<DiagnosticMessage>) {
15401532
self.emit_diagnostic(Diagnostic::new(FailureNote, msg));
15411533
}

0 commit comments

Comments
 (0)