@@ -9,8 +9,8 @@ use rustc_span::{Span, Symbol};
99use crate :: ty:: { Instance , Ty } ;
1010
1111#[ derive( Diagnostic ) ]
12- #[ diag( middle_drop_check_overflow , code = E0320 ) ]
13- #[ note]
12+ #[ diag( "overflow while adding drop-check rules for `{$ty}`" , code = E0320 ) ]
13+ #[ note( "overflowed on `{$overflow_ty}`" ) ]
1414pub ( crate ) struct DropCheckOverflow < ' tcx > {
1515 #[ primary_span]
1616 pub span : Span ,
@@ -19,33 +19,33 @@ pub(crate) struct DropCheckOverflow<'tcx> {
1919}
2020
2121#[ derive( Diagnostic ) ]
22- #[ diag( middle_failed_writing_file ) ]
22+ #[ diag( "failed to write file {$path}: {$error} \" " ) ]
2323pub ( crate ) struct FailedWritingFile < ' a > {
2424 pub path : & ' a Path ,
2525 pub error : io:: Error ,
2626}
2727
2828#[ derive( Diagnostic ) ]
29- #[ diag( middle_opaque_hidden_type_mismatch ) ]
29+ #[ diag( "concrete type differs from previous defining opaque type use" ) ]
3030pub ( crate ) struct OpaqueHiddenTypeMismatch < ' tcx > {
3131 pub self_ty : Ty < ' tcx > ,
3232 pub other_ty : Ty < ' tcx > ,
3333 #[ primary_span]
34- #[ label]
34+ #[ label( "expected `{$self_ty}`, got `{$other_ty}`" ) ]
3535 pub other_span : Span ,
3636 #[ subdiagnostic]
3737 pub sub : TypeMismatchReason ,
3838}
3939
4040#[ derive( Diagnostic ) ]
41- #[ diag( middle_unsupported_union ) ]
41+ #[ diag( "we don't support unions yet: '{$ty_name}'" ) ]
4242pub struct UnsupportedUnion {
4343 pub ty_name : String ,
4444}
4545
4646// FIXME(autodiff): I should get used somewhere
4747#[ derive( Diagnostic ) ]
48- #[ diag( middle_autodiff_unsafe_inner_const_ref ) ]
48+ #[ diag( "reading from a `Duplicated` const {$ty} is unsafe" ) ]
4949pub struct AutodiffUnsafeInnerConstRef < ' tcx > {
5050 #[ primary_span]
5151 pub span : Span ,
@@ -54,21 +54,23 @@ pub struct AutodiffUnsafeInnerConstRef<'tcx> {
5454
5555#[ derive( Subdiagnostic ) ]
5656pub enum TypeMismatchReason {
57- #[ label( middle_conflict_types ) ]
57+ #[ label( "this expression supplies two conflicting concrete types for the same opaque type" ) ]
5858 ConflictType {
5959 #[ primary_span]
6060 span : Span ,
6161 } ,
62- #[ note( middle_previous_use_here ) ]
62+ #[ note( "previous use here" ) ]
6363 PreviousUse {
6464 #[ primary_span]
6565 span : Span ,
6666 } ,
6767}
6868
6969#[ derive( Diagnostic ) ]
70- #[ diag( middle_recursion_limit_reached) ]
71- #[ help]
70+ #[ diag( "reached the recursion limit finding the struct tail for `{$ty}`" ) ]
71+ #[ help(
72+ "consider increasing the recursion limit by adding a `#![recursion_limit = \" {$suggested_limit}\" ]`"
73+ ) ]
7274pub ( crate ) struct RecursionLimitReached < ' tcx > {
7375 #[ primary_span]
7476 pub span : Span ,
@@ -77,31 +79,35 @@ pub(crate) struct RecursionLimitReached<'tcx> {
7779}
7880
7981#[ derive( Diagnostic ) ]
80- #[ diag( middle_const_eval_non_int ) ]
82+ #[ diag( "constant evaluation of enum discriminant resulted in non-integer" ) ]
8183pub ( crate ) struct ConstEvalNonIntError {
8284 #[ primary_span]
8385 pub span : Span ,
8486}
8587
8688#[ derive( Diagnostic ) ]
87- #[ diag( middle_strict_coherence_needs_negative_coherence) ]
89+ #[ diag(
90+ "to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled"
91+ ) ]
8892pub ( crate ) struct StrictCoherenceNeedsNegativeCoherence {
8993 #[ primary_span]
9094 pub span : Span ,
91- #[ label]
95+ #[ label( "due to this attribute" ) ]
9296 pub attr_span : Option < Span > ,
9397}
9498
9599#[ derive( Diagnostic ) ]
96- #[ diag( middle_requires_lang_item ) ]
100+ #[ diag( "requires `{$name}` lang_item" ) ]
97101pub ( crate ) struct RequiresLangItem {
98102 #[ primary_span]
99103 pub span : Span ,
100104 pub name : Symbol ,
101105}
102106
103107#[ derive( Diagnostic ) ]
104- #[ diag( middle_const_not_used_in_type_alias) ]
108+ #[ diag(
109+ "const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias"
110+ ) ]
105111pub ( super ) struct ConstNotUsedTraitAlias {
106112 pub ct : String ,
107113 #[ primary_span]
@@ -133,41 +139,41 @@ impl fmt::Debug for CustomSubdiagnostic<'_> {
133139
134140#[ derive( Diagnostic ) ]
135141pub enum LayoutError < ' tcx > {
136- #[ diag( middle_layout_unknown ) ]
142+ #[ diag( "the type `{$ty}` has an unknown layout" ) ]
137143 Unknown { ty : Ty < ' tcx > } ,
138144
139- #[ diag( middle_layout_too_generic ) ]
145+ #[ diag( "the type `{$ty}` does not have a fixed layout" ) ]
140146 TooGeneric { ty : Ty < ' tcx > } ,
141147
142- #[ diag( middle_layout_size_overflow ) ]
148+ #[ diag( "values of the type `{$ty}` are too big for the target architecture" ) ]
143149 Overflow { ty : Ty < ' tcx > } ,
144150
145- #[ diag( middle_layout_simd_too_many ) ]
151+ #[ diag( "the SIMD type `{$ty}` has more elements than the limit {$max_lanes}" ) ]
146152 SimdTooManyLanes { ty : Ty < ' tcx > , max_lanes : u64 } ,
147153
148- #[ diag( middle_layout_simd_zero_length ) ]
154+ #[ diag( "the SIMD type `{$ty}` has zero elements" ) ]
149155 SimdZeroLength { ty : Ty < ' tcx > } ,
150156
151- #[ diag( middle_layout_normalization_failure ) ]
157+ #[ diag( "unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized" ) ]
152158 NormalizationFailure { ty : Ty < ' tcx > , failure_ty : String } ,
153159
154- #[ diag( middle_layout_cycle ) ]
160+ #[ diag( "a cycle occurred during layout computation" ) ]
155161 Cycle ,
156162
157- #[ diag( middle_layout_references_error ) ]
163+ #[ diag( "the type has an unknown layout" ) ]
158164 ReferencesError ,
159165}
160166
161167#[ derive( Diagnostic ) ]
162- #[ diag( middle_erroneous_constant ) ]
168+ #[ diag( "erroneous constant encountered" ) ]
163169pub ( crate ) struct ErroneousConstant {
164170 #[ primary_span]
165171 pub span : Span ,
166172}
167173
168174#[ derive( Diagnostic ) ]
169- #[ diag( middle_type_length_limit ) ]
170- #[ help( middle_consider_type_length_limit ) ]
175+ #[ diag( "reached the type-length limit while instantiating `{$instance}`" ) ]
176+ #[ help( "consider adding a `#![type_length_limit= \" {$type_length} \" ]` attribute to your crate" ) ]
171177pub ( crate ) struct TypeLengthLimit < ' tcx > {
172178 #[ primary_span]
173179 pub span : Span ,
@@ -176,16 +182,16 @@ pub(crate) struct TypeLengthLimit<'tcx> {
176182}
177183
178184#[ derive( Diagnostic ) ]
179- #[ diag( middle_max_num_nodes_in_valtree ) ]
185+ #[ diag( "maximum number of nodes exceeded in constant {$global_const_id}" ) ]
180186pub ( crate ) struct MaxNumNodesInValtree {
181187 #[ primary_span]
182188 pub span : Span ,
183189 pub global_const_id : String ,
184190}
185191
186192#[ derive( Diagnostic ) ]
187- #[ diag( middle_invalid_const_in_valtree ) ]
188- #[ note]
193+ #[ diag( "constant {$global_const_id} cannot be used as pattern" ) ]
194+ #[ note( "constants that reference mutable or external memory cannot be used as patterns" ) ]
189195pub ( crate ) struct InvalidConstInValtree {
190196 #[ primary_span]
191197 pub span : Span ,
0 commit comments