11use hir:: GenericParamKind ;
22use rustc_errors:: {
33 codes:: * , AddToDiagnostic , Applicability , Diagnostic , DiagnosticMessage ,
4- DiagnosticStyledString , IntoDiagnosticArg , MultiSpan , SubdiagnosticMessage ,
4+ DiagnosticStyledString , IntoDiagnosticArg , MultiSpan , SubdiagnosticMessageOp ,
55} ;
66use rustc_hir as hir;
77use rustc_hir:: FnRetTy ;
@@ -225,10 +225,7 @@ pub enum RegionOriginNote<'a> {
225225}
226226
227227impl 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 ) {
232229 let mut label_or_note = |span, msg : DiagnosticMessage | {
233230 let sub_count = diag. children . iter ( ) . filter ( |d| d. span . is_dummy ( ) ) . count ( ) ;
234231 let expanded_sub_count = diag. children . iter ( ) . filter ( |d| !d. span . is_dummy ( ) ) . count ( ) ;
@@ -289,10 +286,7 @@ pub enum LifetimeMismatchLabels {
289286}
290287
291288impl 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 ) {
296290 match self {
297291 LifetimeMismatchLabels :: InRet { param_span, ret_span, span, label_var1 } => {
298292 diag. span_label ( param_span, fluent:: infer_declared_different) ;
@@ -336,10 +330,7 @@ pub struct AddLifetimeParamsSuggestion<'a> {
336330}
337331
338332impl 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 ) {
343334 let mut mk_suggestion = || {
344335 let (
345336 hir:: Ty { kind : hir:: TyKind :: Ref ( lifetime_sub, _) , .. } ,
@@ -437,10 +428,7 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
437428}
438429
439430impl 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 ) {
444432 self . unmet_requirements
445433 . push_span_label ( self . binding_span , fluent:: infer_msl_introduces_static) ;
446434 diag. span_note ( self . unmet_requirements , fluent:: infer_msl_unmet_req) ;
@@ -755,10 +743,7 @@ pub struct ConsiderBorrowingParamHelp {
755743}
756744
757745impl 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 ) {
762747 let mut type_param_span: MultiSpan = self . spans . clone ( ) . into ( ) ;
763748 for & span in & self . spans {
764749 // Seems like we can't call f() here as Into<DiagnosticMessage> is required
@@ -799,10 +784,7 @@ pub struct DynTraitConstraintSuggestion {
799784}
800785
801786impl 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 ) {
806788 let mut multi_span: MultiSpan = vec ! [ self . span] . into ( ) ;
807789 multi_span. push_span_label ( self . span , fluent:: infer_dtcs_has_lifetime_req_label) ;
808790 multi_span. push_span_label ( self . ident . span , fluent:: infer_dtcs_introduces_requirement) ;
@@ -845,10 +827,7 @@ pub struct ReqIntroducedLocations {
845827}
846828
847829impl 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 ) {
852831 for sp in self . spans {
853832 self . span . push_span_label ( sp, fluent:: infer_ril_introduced_here) ;
854833 }
@@ -867,10 +846,7 @@ pub struct MoreTargeted {
867846}
868847
869848impl 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 ) {
874850 diag. code ( E0772 ) ;
875851 diag. primary_message ( fluent:: infer_more_targeted) ;
876852 diag. arg ( "ident" , self . ident ) ;
@@ -1289,10 +1265,7 @@ pub struct SuggestTuplePatternMany {
12891265}
12901266
12911267impl 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 ) {
12961269 diag. arg ( "path" , self . path ) ;
12971270 let message = f ( diag, crate :: fluent_generated:: infer_stp_wrap_many. into ( ) ) ;
12981271 diag. multipart_suggestions (
0 commit comments