@@ -544,7 +544,6 @@ pub struct ExplicitLifetimeRequired<'a> {
544
544
545
545
#[ derive( Subdiagnostic ) ]
546
546
pub enum ActualImplExplNotes {
547
- // Field names have to be different across Expected* and ButActually variants
548
547
#[ note( infer:: actual_impl_expl_expected_signature_two) ]
549
548
ExpectedSignatureTwo {
550
549
leading_ellipsis : bool ,
@@ -731,7 +730,7 @@ pub struct TraitPlaceholderMismatch {
731
730
pub def_id : String ,
732
731
pub trait_def_id : String ,
733
732
734
- #[ subdiagnostic]
733
+ #[ subdiagnostic( eager ) ]
735
734
pub actual_impl_expl_notes : Vec < ActualImplExplNotes > ,
736
735
}
737
736
@@ -740,12 +739,17 @@ pub struct ConsiderBorrowingParamHelp {
740
739
}
741
740
742
741
impl AddToDiagnostic for ConsiderBorrowingParamHelp {
743
- fn add_to_diagnostic ( self , diag : & mut rustc_errors:: Diagnostic ) {
742
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , f : F )
743
+ where
744
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
745
+ {
744
746
let mut type_param_span: MultiSpan = self . spans . clone ( ) . into ( ) ;
745
747
for & span in & self . spans {
746
- type_param_span. push_span_label ( span, fluent:: infer:: tid_consider_borriwing) ;
748
+ // Seems like we can't call f() here as Into<DiagnosticMessage> is required
749
+ type_param_span. push_span_label ( span, fluent:: infer:: tid_consider_borrowing) ;
747
750
}
748
- diag. span_help ( type_param_span, fluent:: infer:: tid_param_help) ;
751
+ let msg = f ( diag, fluent:: infer:: tid_param_help. into ( ) ) ;
752
+ diag. span_help ( type_param_span, msg) ;
749
753
}
750
754
}
751
755
@@ -779,14 +783,19 @@ pub struct DynTraitConstraintSuggestion {
779
783
}
780
784
781
785
impl AddToDiagnostic for DynTraitConstraintSuggestion {
782
- fn add_to_diagnostic ( self , diag : & mut rustc_errors:: Diagnostic ) {
786
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , f : F )
787
+ where
788
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
789
+ {
783
790
let mut multi_span: MultiSpan = vec ! [ self . span] . into ( ) ;
784
791
multi_span. push_span_label ( self . span , fluent:: infer:: dtcs_has_lifetime_req_label) ;
785
792
multi_span. push_span_label ( self . ident . span , fluent:: infer:: dtcs_introduces_requirement) ;
786
- diag. span_note ( multi_span, fluent:: infer:: dtcs_has_req_note) ;
793
+ let msg = f ( diag, fluent:: infer:: dtcs_has_req_note. into ( ) ) ;
794
+ diag. span_note ( multi_span, msg) ;
795
+ let msg = f ( diag, fluent:: infer:: dtcs_suggestion. into ( ) ) ;
787
796
diag. span_suggestion_verbose (
788
797
self . span . shrink_to_hi ( ) ,
789
- fluent :: infer :: dtcs_suggestion ,
798
+ msg ,
790
799
" + '_" ,
791
800
Applicability :: MaybeIncorrect ,
792
801
) ;
@@ -820,7 +829,10 @@ pub struct ReqIntroducedLocations {
820
829
}
821
830
822
831
impl AddToDiagnostic for ReqIntroducedLocations {
823
- fn add_to_diagnostic ( mut self , diag : & mut rustc_errors:: Diagnostic ) {
832
+ fn add_to_diagnostic_with < F > ( mut self , diag : & mut Diagnostic , f : F )
833
+ where
834
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
835
+ {
824
836
for sp in self . spans {
825
837
self . span . push_span_label ( sp, fluent:: infer:: ril_introduced_here) ;
826
838
}
@@ -829,7 +841,8 @@ impl AddToDiagnostic for ReqIntroducedLocations {
829
841
self . span . push_span_label ( self . fn_decl_span , fluent:: infer:: ril_introduced_by) ;
830
842
}
831
843
self . span . push_span_label ( self . cause_span , fluent:: infer:: ril_because_of) ;
832
- diag. span_note ( self . span , fluent:: infer:: ril_static_introduced_by) ;
844
+ let msg = f ( diag, fluent:: infer:: ril_static_introduced_by. into ( ) ) ;
845
+ diag. span_note ( self . span , msg) ;
833
846
}
834
847
}
835
848
@@ -838,7 +851,10 @@ pub struct MoreTargeted {
838
851
}
839
852
840
853
impl AddToDiagnostic for MoreTargeted {
841
- fn add_to_diagnostic ( self , diag : & mut rustc_errors:: Diagnostic ) {
854
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _f : F )
855
+ where
856
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
857
+ {
842
858
diag. code ( rustc_errors:: error_code!( E0772 ) ) ;
843
859
diag. set_primary_message ( fluent:: infer:: more_targeted) ;
844
860
diag. set_arg ( "ident" , self . ident ) ;
0 commit comments