1+ use crate :: rustc_middle:: ty:: TypeVisitableExt ;
12use crate :: FnCtxt ;
23use rustc_infer:: traits:: solve:: Goal ;
34use rustc_infer:: traits:: { self , ObligationCause } ;
@@ -31,10 +32,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3132 ) -> bool {
3233 match predicate. kind ( ) . skip_binder ( ) {
3334 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 ( ) )
3536 }
3637 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 ( ) )
3839 }
3940 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstArgHasType ( ..) )
4041 | ty:: PredicateKind :: Subtype ( ..)
@@ -52,11 +53,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5253 }
5354
5455 #[ 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 ) ;
5859
59- match * self_ty . kind ( ) {
60+ match * ty . kind ( ) {
6061 ty:: Infer ( ty:: TyVar ( found_vid) ) => expected_vid == self . root_var ( found_vid) ,
6162 _ => false ,
6263 }
@@ -67,6 +68,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6768 self_ty : ty:: TyVid ,
6869 ) -> Vec < traits:: PredicateObligation < ' tcx > > {
6970 let obligations = self . fulfillment_cx . borrow ( ) . pending_obligations ( ) ;
71+ debug ! ( ?obligations) ;
7072 let mut obligations_for_self_ty = vec ! [ ] ;
7173 for obligation in obligations {
7274 let mut visitor = NestedObligationsForSelfTy {
@@ -79,6 +81,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7981 let goal = Goal :: new ( self . tcx , obligation. param_env , obligation. predicate ) ;
8082 self . visit_proof_tree ( goal, & mut visitor) ;
8183 }
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+ } ) ;
8289 obligations_for_self_ty
8390 }
8491}
0 commit comments