Skip to content

Commit b0d5b44

Browse files
committed
Avoid DiagnosticBuilder::<T>::new calls.
The `Handler` functions that directly emit diagnostics can be more easily implemented using `struct_foo(msg).emit()`. This mirrors `Handler::emit_err` which just does `create_err(err).emit()`. `Handler::bug` is not converted because of weirdness involving conflation bugs and fatal errors with `EmissionGuarantee`. I'll fix that later.
1 parent 19d28a4 commit b0d5b44

File tree

1 file changed

+4
-4
lines changed
  • compiler/rustc_errors/src

1 file changed

+4
-4
lines changed

compiler/rustc_errors/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1101,22 +1101,22 @@ impl Handler {
11011101

11021102
#[rustc_lint_diagnostics]
11031103
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
1104-
DiagnosticBuilder::<FatalError>::new(self, Fatal, msg).emit().raise()
1104+
self.struct_fatal(msg).emit()
11051105
}
11061106

11071107
#[rustc_lint_diagnostics]
11081108
pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
1109-
DiagnosticBuilder::<ErrorGuaranteed>::new(self, Error { lint: false }, msg).emit()
1109+
self.struct_err(msg).emit()
11101110
}
11111111

11121112
#[rustc_lint_diagnostics]
11131113
pub fn warn(&self, msg: impl Into<DiagnosticMessage>) {
1114-
DiagnosticBuilder::<()>::new(self, Warning(None), msg).emit();
1114+
self.struct_warn(msg).emit()
11151115
}
11161116

11171117
#[rustc_lint_diagnostics]
11181118
pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
1119-
DiagnosticBuilder::<()>::new(self, Note, msg).emit();
1119+
self.struct_note(msg).emit()
11201120
}
11211121

11221122
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {

0 commit comments

Comments
 (0)