From b107ab81adfe0b45a073a5a487c3257c70b34ef6 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Dec 2023 09:56:23 +1100 Subject: [PATCH] Rename `EarlyDiagCtxt::handler` as `EarlyDiagCtxt::dcx`. --- compiler/rustc_session/src/session.rs | 31 ++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 08190e1fff0..6bb4aefd6bd 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1727,52 +1727,52 @@ enum IncrCompSession { /// A wrapper around an [`DiagCtxt`] that is used for early error emissions. pub struct EarlyDiagCtxt { - handler: DiagCtxt, + dcx: DiagCtxt, } impl EarlyDiagCtxt { pub fn new(output: ErrorOutputType) -> Self { let emitter = mk_emitter(output); - Self { handler: DiagCtxt::with_emitter(emitter) } + Self { dcx: DiagCtxt::with_emitter(emitter) } } pub fn abort_if_errors(&self) { - self.handler.abort_if_errors() + self.dcx.abort_if_errors() } - /// Swap out the underlying handler once we acquire the user's preference on error emission + /// Swap out the underlying dcx once we acquire the user's preference on error emission /// format. Any errors prior to that will cause an abort and all stashed diagnostics of the - /// previous handler will be emitted. + /// previous dcx will be emitted. pub fn abort_if_error_and_set_error_format(&mut self, output: ErrorOutputType) { - self.handler.abort_if_errors(); + self.dcx.abort_if_errors(); let emitter = mk_emitter(output); - self.handler = DiagCtxt::with_emitter(emitter); + self.dcx = DiagCtxt::with_emitter(emitter); } #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_note(&self, msg: impl Into) { - self.handler.struct_note(msg).emit() + self.dcx.struct_note(msg).emit() } #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_help(&self, msg: impl Into) { - self.handler.struct_help(msg).emit() + self.dcx.struct_help(msg).emit() } #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] #[must_use = "ErrorGuaranteed must be returned from `run_compiler` in order to exit with a non-zero status code"] pub fn early_error_no_abort(&self, msg: impl Into) -> ErrorGuaranteed { - self.handler.struct_err(msg).emit() + self.dcx.struct_err(msg).emit() } #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_error(&self, msg: impl Into) -> ! { - self.handler.struct_fatal(msg).emit() + self.dcx.struct_fatal(msg).emit() } #[allow(rustc::untranslatable_diagnostic)] @@ -1781,13 +1781,13 @@ pub fn early_struct_error( &self, msg: impl Into, ) -> DiagnosticBuilder<'_, !> { - self.handler.struct_fatal(msg) + self.dcx.struct_fatal(msg) } #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] pub fn early_warn(&self, msg: impl Into) { - self.handler.struct_warn(msg).emit() + self.dcx.struct_warn(msg).emit() } pub fn initialize_checked_jobserver(&self) { @@ -1795,10 +1795,7 @@ pub fn initialize_checked_jobserver(&self) { jobserver::initialize_checked(|err| { #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] - self.handler - .struct_warn(err) - .note("the build environment is likely misconfigured") - .emit() + self.dcx.struct_warn(err).note("the build environment is likely misconfigured").emit() }); } }