Skip to content

Commit 91722d3

Browse files
committed
Inline and remove Handler::span_bug_no_panic.
It's needed for a single weird case. Let's not encourage any more behaviour like this.
1 parent e3b7ecc commit 91722d3

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,6 @@ impl Handler {
10761076
inner.good_path_delayed_bugs.push(DelayedDiagnostic::with_backtrace(diagnostic, backtrace));
10771077
}
10781078

1079-
#[track_caller]
1080-
pub fn span_bug_no_panic(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
1081-
self.emit_diag_at_span(Diagnostic::new(Bug, msg), span);
1082-
}
1083-
10841079
#[track_caller]
10851080
#[rustc_lint_diagnostics]
10861081
pub fn span_note(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use crate::expectation::Expectation;
5252
use crate::fn_ctxt::RawTy;
5353
use crate::gather_locals::GatherLocalsVisitor;
5454
use rustc_data_structures::unord::UnordSet;
55-
use rustc_errors::{struct_span_err, DiagnosticId, ErrorGuaranteed, MultiSpan};
55+
use rustc_errors::{struct_span_err, Diagnostic, DiagnosticId, ErrorGuaranteed, Level};
5656
use rustc_hir as hir;
5757
use rustc_hir::def::{DefKind, Res};
5858
use rustc_hir::intravisit::Visitor;
@@ -414,10 +414,12 @@ enum TupleArgumentsFlag {
414414

415415
fn fatally_break_rust(tcx: TyCtxt<'_>) {
416416
let handler = tcx.sess.diagnostic();
417-
handler.span_bug_no_panic(
418-
MultiSpan::new(),
417+
// We normally use `handler.bug()` for bugs, but this is an exceptional case, so we do this
418+
// instead to avoid an abort.
419+
handler.emit_diagnostic(&mut Diagnostic::new(
420+
Level::Bug,
419421
"It looks like you're trying to break rust; would you like some ICE?",
420-
);
422+
));
421423
handler.note("the compiler expectedly panicked. this is a feature.");
422424
handler.note(
423425
"we would appreciate a joke overview: \

0 commit comments

Comments
 (0)