Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 072c157

Browse files
committed
Introduce DiagCtxt::struct_bug.
This makes `DiagCtxt::bug` look like the other similar functions.
1 parent 9ed8733 commit 072c157

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,13 @@ impl DiagCtxt {
961961
DiagnosticBuilder::new(self, Level::Note, msg)
962962
}
963963

964+
/// Construct a builder at the `Bug` level with the `msg`.
965+
#[rustc_lint_diagnostics]
966+
#[track_caller]
967+
pub fn struct_bug(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, BugAbort> {
968+
DiagnosticBuilder::new(self, Level::Bug, msg)
969+
}
970+
964971
#[rustc_lint_diagnostics]
965972
#[track_caller]
966973
pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
@@ -1104,8 +1111,9 @@ impl DiagCtxt {
11041111
self.struct_note(msg).emit()
11051112
}
11061113

1114+
#[rustc_lint_diagnostics]
11071115
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {
1108-
DiagnosticBuilder::<BugAbort>::new(self, Bug, msg).emit()
1116+
self.struct_bug(msg).emit()
11091117
}
11101118

11111119
#[inline]

compiler/rustc_expand/src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,7 @@ impl<'a> ExtCtxt<'a> {
11591159
// Fixme: does this result in errors?
11601160
self.expansions.clear();
11611161
}
1162+
#[rustc_lint_diagnostics]
11621163
pub fn bug(&self, msg: &'static str) -> ! {
11631164
self.sess.dcx().bug(msg);
11641165
}

0 commit comments

Comments
 (0)