about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2022-09-14 19:22:20 +0200
committerXiretza <xiretza@xiretza.xyz>2022-09-27 20:29:18 +0200
commit8489a67f0b0ca5a973d48b27d609c91cb93cf343 (patch)
treee69c24d4a69303c76e0a5fcf1e55681beb5dc3b3 /compiler/rustc_errors/src
parent495e271883188ece09b80ae7f405e8062853f2d3 (diff)
downloadrust-8489a67f0b0ca5a973d48b27d609c91cb93cf343.tar.gz
rust-8489a67f0b0ca5a973d48b27d609c91cb93cf343.zip
Implement IntoDiagnosticArg for rustc_ast::Path
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 1c440a0a07e..fb409c578f6 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -3,6 +3,8 @@ use crate::{
     CodeSuggestion, DiagnosticMessage, EmissionGuarantee, Level, LintDiagnosticBuilder, MultiSpan,
     SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
 };
+use rustc_ast as ast;
+use rustc_ast_pretty::pprust;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_error_messages::FluentValue;
 use rustc_hir as hir;
@@ -175,6 +177,12 @@ impl IntoDiagnosticArg for hir::ConstContext {
     }
 }
 
+impl IntoDiagnosticArg for ast::Path {
+    fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
+        DiagnosticArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
+    }
+}
+
 /// Trait implemented by error types. This should not be implemented manually. Instead, use
 /// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
 #[cfg_attr(bootstrap, rustc_diagnostic_item = "AddSubdiagnostic")]