@@ -620,6 +620,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
620620 outlived_fr : RegionVid ,
621621 ) {
622622 let tcx = self . infcx . tcx ;
623+ debug ! ( ?code) ;
623624 let ObligationCauseCode :: MethodCallConstraint ( ty, call_span) = code else {
624625 return ;
625626 } ;
@@ -634,10 +635,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
634635 ) else {
635636 return ;
636637 } ;
638+ debug ! ( ?instance) ;
637639 let def_id = instance. def_id ( ) ;
638640 let mut parent = tcx. parent ( def_id) ;
639- match tcx. def_kind ( parent) {
640- hir:: def:: DefKind :: Impl { .. } => { }
641+ debug ! ( ?def_id, ?parent) ;
642+ let trait_preds = match tcx. def_kind ( parent) {
643+ hir:: def:: DefKind :: Impl { .. } => & [ ] ,
641644 hir:: def:: DefKind :: Trait => {
642645 let Some ( ty) = args. get ( 0 ) . and_then ( |arg| arg. as_type ( ) ) else {
643646 return ;
@@ -649,14 +652,18 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
649652 if let [ def_id] = impls[ ..] {
650653 // The method we have is on the trait, but for `parent` we want to analyze the
651654 // relevant impl instead.
655+ let preds = tcx. predicates_of ( parent) . predicates ;
652656 parent = def_id;
657+ preds
653658 } else {
654659 return ;
655- } ;
660+ }
656661 }
657662 _ => return ,
658- }
663+ } ;
664+ debug ! ( ?def_id, ?parent) ;
659665 let ty = tcx. type_of ( parent) . instantiate_identity ( ) ;
666+ debug ! ( ?ty) ;
660667 if self . to_error_region ( outlived_fr) != Some ( tcx. lifetimes . re_static ) {
661668 return ;
662669 }
@@ -675,23 +682,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
675682 // ```
676683 let mut predicates: Vec < Span > = traits:: elaborate (
677684 tcx,
678- tcx. predicates_of ( def_id)
679- . predicates
680- . iter ( )
681- . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) )
682- . chain (
683- tcx. predicates_of ( parent)
684- . predicates
685- . iter ( )
686- . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
687- ) ,
685+ tcx. predicates_of ( def_id) . predicates . iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
688686 )
687+ . chain ( traits:: elaborate (
688+ tcx,
689+ tcx. predicates_of ( parent) . predicates . iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ,
690+ ) )
691+ . chain ( traits:: elaborate ( tcx, trait_preds. iter ( ) . map ( |( p, sp) | ( p. as_predicate ( ) , * sp) ) ) )
689692 . filter_map ( |( pred, pred_span) | {
690693 if let ty:: PredicateKind :: Clause ( clause) = pred. kind ( ) . skip_binder ( )
691694 && let ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( pred_ty, r) ) = clause
692- // Look for `'static` bounds
693695 && r. kind ( ) == ty:: ReStatic
694- // We only want bounds on `Self`
695696 && ( self . infcx . can_eq ( self . param_env , ty, pred_ty)
696697 || matches ! (
697698 pred_ty. kind( ) ,
@@ -703,6 +704,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
703704 }
704705 } )
705706 . collect ( ) ;
707+ debug ! ( ?predicates) ;
706708
707709 // Look at the receiver for `&'static self`, which introduces a `'static` obligation.
708710 // ```
0 commit comments