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 = [
4155
4155
" punycode" ,
4156
4156
" rustc-demangle" ,
4157
4157
" rustc_data_structures" ,
4158
+ " rustc_errors" ,
4158
4159
" rustc_hir" ,
4160
+ " rustc_macros" ,
4159
4161
" rustc_middle" ,
4160
4162
" rustc_session" ,
4161
4163
" 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! {
52
52
ty_utils => "../locales/en-US/ty_utils.ftl" ,
53
53
typeck => "../locales/en-US/typeck.ftl" ,
54
54
mir_dataflow => "../locales/en-US/mir_dataflow.ftl" ,
55
+ symbol_mangling => "../locales/en-US/symbol_mangling.ftl" ,
55
56
}
56
57
57
58
pub 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" }
18
18
rustc_target = { path = " ../rustc_target" }
19
19
rustc_data_structures = { path = " ../rustc_data_structures" }
20
20
rustc_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;
110
110
mod legacy;
111
111
mod v0;
112
112
113
+ pub mod errors;
113
114
pub mod test;
114
115
pub mod typeid;
115
116
Original file line number Diff line number Diff line change 4
4
//! def-path. This is used for unit testing the code that generates
5
5
//! paths etc in all kinds of annoying scenarios.
6
6
7
+ use crate :: errors:: InvalidSymbolName ;
7
8
use rustc_hir:: def_id:: LocalDefId ;
8
9
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
9
10
use rustc_middle:: ty:: { subst:: InternalSubsts , Instance , TyCtxt } ;
@@ -59,7 +60,10 @@ impl SymbolNamesTest<'_> {
59
60
tcx. erase_regions ( InternalSubsts :: identity_for_item ( tcx, def_id) ) ,
60
61
) ;
61
62
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
+ } ) ;
63
67
if let Ok ( demangling) = rustc_demangle:: try_demangle ( mangled. name ) {
64
68
tcx. sess . span_err ( attr. span , & format ! ( "demangling({})" , demangling) ) ;
65
69
tcx. sess . span_err ( attr. span , & format ! ( "demangling-alt({:#})" , demangling) ) ;
You can’t perform that action at this time.
0 commit comments