From d5bc581f5db6ba5198ccec45d938422778f56bff Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sun, 30 Apr 2023 02:20:53 +0100 Subject: Migrate `mir_transform` to translatable diagnostics --- compiler/rustc_errors/src/diagnostic_builder.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/rustc_errors') diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index 3064d2bedbe..c8e57aa39af 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -570,6 +570,14 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { Some((diagnostic, handler)) } + /// Retrieves the [`Handler`] if available + pub fn handler(&self) -> Option<&Handler> { + match self.inner.state { + DiagnosticBuilderState::Emittable(handler) => Some(handler), + DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => None, + } + } + /// Buffers the diagnostic for later emission, /// unless handler has disabled such buffering. pub fn buffer(self, buffered_diagnostics: &mut Vec) { -- cgit 1.4.1-3-g733a5