File tree Expand file tree Collapse file tree 7 files changed +24
-1
lines changed Expand file tree Collapse file tree 7 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -4155,7 +4155,9 @@ dependencies = [
41554155 " punycode" ,
41564156 " rustc-demangle" ,
41574157 " rustc_data_structures" ,
4158+ " rustc_errors" ,
41584159 " rustc_hir" ,
4160+ " rustc_macros" ,
41594161 " rustc_middle" ,
41604162 " rustc_session" ,
41614163 " rustc_span" ,
Original file line number Diff line number Diff line change 1+ symbol_mangling_invalid_symbol_name = symbol-name({ $mangled_formatted } )
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ fluent_messages! {
5252 ty_utils => "../locales/en-US/ty_utils.ftl" ,
5353 typeck => "../locales/en-US/typeck.ftl" ,
5454 mir_dataflow => "../locales/en-US/mir_dataflow.ftl" ,
55+ symbol_mangling => "../locales/en-US/symbol_mangling.ftl" ,
5556}
5657
5758pub use fluent_generated:: { self as fluent, DEFAULT_LOCALE_RESOURCES } ;
Original file line number Diff line number Diff line change @@ -18,3 +18,5 @@ rustc_hir = { path = "../rustc_hir" }
1818rustc_target = { path = " ../rustc_target" }
1919rustc_data_structures = { path = " ../rustc_data_structures" }
2020rustc_session = { path = " ../rustc_session" }
21+ rustc_macros = { path = " ../rustc_macros" }
22+ rustc_errors = { path = " ../rustc_errors" }
Original file line number Diff line number Diff line change 1+ //! Errors emitted by symbol_mangling.
2+
3+ use rustc_macros:: SessionDiagnostic ;
4+ use rustc_span:: Span ;
5+
6+ #[ derive( SessionDiagnostic ) ]
7+ #[ error( symbol_mangling:: invalid_symbol_name) ]
8+ pub struct InvalidSymbolName < ' a > {
9+ #[ primary_span]
10+ pub span : Span ,
11+ pub mangled_formatted : & ' a str ,
12+ }
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ use tracing::debug;
110110mod legacy;
111111mod v0;
112112
113+ pub mod errors;
113114pub mod test;
114115pub mod typeid;
115116
Original file line number Diff line number Diff line change 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:: InvalidSymbolName ;
78use rustc_hir:: def_id:: LocalDefId ;
89use rustc_middle:: ty:: print:: with_no_trimmed_paths;
910use rustc_middle:: ty:: { subst:: InternalSubsts , Instance , TyCtxt } ;
@@ -59,7 +60,10 @@ impl SymbolNamesTest<'_> {
5960 tcx. erase_regions ( InternalSubsts :: identity_for_item ( tcx, def_id) ) ,
6061 ) ;
6162 let mangled = tcx. symbol_name ( instance) ;
62- tcx. sess . span_err ( attr. span , & format ! ( "symbol-name({})" , mangled) ) ;
63+ tcx. sess . emit_err ( InvalidSymbolName {
64+ span : attr. span ,
65+ mangled_formatted : & format ! ( "{mangled}" ) ,
66+ } ) ;
6367 if let Ok ( demangling) = rustc_demangle:: try_demangle ( mangled. name ) {
6468 tcx. sess . span_err ( attr. span , & format ! ( "demangling({})" , demangling) ) ;
6569 tcx. sess . span_err ( attr. span , & format ! ( "demangling-alt({:#})" , demangling) ) ;
You can’t perform that action at this time.
0 commit comments