about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJhonny Bill Mena <jhonnybillm@gmail.com>2022-08-21 00:51:33 -0400
committerJhonny Bill Mena <jhonnybillm@gmail.com>2022-08-30 14:27:42 -0400
commit8f5fada86df26aaccbf4f5e5851ac040b5ea5852 (patch)
treed08a9e2d4932bde65e0da0652d53c64fde2db123
parentbd83bbc93adce97e34c1c4d5d8d74f7b19068326 (diff)
downloadrust-8f5fada86df26aaccbf4f5e5851ac040b5ea5852.tar.gz
rust-8f5fada86df26aaccbf4f5e5851ac040b5ea5852.zip
ADD - migrate InvalidDefPath to new diagnostics infra
-rw-r--r--compiler/rustc_error_messages/locales/en-US/symbol_mangling.ftl2
-rw-r--r--compiler/rustc_symbol_mangling/src/errors.rs8
-rw-r--r--compiler/rustc_symbol_mangling/src/test.rs8
3 files changed, 15 insertions, 3 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/symbol_mangling.ftl b/compiler/rustc_error_messages/locales/en-US/symbol_mangling.ftl
index 644c8f84c28..55d6fbbf86f 100644
--- a/compiler/rustc_error_messages/locales/en-US/symbol_mangling.ftl
+++ b/compiler/rustc_error_messages/locales/en-US/symbol_mangling.ftl
@@ -3,3 +3,5 @@ symbol_mangling_invalid_symbol_name = symbol-name({$mangled_formatted})
 symbol_mangling_invalid_trait_item = demangling({$demangling_formatted})
 
 symbol_mangling_alt_invalid_trait_item = demangling-alt({$alt_demangling_formatted})
+
+symbol_mangling_invalid_def_path = def-path({$def_path})
diff --git a/compiler/rustc_symbol_mangling/src/errors.rs b/compiler/rustc_symbol_mangling/src/errors.rs
index c0e49e07bfc..4872dfa2653 100644
--- a/compiler/rustc_symbol_mangling/src/errors.rs
+++ b/compiler/rustc_symbol_mangling/src/errors.rs
@@ -26,3 +26,11 @@ pub struct AltInvalidTraitItem {
     pub span: Span,
     pub alt_demangling_formatted: String,
 }
+
+#[derive(SessionDiagnostic)]
+#[error(symbol_mangling::invalid_def_path)]
+pub struct InvalidDefPath {
+    #[primary_span]
+    pub span: Span,
+    pub def_path: String,
+}
diff --git a/compiler/rustc_symbol_mangling/src/test.rs b/compiler/rustc_symbol_mangling/src/test.rs
index 2ed1dea357d..b1c4cab11eb 100644
--- a/compiler/rustc_symbol_mangling/src/test.rs
+++ b/compiler/rustc_symbol_mangling/src/test.rs
@@ -4,7 +4,7 @@
 //! def-path. This is used for unit testing the code that generates
 //! paths etc in all kinds of annoying scenarios.
 
-use crate::errors::{AltInvalidTraitItem, InvalidSymbolName, InvalidTraitItem};
+use crate::errors::{AltInvalidTraitItem, InvalidDefPath, InvalidSymbolName, InvalidTraitItem};
 use rustc_hir::def_id::LocalDefId;
 use rustc_middle::ty::print::with_no_trimmed_paths;
 use rustc_middle::ty::{subst::InternalSubsts, Instance, TyCtxt};
@@ -77,8 +77,10 @@ impl SymbolNamesTest<'_> {
         }
 
         for attr in tcx.get_attrs(def_id.to_def_id(), DEF_PATH) {
-            let path = with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id()));
-            tcx.sess.span_err(attr.span, &format!("def-path({})", path));
+            tcx.sess.emit_err(InvalidDefPath {
+                span: attr.span,
+                def_path: with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id())),
+            });
         }
     }
 }