@@ -544,27 +544,179 @@ pub struct ExplicitLifetimeRequired<'a> {
544544
545545#[ derive( Subdiagnostic ) ]
546546pub enum ActualImplExplNotes {
547- // Field names have to be different across all variants
548- #[ note( infer:: actual_impl_expl_expected) ]
549- Expected {
547+ // Field names have to be different across Expected* and ButActually variants
548+ #[ note( infer:: actual_impl_expl_expected_signature_two) ]
549+ ExpectedSignatureTwo {
550+ leading_ellipsis : bool ,
551+ ty_or_sig : String ,
552+ trait_path : String ,
553+ lifetime_1 : usize ,
554+ lifetime_2 : usize ,
555+ } ,
556+ #[ note( infer:: actual_impl_expl_expected_signature_any) ]
557+ ExpectedSignatureAny {
558+ leading_ellipsis : bool ,
559+ ty_or_sig : String ,
560+ trait_path : String ,
561+ lifetime_1 : usize ,
562+ } ,
563+ #[ note( infer:: actual_impl_expl_expected_signature_some) ]
564+ ExpectedSignatureSome {
565+ leading_ellipsis : bool ,
566+ ty_or_sig : String ,
567+ trait_path : String ,
568+ lifetime_1 : usize ,
569+ } ,
570+ #[ note( infer:: actual_impl_expl_expected_signature_nothing) ]
571+ ExpectedSignatureNothing { leading_ellipsis : bool , ty_or_sig : String , trait_path : String } ,
572+ #[ note( infer:: actual_impl_expl_expected_passive_two) ]
573+ ExpectedPassiveTwo {
550574 leading_ellipsis : bool ,
551- kind : & ' static str ,
552575 ty_or_sig : String ,
553576 trait_path : String ,
554- lt_kind : & ' static str ,
555577 lifetime_1 : usize ,
556578 lifetime_2 : usize ,
557579 } ,
558- #[ note( infer:: actual_impl_expl_but_actually) ]
559- ButActually {
560- kind_2 : & ' static str ,
580+ #[ note( infer:: actual_impl_expl_expected_passive_any) ]
581+ ExpectedPassiveAny {
582+ leading_ellipsis : bool ,
583+ ty_or_sig : String ,
584+ trait_path : String ,
585+ lifetime_1 : usize ,
586+ } ,
587+ #[ note( infer:: actual_impl_expl_expected_passive_some) ]
588+ ExpectedPassiveSome {
589+ leading_ellipsis : bool ,
590+ ty_or_sig : String ,
591+ trait_path : String ,
592+ lifetime_1 : usize ,
593+ } ,
594+ #[ note( infer:: actual_impl_expl_expected_passive_nothing) ]
595+ ExpectedPassiveNothing { leading_ellipsis : bool , ty_or_sig : String , trait_path : String } ,
596+ #[ note( infer:: actual_impl_expl_expected_other_two) ]
597+ ExpectedOtherTwo {
598+ leading_ellipsis : bool ,
599+ ty_or_sig : String ,
600+ trait_path : String ,
601+ lifetime_1 : usize ,
602+ lifetime_2 : usize ,
603+ } ,
604+ #[ note( infer:: actual_impl_expl_expected_other_any) ]
605+ ExpectedOtherAny {
606+ leading_ellipsis : bool ,
607+ ty_or_sig : String ,
608+ trait_path : String ,
609+ lifetime_1 : usize ,
610+ } ,
611+ #[ note( infer:: actual_impl_expl_expected_other_some) ]
612+ ExpectedOtherSome {
613+ leading_ellipsis : bool ,
614+ ty_or_sig : String ,
615+ trait_path : String ,
616+ lifetime_1 : usize ,
617+ } ,
618+ #[ note( infer:: actual_impl_expl_expected_other_nothing) ]
619+ ExpectedOtherNothing { leading_ellipsis : bool , ty_or_sig : String , trait_path : String } ,
620+ #[ note( infer:: actual_impl_expl_but_actually_implements_trait) ]
621+ ButActuallyImplementsTrait { trait_path_2 : String , has_lifetime : bool , lifetime : usize } ,
622+ #[ note( infer:: actual_impl_expl_but_actually_implemented_for_ty) ]
623+ ButActuallyImplementedForTy {
624+ trait_path_2 : String ,
625+ has_lifetime : bool ,
626+ lifetime : usize ,
627+ ty : String ,
628+ } ,
629+ #[ note( infer:: actual_impl_expl_but_actually_ty_implements) ]
630+ ButActuallyTyImplements {
561631 trait_path_2 : String ,
562632 has_lifetime : bool ,
563633 lifetime : usize ,
564634 ty : String ,
565635 } ,
566636}
567637
638+ pub enum ActualImplExpectedKind {
639+ Signature ,
640+ Passive ,
641+ Other ,
642+ }
643+
644+ pub enum ActualImplExpectedLifetimeKind {
645+ Two ,
646+ Any ,
647+ Some ,
648+ Nothing ,
649+ }
650+
651+ impl ActualImplExplNotes {
652+ pub fn new_expected (
653+ kind : ActualImplExpectedKind ,
654+ lt_kind : ActualImplExpectedLifetimeKind ,
655+ leading_ellipsis : bool ,
656+ ty_or_sig : String ,
657+ trait_path : String ,
658+ lifetime_1 : usize ,
659+ lifetime_2 : usize ,
660+ ) -> Self {
661+ match ( kind, lt_kind) {
662+ ( ActualImplExpectedKind :: Signature , ActualImplExpectedLifetimeKind :: Two ) => {
663+ Self :: ExpectedSignatureTwo {
664+ leading_ellipsis,
665+ ty_or_sig,
666+ trait_path,
667+ lifetime_1,
668+ lifetime_2,
669+ }
670+ }
671+ ( ActualImplExpectedKind :: Signature , ActualImplExpectedLifetimeKind :: Any ) => {
672+ Self :: ExpectedSignatureAny { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
673+ }
674+ ( ActualImplExpectedKind :: Signature , ActualImplExpectedLifetimeKind :: Some ) => {
675+ Self :: ExpectedSignatureSome { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
676+ }
677+ ( ActualImplExpectedKind :: Signature , ActualImplExpectedLifetimeKind :: Nothing ) => {
678+ Self :: ExpectedSignatureNothing { leading_ellipsis, ty_or_sig, trait_path }
679+ }
680+ ( ActualImplExpectedKind :: Passive , ActualImplExpectedLifetimeKind :: Two ) => {
681+ Self :: ExpectedPassiveTwo {
682+ leading_ellipsis,
683+ ty_or_sig,
684+ trait_path,
685+ lifetime_1,
686+ lifetime_2,
687+ }
688+ }
689+ ( ActualImplExpectedKind :: Passive , ActualImplExpectedLifetimeKind :: Any ) => {
690+ Self :: ExpectedPassiveAny { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
691+ }
692+ ( ActualImplExpectedKind :: Passive , ActualImplExpectedLifetimeKind :: Some ) => {
693+ Self :: ExpectedPassiveSome { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
694+ }
695+ ( ActualImplExpectedKind :: Passive , ActualImplExpectedLifetimeKind :: Nothing ) => {
696+ Self :: ExpectedPassiveNothing { leading_ellipsis, ty_or_sig, trait_path }
697+ }
698+ ( ActualImplExpectedKind :: Other , ActualImplExpectedLifetimeKind :: Two ) => {
699+ Self :: ExpectedOtherTwo {
700+ leading_ellipsis,
701+ ty_or_sig,
702+ trait_path,
703+ lifetime_1,
704+ lifetime_2,
705+ }
706+ }
707+ ( ActualImplExpectedKind :: Other , ActualImplExpectedLifetimeKind :: Any ) => {
708+ Self :: ExpectedOtherAny { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
709+ }
710+ ( ActualImplExpectedKind :: Other , ActualImplExpectedLifetimeKind :: Some ) => {
711+ Self :: ExpectedOtherSome { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
712+ }
713+ ( ActualImplExpectedKind :: Other , ActualImplExpectedLifetimeKind :: Nothing ) => {
714+ Self :: ExpectedOtherNothing { leading_ellipsis, ty_or_sig, trait_path }
715+ }
716+ }
717+ }
718+ }
719+
568720#[ derive( Diagnostic ) ]
569721#[ diag( infer:: trait_placeholder_mismatch) ]
570722pub struct TraitPlaceholderMismatch {
0 commit comments