@@ -544,7 +544,6 @@ pub struct ExplicitLifetimeRequired<'a> {
544544
545545#[ derive( Subdiagnostic ) ]
546546pub enum ActualImplExplNotes {
547- // Field names have to be different across Expected* and ButActually variants
548547 #[ note( infer:: actual_impl_expl_expected_signature_two) ]
549548 ExpectedSignatureTwo {
550549 leading_ellipsis : bool ,
@@ -731,7 +730,7 @@ pub struct TraitPlaceholderMismatch {
731730 pub def_id : String ,
732731 pub trait_def_id : String ,
733732
734- #[ subdiagnostic]
733+ #[ subdiagnostic( eager ) ]
735734 pub actual_impl_expl_notes : Vec < ActualImplExplNotes > ,
736735}
737736
@@ -740,12 +739,17 @@ pub struct ConsiderBorrowingParamHelp {
740739}
741740
742741impl 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+ {
744746 let mut type_param_span: MultiSpan = self . spans . clone ( ) . into ( ) ;
745747 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) ;
747750 }
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) ;
749753 }
750754}
751755
@@ -779,14 +783,19 @@ pub struct DynTraitConstraintSuggestion {
779783}
780784
781785impl 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+ {
783790 let mut multi_span: MultiSpan = vec ! [ self . span] . into ( ) ;
784791 multi_span. push_span_label ( self . span , fluent:: infer:: dtcs_has_lifetime_req_label) ;
785792 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 ( ) ) ;
787796 diag. span_suggestion_verbose (
788797 self . span . shrink_to_hi ( ) ,
789- fluent :: infer :: dtcs_suggestion ,
798+ msg ,
790799 " + '_" ,
791800 Applicability :: MaybeIncorrect ,
792801 ) ;
@@ -820,7 +829,10 @@ pub struct ReqIntroducedLocations {
820829}
821830
822831impl 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+ {
824836 for sp in self . spans {
825837 self . span . push_span_label ( sp, fluent:: infer:: ril_introduced_here) ;
826838 }
@@ -829,7 +841,8 @@ impl AddToDiagnostic for ReqIntroducedLocations {
829841 self . span . push_span_label ( self . fn_decl_span , fluent:: infer:: ril_introduced_by) ;
830842 }
831843 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) ;
833846 }
834847}
835848
@@ -838,7 +851,10 @@ pub struct MoreTargeted {
838851}
839852
840853impl 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+ {
842858 diag. code ( rustc_errors:: error_code!( E0772 ) ) ;
843859 diag. set_primary_message ( fluent:: infer:: more_targeted) ;
844860 diag. set_arg ( "ident" , self . ident ) ;
0 commit comments