@@ -624,6 +624,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
624624 outlived_fr : RegionVid ,
625625 ) {
626626 let tcx = self . infcx . tcx ;
627+ debug ! ( ?code) ;
627628 let ObligationCauseCode :: MethodCallConstraint ( ty, call_span) = code else {
628629 return ;
629630 } ;
@@ -638,10 +639,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
638639 ) else {
639640 return ;
640641 } ;
642+ debug ! ( ?instance) ;
641643 let def_id = instance. def_id ( ) ;
642644 let mut parent = tcx. parent ( def_id) ;
643- match tcx. def_kind ( parent) {
644- hir:: def:: DefKind :: Impl { .. } => { }
645+ debug ! ( ?def_id, ?parent) ;
646+ let trait_preds = match tcx. def_kind ( parent) {
647+ hir:: def:: DefKind :: Impl { .. } => & [ ] ,
645648 hir:: def:: DefKind :: Trait => {
646649 let Some ( ty) = args. get ( 0 ) . and_then ( |arg| arg. as_type ( ) ) else {
647650 return ;
@@ -653,14 +656,18 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
653656 if let [ def_id] = impls[ ..] {
654657 // The method we have is on the trait, but for `parent` we want to analyze the
655658 // relevant impl instead.
659+ let preds = tcx. predicates_of ( parent) . predicates ;
656660 parent = def_id;
661+ preds
657662 } else {
658663 return ;
659- } ;
664+ }
660665 }
661666 _ => return ,
662- }
667+ } ;
668+ debug ! ( ?def_id, ?parent) ;
663669 let ty = tcx. type_of ( parent) . instantiate_identity ( ) ;
670+ debug ! ( ?ty) ;
664671 if self . to_error_region ( outlived_fr) != Some ( tcx. lifetimes . re_static ) {
665672 return ;
666673 }
@@ -679,23 +686,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
679686 // ```
680687 let mut predicates: Vec < Span > = traits:: elaborate (
681688 tcx,
682- tcx. predicates_of ( def_id)
683- . predicates
684- . iter ( )
685- . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) )
686- . chain (
687- tcx. predicates_of ( parent)
688- . predicates
689- . iter ( )
690- . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
691- ) ,
689+ tcx. predicates_of ( def_id) . predicates . iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
692690 )
691+ . chain ( traits:: elaborate (
692+ tcx,
693+ tcx. predicates_of ( parent) . predicates . iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
694+ ) )
695+ . chain ( traits:: elaborate ( tcx, trait_preds. iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ) )
693696 . filter_map ( |( pred, pred_span) | {
694697 if let ty:: PredicateKind :: Clause ( clause) = pred. kind ( ) . skip_binder ( )
695698 && let ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( pred_ty, r) ) = clause
696- // Look for `'static` bounds
697699 && r. kind ( ) == ty:: ReStatic
698- // We only want bounds on `Self`
699700 && ( self . infcx . can_eq ( self . param_env , ty, pred_ty)
700701 || matches ! (
701702 pred_ty. kind( ) ,
@@ -707,6 +708,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
707708 }
708709 } )
709710 . collect ( ) ;
711+ debug ! ( ?predicates) ;
710712
711713 // Look at the receiver for `&'static self`, which introduces a `'static` obligation.
712714 // ```
0 commit comments