Skip to content

Commit 8f5fada

Browse files
committed
ADD - migrate InvalidDefPath to new diagnostics infra
1 parent bd83bbc commit 8f5fada

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

compiler/rustc_error_messages/locales/en-US/symbol_mangling.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ symbol_mangling_invalid_symbol_name = symbol-name({$mangled_formatted})
33
symbol_mangling_invalid_trait_item = demangling({$demangling_formatted})
44
55
symbol_mangling_alt_invalid_trait_item = demangling-alt({$alt_demangling_formatted})
6+
7+
symbol_mangling_invalid_def_path = def-path({$def_path})

compiler/rustc_symbol_mangling/src/errors.rs

+8
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,11 @@ pub struct AltInvalidTraitItem {
2626
pub span: Span,
2727
pub alt_demangling_formatted: String,
2828
}
29+
30+
#[derive(SessionDiagnostic)]
31+
#[error(symbol_mangling::invalid_def_path)]
32+
pub struct InvalidDefPath {
33+
#[primary_span]
34+
pub span: Span,
35+
pub def_path: String,
36+
}

compiler/rustc_symbol_mangling/src/test.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! def-path. This is used for unit testing the code that generates
55
//! paths etc in all kinds of annoying scenarios.
66
7-
use crate::errors::{AltInvalidTraitItem, InvalidSymbolName, InvalidTraitItem};
7+
use crate::errors::{AltInvalidTraitItem, InvalidDefPath, InvalidSymbolName, InvalidTraitItem};
88
use rustc_hir::def_id::LocalDefId;
99
use rustc_middle::ty::print::with_no_trimmed_paths;
1010
use rustc_middle::ty::{subst::InternalSubsts, Instance, TyCtxt};
@@ -77,8 +77,10 @@ impl SymbolNamesTest<'_> {
7777
}
7878

7979
for attr in tcx.get_attrs(def_id.to_def_id(), DEF_PATH) {
80-
let path = with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id()));
81-
tcx.sess.span_err(attr.span, &format!("def-path({})", path));
80+
tcx.sess.emit_err(InvalidDefPath {
81+
span: attr.span,
82+
def_path: with_no_trimmed_paths!(tcx.def_path_str(def_id.to_def_id())),
83+
});
8284
}
8385
}
8486
}

0 commit comments

Comments
 (0)