1
Fork 0

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.
This commit is contained in:
Nicholas Nethercote 2023-12-13 16:36:57 +11:00
parent 19d28a4f28
commit b0d5b442e9

View file

@ -1101,22 +1101,22 @@ impl Handler {
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! { pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
DiagnosticBuilder::<FatalError>::new(self, Fatal, msg).emit().raise() self.struct_fatal(msg).emit()
} }
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed { pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
DiagnosticBuilder::<ErrorGuaranteed>::new(self, Error { lint: false }, msg).emit() self.struct_err(msg).emit()
} }
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
pub fn warn(&self, msg: impl Into<DiagnosticMessage>) { pub fn warn(&self, msg: impl Into<DiagnosticMessage>) {
DiagnosticBuilder::<()>::new(self, Warning(None), msg).emit(); self.struct_warn(msg).emit()
} }
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
pub fn note(&self, msg: impl Into<DiagnosticMessage>) { pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
DiagnosticBuilder::<()>::new(self, Note, msg).emit(); self.struct_note(msg).emit()
} }
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! { pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {