about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-09-30 10:22:36 +0200
committerGitHub <noreply@github.com>2022-09-30 10:22:36 +0200
commit25017f8bcece0f57cc1acd3b64394f30cbda11f4 (patch)
treeb1b15ccfd08bead80e5d89d0a79b3ede9e9445ce /compiler/rustc_errors/src
parentb3aa4997d4817c5ea2b33ba20f6fe7c695e4f64c (diff)
parent01439c93b8ce1faadb207cd0d5bb3ce6a3cbf1be (diff)
downloadrust-25017f8bcece0f57cc1acd3b64394f30cbda11f4.tar.gz
rust-25017f8bcece0f57cc1acd3b64394f30cbda11f4.zip
Rollup merge of #101075 - ellishg:rustc_codegen_gcc_diagnostics, r=davidtwco
Migrate rustc_codegen_gcc to SessionDiagnostics

As part of #100717 this pr migrates diagnostics to `SessionDiagnostics` for the `rustc_codegen_gcc` crate.

``@rustbot`` label +A-translation
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic_builder.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs
index b4ba65ca96d..092a77f944c 100644
--- a/compiler/rustc_errors/src/diagnostic_builder.rs
+++ b/compiler/rustc_errors/src/diagnostic_builder.rs
@@ -5,6 +5,7 @@ use crate::{
 };
 use crate::{Handler, Level, MultiSpan, StashKey};
 use rustc_lint_defs::Applicability;
+use rustc_span::source_map::Spanned;
 
 use rustc_span::Span;
 use std::borrow::Cow;
@@ -23,6 +24,18 @@ pub trait IntoDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
     fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, T>;
 }
 
+impl<'a, T, E> IntoDiagnostic<'a, E> for Spanned<T>
+where
+    T: IntoDiagnostic<'a, E>,
+    E: EmissionGuarantee,
+{
+    fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, E> {
+        let mut diag = self.node.into_diagnostic(handler);
+        diag.set_span(self.span);
+        diag
+    }
+}
+
 /// Used for emitting structured error messages and other diagnostic information.
 ///
 /// If there is some state in a downstream crate you would like to