From 3ab05caa4d196340dd61ce10543f64cb56878676 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 4 Dec 2023 14:48:11 +1100 Subject: [PATCH] Make `Handler::{err,bug}` more like `Handler::{warn,note}`. --- compiler/rustc_errors/src/lib.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 11ac5239445..e6faefa612f 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1096,10 +1096,7 @@ pub fn fatal(&self, msg: impl Into) -> ! { #[rustc_lint_diagnostics] pub fn err(&self, msg: impl Into) -> ErrorGuaranteed { - self.inner - .borrow_mut() - .emit_diagnostic(&mut Diagnostic::new(Error { lint: false }, msg)) - .unwrap() + DiagnosticBuilder::::new(self, Error { lint: false }, msg).emit() } #[rustc_lint_diagnostics] @@ -1113,7 +1110,8 @@ pub fn note(&self, msg: impl Into) { } pub fn bug(&self, msg: impl Into) -> ! { - self.inner.borrow_mut().bug(msg) + DiagnosticBuilder::::new(self, Bug, msg).emit(); + panic::panic_any(ExplicitBug); } #[inline] @@ -1601,11 +1599,6 @@ fn fatal_no_raise(&mut self, msg: impl Into) -> FatalError { FatalError } - fn bug(&mut self, msg: impl Into) -> ! { - self.emit_diagnostic(&mut Diagnostic::new(Bug, msg)); - panic::panic_any(ExplicitBug); - } - fn flush_delayed( &mut self, bugs: impl IntoIterator,