@@ -623,6 +623,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
623623 outlived_fr : RegionVid ,
624624 ) {
625625 let tcx = self . infcx . tcx ;
626+ debug ! ( ?code) ;
626627 let ObligationCauseCode :: MethodCallConstraint ( ty, call_span) = code else {
627628 return ;
628629 } ;
@@ -637,10 +638,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
637638 ) else {
638639 return ;
639640 } ;
641+ debug ! ( ?instance) ;
640642 let def_id = instance. def_id ( ) ;
641643 let mut parent = tcx. parent ( def_id) ;
642- match tcx. def_kind ( parent) {
643- hir:: def:: DefKind :: Impl { .. } => { }
644+ debug ! ( ?def_id, ?parent) ;
645+ let trait_preds = match tcx. def_kind ( parent) {
646+ hir:: def:: DefKind :: Impl { .. } => & [ ] ,
644647 hir:: def:: DefKind :: Trait => {
645648 let Some ( ty) = args. get ( 0 ) . and_then ( |arg| arg. as_type ( ) ) else {
646649 return ;
@@ -652,14 +655,18 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
652655 if let [ def_id] = impls[ ..] {
653656 // The method we have is on the trait, but for `parent` we want to analyze the
654657 // relevant impl instead.
658+ let preds = tcx. predicates_of ( parent) . predicates ;
655659 parent = def_id;
660+ preds
656661 } else {
657662 return ;
658- } ;
663+ }
659664 }
660665 _ => return ,
661- }
666+ } ;
667+ debug ! ( ?def_id, ?parent) ;
662668 let ty = tcx. type_of ( parent) . instantiate_identity ( ) ;
669+ debug ! ( ?ty) ;
663670 if self . to_error_region ( outlived_fr) != Some ( tcx. lifetimes . re_static ) {
664671 return ;
665672 }
@@ -678,23 +685,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
678685 // ```
679686 let mut predicates: Vec < Span > = traits:: elaborate (
680687 tcx,
681- tcx. predicates_of ( def_id)
682- . predicates
683- . iter ( )
684- . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) )
685- . chain (
686- tcx. predicates_of ( parent)
687- . predicates
688- . iter ( )
689- . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
690- ) ,
688+ tcx. predicates_of ( def_id) . predicates . iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
691689 )
690+ . chain ( traits:: elaborate (
691+ tcx,
692+ tcx. predicates_of ( parent) . predicates . iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
693+ ) )
694+ . chain ( traits:: elaborate ( tcx, trait_preds. iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ) )
692695 . filter_map ( |( pred, pred_span) | {
693696 if let ty:: PredicateKind :: Clause ( clause) = pred. kind ( ) . skip_binder ( )
694697 && let ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( pred_ty, r) ) = clause
695- // Look for `'static` bounds
696698 && r. kind ( ) == ty:: ReStatic
697- // We only want bounds on `Self`
698699 && ( self . infcx . can_eq ( self . param_env , ty, pred_ty)
699700 || matches ! (
700701 pred_ty. kind( ) ,
@@ -706,6 +707,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
706707 }
707708 } )
708709 . collect ( ) ;
710+ debug ! ( ?predicates) ;
709711
710712 // Look at the receiver for `&'static self`, which introduces a `'static` obligation.
711713 // ```
0 commit comments