1
1
use hir:: GenericParamKind ;
2
2
use rustc_errors:: {
3
3
codes:: * , AddToDiagnostic , Applicability , Diagnostic , DiagnosticMessage ,
4
- DiagnosticStyledString , IntoDiagnosticArg , MultiSpan , SubdiagnosticMessage ,
4
+ DiagnosticStyledString , IntoDiagnosticArg , MultiSpan , SubdiagnosticMessageOp ,
5
5
} ;
6
6
use rustc_hir as hir;
7
7
use rustc_hir:: FnRetTy ;
@@ -225,10 +225,7 @@ pub enum RegionOriginNote<'a> {
225
225
}
226
226
227
227
impl AddToDiagnostic for RegionOriginNote < ' _ > {
228
- fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
229
- where
230
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
231
- {
228
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( self , diag : & mut Diagnostic , _: F ) {
232
229
let mut label_or_note = |span, msg : DiagnosticMessage | {
233
230
let sub_count = diag. children . iter ( ) . filter ( |d| d. span . is_dummy ( ) ) . count ( ) ;
234
231
let expanded_sub_count = diag. children . iter ( ) . filter ( |d| !d. span . is_dummy ( ) ) . count ( ) ;
@@ -289,10 +286,7 @@ pub enum LifetimeMismatchLabels {
289
286
}
290
287
291
288
impl AddToDiagnostic for LifetimeMismatchLabels {
292
- fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
293
- where
294
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
295
- {
289
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( self , diag : & mut Diagnostic , _: F ) {
296
290
match self {
297
291
LifetimeMismatchLabels :: InRet { param_span, ret_span, span, label_var1 } => {
298
292
diag. span_label ( param_span, fluent:: infer_declared_different) ;
@@ -336,10 +330,7 @@ pub struct AddLifetimeParamsSuggestion<'a> {
336
330
}
337
331
338
332
impl AddToDiagnostic for AddLifetimeParamsSuggestion < ' _ > {
339
- fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
340
- where
341
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
342
- {
333
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( self , diag : & mut Diagnostic , _: F ) {
343
334
let mut mk_suggestion = || {
344
335
let (
345
336
hir:: Ty { kind : hir:: TyKind :: Ref ( lifetime_sub, _) , .. } ,
@@ -437,10 +428,7 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
437
428
}
438
429
439
430
impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
440
- fn add_to_diagnostic_with < F > ( mut self , diag : & mut Diagnostic , _: F )
441
- where
442
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
443
- {
431
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( mut self , diag : & mut Diagnostic , _: F ) {
444
432
self . unmet_requirements
445
433
. push_span_label ( self . binding_span , fluent:: infer_msl_introduces_static) ;
446
434
diag. span_note ( self . unmet_requirements , fluent:: infer_msl_unmet_req) ;
@@ -755,10 +743,7 @@ pub struct ConsiderBorrowingParamHelp {
755
743
}
756
744
757
745
impl AddToDiagnostic for ConsiderBorrowingParamHelp {
758
- fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , f : F )
759
- where
760
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
761
- {
746
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( self , diag : & mut Diagnostic , f : F ) {
762
747
let mut type_param_span: MultiSpan = self . spans . clone ( ) . into ( ) ;
763
748
for & span in & self . spans {
764
749
// Seems like we can't call f() here as Into<DiagnosticMessage> is required
@@ -799,10 +784,7 @@ pub struct DynTraitConstraintSuggestion {
799
784
}
800
785
801
786
impl AddToDiagnostic for DynTraitConstraintSuggestion {
802
- fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , f : F )
803
- where
804
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
805
- {
787
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( self , diag : & mut Diagnostic , f : F ) {
806
788
let mut multi_span: MultiSpan = vec ! [ self . span] . into ( ) ;
807
789
multi_span. push_span_label ( self . span , fluent:: infer_dtcs_has_lifetime_req_label) ;
808
790
multi_span. push_span_label ( self . ident . span , fluent:: infer_dtcs_introduces_requirement) ;
@@ -845,10 +827,7 @@ pub struct ReqIntroducedLocations {
845
827
}
846
828
847
829
impl AddToDiagnostic for ReqIntroducedLocations {
848
- fn add_to_diagnostic_with < F > ( mut self , diag : & mut Diagnostic , f : F )
849
- where
850
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
851
- {
830
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( mut self , diag : & mut Diagnostic , f : F ) {
852
831
for sp in self . spans {
853
832
self . span . push_span_label ( sp, fluent:: infer_ril_introduced_here) ;
854
833
}
@@ -867,10 +846,7 @@ pub struct MoreTargeted {
867
846
}
868
847
869
848
impl AddToDiagnostic for MoreTargeted {
870
- fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _f : F )
871
- where
872
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
873
- {
849
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( self , diag : & mut Diagnostic , _f : F ) {
874
850
diag. code ( E0772 ) ;
875
851
diag. primary_message ( fluent:: infer_more_targeted) ;
876
852
diag. arg ( "ident" , self . ident ) ;
@@ -1289,10 +1265,7 @@ pub struct SuggestTuplePatternMany {
1289
1265
}
1290
1266
1291
1267
impl AddToDiagnostic for SuggestTuplePatternMany {
1292
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors:: Diagnostic , f : F )
1293
- where
1294
- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
1295
- {
1268
+ fn add_to_diagnostic_with < F : SubdiagnosticMessageOp > ( self , diag : & mut Diagnostic , f : F ) {
1296
1269
diag. arg ( "path" , self . path ) ;
1297
1270
let message = f ( diag, crate :: fluent_generated:: infer_stp_wrap_many. into ( ) ) ;
1298
1271
diag. multipart_suggestions (
0 commit comments