@@ -37,10 +37,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3737 ) -> bool {
3838 match predicate. kind ( ) . skip_binder ( ) {
3939 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( data) ) => {
40- self . type_matches_expected_vid ( expected_vid , data. self_ty ( ) )
40+ self . type_matches_expected_vid ( data. self_ty ( ) , expected_vid )
4141 }
4242 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( data) ) => {
43- self . type_matches_expected_vid ( expected_vid , data. projection_term . self_ty ( ) )
43+ self . type_matches_expected_vid ( data. projection_term . self_ty ( ) , expected_vid )
4444 }
4545 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstArgHasType ( ..) )
4646 | ty:: PredicateKind :: Subtype ( ..)
@@ -60,7 +60,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6060 }
6161
6262 #[ instrument( level = "debug" , skip( self ) , ret) ]
63- fn type_matches_expected_vid ( & self , expected_vid : ty:: TyVid , ty : Ty < ' tcx > ) -> bool {
63+ fn type_matches_expected_vid ( & self , ty : Ty < ' tcx > , expected_vid : ty :: TyVid ) -> bool {
6464 let ty = self . shallow_resolve ( ty) ;
6565 debug ! ( ?ty) ;
6666
@@ -125,6 +125,18 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for NestedObligationsForSelfTy<'a, 'tcx> {
125125 return ;
126126 }
127127
128+ // We don't care about any pending goals which don't actually
129+ // use the self type.
130+ if !inspect_goal
131+ . orig_values ( )
132+ . iter ( )
133+ . filter_map ( |arg| arg. as_type ( ) )
134+ . any ( |ty| self . fcx . type_matches_expected_vid ( ty, self . self_ty ) )
135+ {
136+ debug ! ( goal = ?inspect_goal. goal( ) , "goal does not mention self type" ) ;
137+ return ;
138+ }
139+
128140 let tcx = self . fcx . tcx ;
129141 let goal = inspect_goal. goal ( ) ;
130142 if self . fcx . predicate_has_self_ty ( goal. predicate , self . self_ty )
0 commit comments