@@ -3,51 +3,55 @@ use rustc_middle::ty::{Instance, Ty};
33use rustc_span:: { Span , Symbol } ;
44
55#[ derive( Diagnostic ) ]
6- #[ diag( monomorphize_recursion_limit ) ]
6+ #[ diag( "reached the recursion limit while instantiating `{$instance}`" ) ]
77pub ( crate ) struct RecursionLimit < ' tcx > {
88 #[ primary_span]
99 pub span : Span ,
1010 pub instance : Instance < ' tcx > ,
11- #[ note]
11+ #[ note( "`{$def_path_str}` defined here" ) ]
1212 pub def_span : Span ,
1313 pub def_path_str : String ,
1414}
1515
1616#[ derive( Diagnostic ) ]
17- #[ diag( monomorphize_no_optimized_mir ) ]
17+ #[ diag( "missing optimized MIR for `{$instance}` in the crate `{$crate_name}`" ) ]
1818pub ( crate ) struct NoOptimizedMir {
19- #[ note]
19+ #[ note(
20+ "missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?)"
21+ ) ]
2022 pub span : Span ,
2123 pub crate_name : Symbol ,
2224 pub instance : String ,
2325}
2426
2527#[ derive( LintDiagnostic ) ]
26- #[ diag( monomorphize_large_assignments) ]
27- #[ note]
28+ #[ diag( "moving {$size} bytes" ) ]
29+ #[ note(
30+ "the current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = \" ...\" ]`"
31+ ) ]
2832pub ( crate ) struct LargeAssignmentsLint {
29- #[ label]
33+ #[ label( "value moved from here" ) ]
3034 pub span : Span ,
3135 pub size : u64 ,
3236 pub limit : u64 ,
3337}
3438
3539#[ derive( Diagnostic ) ]
36- #[ diag( monomorphize_symbol_already_defined ) ]
40+ #[ diag( "symbol `{$symbol}` is already defined" ) ]
3741pub ( crate ) struct SymbolAlreadyDefined {
3842 #[ primary_span]
3943 pub span : Option < Span > ,
4044 pub symbol : String ,
4145}
4246
4347#[ derive( Diagnostic ) ]
44- #[ diag( monomorphize_couldnt_dump_mono_stats ) ]
48+ #[ diag( "unexpected error occurred while dumping monomorphization stats: {$error}" ) ]
4549pub ( crate ) struct CouldntDumpMonoStats {
4650 pub error : String ,
4751}
4852
4953#[ derive( Diagnostic ) ]
50- #[ diag( monomorphize_encountered_error_while_instantiating ) ]
54+ #[ diag( "the above error was encountered while instantiating `{$kind} {$instance}`" ) ]
5155pub ( crate ) struct EncounteredErrorWhileInstantiating < ' tcx > {
5256 #[ primary_span]
5357 pub span : Span ,
@@ -56,23 +60,41 @@ pub(crate) struct EncounteredErrorWhileInstantiating<'tcx> {
5660}
5761
5862#[ derive( Diagnostic ) ]
59- #[ diag( monomorphize_encountered_error_while_instantiating_global_asm ) ]
63+ #[ diag( "the above error was encountered while instantiating `global_asm`" ) ]
6064pub ( crate ) struct EncounteredErrorWhileInstantiatingGlobalAsm {
6165 #[ primary_span]
6266 pub span : Span ,
6367}
6468
6569#[ derive( Diagnostic ) ]
66- #[ diag( monomorphize_start_not_found) ]
67- #[ help]
70+ #[ diag( "using `fn main` requires the standard library" ) ]
71+ #[ help(
72+ "use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]`"
73+ ) ]
6874pub ( crate ) struct StartNotFound ;
6975
7076#[ derive( Diagnostic ) ]
71- #[ diag( monomorphize_abi_error_disabled_vector_type) ]
72- #[ help]
77+ #[ diag( "this function {$is_call ->
78+ [true] call
79+ *[false] definition
80+ } uses {$is_scalable ->
81+ [true] scalable
82+ *[false] SIMD
83+ } vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
84+ [true] {\" \" }in the caller
85+ *[false] {\" \" }
86+ }" ) ]
87+ #[ help(
88+ "consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\" {$required_feature}\" )]`)"
89+ ) ]
7390pub ( crate ) struct AbiErrorDisabledVectorType < ' a > {
7491 #[ primary_span]
75- #[ label]
92+ #[ label(
93+ "function {$is_call ->
94+ [true] called
95+ *[false] defined
96+ } here"
97+ ) ]
7698 pub span : Span ,
7799 pub required_feature : & ' a str ,
78100 pub ty : Ty < ' a > ,
@@ -83,34 +105,67 @@ pub(crate) struct AbiErrorDisabledVectorType<'a> {
83105}
84106
85107#[ derive( Diagnostic ) ]
86- #[ diag( monomorphize_abi_error_unsupported_unsized_parameter) ]
87- #[ help]
108+ #[ diag(
109+ "this function {$is_call ->
110+ [true] call
111+ *[false] definition
112+ } uses unsized type `{$ty}` which is not supported with the chosen ABI"
113+ ) ]
114+ #[ help( "only rustic ABIs support unsized parameters" ) ]
88115pub ( crate ) struct AbiErrorUnsupportedUnsizedParameter < ' a > {
89116 #[ primary_span]
90- #[ label]
117+ #[ label(
118+ "function {$is_call ->
119+ [true] called
120+ *[false] defined
121+ } here"
122+ ) ]
91123 pub span : Span ,
92124 pub ty : Ty < ' a > ,
93125 /// Whether this is a problem at a call site or at a declaration.
94126 pub is_call : bool ,
95127}
96128
97129#[ derive( Diagnostic ) ]
98- #[ diag( monomorphize_abi_error_unsupported_vector_type) ]
130+ #[ diag(
131+ "this function {$is_call ->
132+ [true] call
133+ *[false] definition
134+ } uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI"
135+ ) ]
99136pub ( crate ) struct AbiErrorUnsupportedVectorType < ' a > {
100137 #[ primary_span]
101- #[ label]
138+ #[ label(
139+ "function {$is_call ->
140+ [true] called
141+ *[false] defined
142+ } here"
143+ ) ]
102144 pub span : Span ,
103145 pub ty : Ty < ' a > ,
104146 /// Whether this is a problem at a call site or at a declaration.
105147 pub is_call : bool ,
106148}
107149
108150#[ derive( Diagnostic ) ]
109- #[ diag( monomorphize_abi_required_target_feature) ]
110- #[ help]
151+ #[ diag( "this function {$is_call ->
152+ [true] call
153+ *[false] definition
154+ } uses ABI \" {$abi}\" which requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
155+ [true] {\" \" }in the caller
156+ *[false] {\" \" }
157+ }" ) ]
158+ #[ help(
159+ "consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\" {$required_feature}\" )]`)"
160+ ) ]
111161pub ( crate ) struct AbiRequiredTargetFeature < ' a > {
112162 #[ primary_span]
113- #[ label]
163+ #[ label(
164+ "function {$is_call ->
165+ [true] called
166+ *[false] defined
167+ } here"
168+ ) ]
114169 pub span : Span ,
115170 pub required_feature : & ' a str ,
116171 pub abi : & ' a str ,
@@ -119,12 +174,12 @@ pub(crate) struct AbiRequiredTargetFeature<'a> {
119174}
120175
121176#[ derive( Diagnostic ) ]
122- #[ diag( monomorphize_static_initializer_cyclic ) ]
123- #[ note]
177+ #[ diag( "static initializer forms a cycle involving `{$head}`" ) ]
178+ #[ note( "cyclic static initializers are not supported for target `{$target}`" ) ]
124179pub ( crate ) struct StaticInitializerCyclic < ' a > {
125180 #[ primary_span]
126181 pub span : Span ,
127- #[ label]
182+ #[ label( "part of this cycle" ) ]
128183 pub labels : Vec < Span > ,
129184 pub head : & ' a str ,
130185 pub target : & ' a str ,
0 commit comments