mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
ADD - migrate InvalidDefPath to new diagnostics infra
This commit is contained in:
parent
bd83bbc93a
commit
8f5fada86d
@ -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})
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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())),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user