about summary refs log tree commit diff
path: root/compiler/rustc_session
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2022-08-19 14:47:45 +0200
committerXiretza <xiretza@xiretza.xyz>2022-08-21 09:17:43 +0200
commit91ad4e38f53ce1ef8783233bde36a81cd8177981 (patch)
tree0d28d3daed968a041b7e302046539167abffd8b9 /compiler/rustc_session
parentaa8e761defc245d08d2cf226786def8a8bb56e53 (diff)
downloadrust-91ad4e38f53ce1ef8783233bde36a81cd8177981.tar.gz
rust-91ad4e38f53ce1ef8783233bde36a81cd8177981.zip
Add Handler::struct_diagnostic()
This unifies the struct_{warn,error,fatal}() methods in one generic
method.
Diffstat (limited to 'compiler/rustc_session')
-rw-r--r--compiler/rustc_session/src/parse.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs
index 9f0886cb208..b9b2356130a 100644
--- a/compiler/rustc_session/src/parse.rs
+++ b/compiler/rustc_session/src/parse.rs
@@ -12,7 +12,7 @@ use rustc_data_structures::sync::{Lock, Lrc};
 use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
 use rustc_errors::{
     error_code, fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId,
-    DiagnosticMessage, ErrorGuaranteed, MultiSpan, StashKey,
+    DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, MultiSpan, StashKey,
 };
 use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
 use rustc_span::edition::Edition;
@@ -372,4 +372,12 @@ impl ParseSess {
     pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
         self.span_diagnostic.struct_warn(msg)
     }
+
+    #[rustc_lint_diagnostics]
+    pub fn struct_diagnostic<G: EmissionGuarantee>(
+        &self,
+        msg: impl Into<DiagnosticMessage>,
+    ) -> DiagnosticBuilder<'_, G> {
+        self.span_diagnostic.struct_diagnostic(msg)
+    }
 }