Skip to content

Commit 19d28a4

Browse files
committed
Change msg: impl Into<String> for bug diagnostics.
To `msg: impl Into<DiagnosticMessage>`, like all the other diagnostics. For consistency.
1 parent e3b7ecc commit 19d28a4

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

compiler/rustc_errors/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ impl Handler {
10331033
self.emit_diag_at_span(Diagnostic::new_with_code(Warning(None), Some(code), msg), span);
10341034
}
10351035

1036-
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<String>) -> ! {
1036+
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
10371037
self.inner.borrow_mut().span_bug(span, msg)
10381038
}
10391039

@@ -1045,7 +1045,7 @@ impl Handler {
10451045
pub fn span_delayed_bug(
10461046
&self,
10471047
sp: impl Into<MultiSpan>,
1048-
msg: impl Into<String>,
1048+
msg: impl Into<DiagnosticMessage>,
10491049
) -> ErrorGuaranteed {
10501050
let mut inner = self.inner.borrow_mut();
10511051

@@ -1056,10 +1056,10 @@ impl Handler {
10561056
inner.err_count + inner.lint_err_count + inner.delayed_bug_count() + 1 >= c.get()
10571057
}) {
10581058
// FIXME: don't abort here if report_delayed_bugs is off
1059-
inner.span_bug(sp, msg.into());
1059+
inner.span_bug(sp, msg);
10601060
}
1061-
let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg.into());
1062-
diagnostic.set_span(sp.into());
1061+
let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg);
1062+
diagnostic.set_span(sp);
10631063
inner.emit_diagnostic(&mut diagnostic).unwrap()
10641064
}
10651065

@@ -1589,8 +1589,8 @@ impl HandlerInner {
15891589
}
15901590

15911591
#[track_caller]
1592-
fn span_bug(&mut self, sp: impl Into<MultiSpan>, msg: impl Into<String>) -> ! {
1593-
self.emit_diagnostic(Diagnostic::new(Bug, msg.into()).set_span(sp));
1592+
fn span_bug(&mut self, sp: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
1593+
self.emit_diagnostic(Diagnostic::new(Bug, msg).set_span(sp));
15941594
panic::panic_any(ExplicitBug);
15951595
}
15961596

compiler/rustc_expand/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ impl<'a> ExtCtxt<'a> {
11451145
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
11461146
self.sess.diagnostic().span_err(sp, msg);
11471147
}
1148-
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<String>) -> ! {
1148+
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
11491149
self.sess.diagnostic().span_bug(sp, msg);
11501150
}
11511151
pub fn trace_macros_diag(&mut self) {

compiler/rustc_middle/src/ty/sty.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use hir::def::DefKind;
1515
use polonius_engine::Atom;
1616
use rustc_data_structures::captures::Captures;
1717
use rustc_data_structures::intern::Interned;
18-
use rustc_errors::{DiagnosticArgValue, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan};
18+
use rustc_errors::{
19+
DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan,
20+
};
1921
use rustc_hir as hir;
2022
use rustc_hir::def_id::DefId;
2123
use rustc_hir::LangItem;
@@ -2005,7 +2007,7 @@ impl<'tcx> Ty<'tcx> {
20052007
pub fn new_error_with_message<S: Into<MultiSpan>>(
20062008
tcx: TyCtxt<'tcx>,
20072009
span: S,
2008-
msg: impl Into<String>,
2010+
msg: impl Into<DiagnosticMessage>,
20092011
) -> Ty<'tcx> {
20102012
let reported = tcx.sess.span_delayed_bug(span, msg);
20112013
Ty::new(tcx, Error(reported))

compiler/rustc_parse/src/parser/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ impl<'a> Parser<'a> {
249249
self.diagnostic().struct_span_err(sp, m)
250250
}
251251

252-
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: impl Into<String>) -> ! {
253-
self.diagnostic().span_bug(sp, m)
252+
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
253+
self.diagnostic().span_bug(sp, msg)
254254
}
255255

256256
pub(super) fn diagnostic(&self) -> &'a Handler {

compiler/rustc_session/src/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ impl Session {
632632
pub fn span_delayed_bug<S: Into<MultiSpan>>(
633633
&self,
634634
sp: S,
635-
msg: impl Into<String>,
635+
msg: impl Into<DiagnosticMessage>,
636636
) -> ErrorGuaranteed {
637637
self.diagnostic().span_delayed_bug(sp, msg)
638638
}

0 commit comments

Comments
 (0)