1
+ use crate :: rustc_middle:: ty:: TypeVisitableExt ;
1
2
use crate :: FnCtxt ;
2
3
use rustc_infer:: traits:: solve:: Goal ;
3
4
use rustc_infer:: traits:: { self , ObligationCause } ;
@@ -31,10 +32,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31
32
) -> bool {
32
33
match predicate. kind ( ) . skip_binder ( ) {
33
34
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Trait ( data) ) => {
34
- self . self_type_matches_expected_vid ( data. self_ty ( ) , expected_vid )
35
+ self . type_matches_expected_vid ( expected_vid , data. self_ty ( ) )
35
36
}
36
37
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( data) ) => {
37
- self . self_type_matches_expected_vid ( data. projection_ty . self_ty ( ) , expected_vid )
38
+ self . type_matches_expected_vid ( expected_vid , data. projection_ty . self_ty ( ) )
38
39
}
39
40
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstArgHasType ( ..) )
40
41
| ty:: PredicateKind :: Subtype ( ..)
@@ -52,11 +53,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
52
53
}
53
54
54
55
#[ instrument( level = "debug" , skip( self ) , ret) ]
55
- fn self_type_matches_expected_vid ( & self , self_ty : Ty < ' tcx > , expected_vid : ty:: TyVid ) -> bool {
56
- let self_ty = self . shallow_resolve ( self_ty ) ;
57
- debug ! ( ?self_ty ) ;
56
+ fn type_matches_expected_vid ( & self , expected_vid : ty:: TyVid , ty : Ty < ' tcx > ) -> bool {
57
+ let ty = self . shallow_resolve ( ty ) ;
58
+ debug ! ( ?ty ) ;
58
59
59
- match * self_ty . kind ( ) {
60
+ match * ty . kind ( ) {
60
61
ty:: Infer ( ty:: TyVar ( found_vid) ) => expected_vid == self . root_var ( found_vid) ,
61
62
_ => false ,
62
63
}
@@ -67,6 +68,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
67
68
self_ty : ty:: TyVid ,
68
69
) -> Vec < traits:: PredicateObligation < ' tcx > > {
69
70
let obligations = self . fulfillment_cx . borrow ( ) . pending_obligations ( ) ;
71
+ debug ! ( ?obligations) ;
70
72
let mut obligations_for_self_ty = vec ! [ ] ;
71
73
for obligation in obligations {
72
74
let mut visitor = NestedObligationsForSelfTy {
@@ -79,6 +81,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
79
81
let goal = Goal :: new ( self . tcx , obligation. param_env , obligation. predicate ) ;
80
82
self . visit_proof_tree ( goal, & mut visitor) ;
81
83
}
84
+
85
+ obligations_for_self_ty. retain_mut ( |obligation| {
86
+ obligation. predicate = self . resolve_vars_if_possible ( obligation. predicate ) ;
87
+ !obligation. predicate . has_placeholders ( )
88
+ } ) ;
82
89
obligations_for_self_ty
83
90
}
84
91
}
0 commit comments