@@ -37,10 +37,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37
37
) -> bool {
38
38
match predicate. kind ( ) . skip_binder ( ) {
39
39
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 )
41
41
}
42
42
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 )
44
44
}
45
45
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstArgHasType ( ..) )
46
46
| ty:: PredicateKind :: Subtype ( ..)
@@ -60,7 +60,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
60
60
}
61
61
62
62
#[ 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 {
64
64
let ty = self . shallow_resolve ( ty) ;
65
65
debug ! ( ?ty) ;
66
66
@@ -125,6 +125,18 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for NestedObligationsForSelfTy<'a, 'tcx> {
125
125
return ;
126
126
}
127
127
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
+
128
140
let tcx = self . fcx . tcx ;
129
141
let goal = inspect_goal. goal ( ) ;
130
142
if self . fcx . predicate_has_self_ty ( goal. predicate , self . self_ty )
0 commit comments