@@ -255,9 +255,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
255255 return ;
256256 }
257257
258- match obligation. predicate . skip_binders ( ) {
258+ let bound_predicate = obligation. predicate . bound_atom ( ) ;
259+ match bound_predicate. skip_binder ( ) {
259260 ty:: PredicateAtom :: Trait ( trait_predicate, _) => {
260- let trait_predicate = ty :: Binder :: bind ( trait_predicate) ;
261+ let trait_predicate = bound_predicate . rebind ( trait_predicate) ;
261262 let trait_predicate = self . resolve_vars_if_possible ( & trait_predicate) ;
262263
263264 if self . tcx . sess . has_errors ( ) && trait_predicate. references_error ( ) {
@@ -531,7 +532,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
531532 }
532533
533534 ty:: PredicateAtom :: RegionOutlives ( predicate) => {
534- let predicate = ty :: Binder :: bind ( predicate) ;
535+ let predicate = bound_predicate . rebind ( predicate) ;
535536 let predicate = self . resolve_vars_if_possible ( & predicate) ;
536537 let err = self
537538 . region_outlives_predicate ( & obligation. cause , predicate)
@@ -1078,9 +1079,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
10781079 }
10791080
10801081 // FIXME: It should be possible to deal with `ForAll` in a cleaner way.
1081- let ( cond, error) = match ( cond. skip_binders ( ) , error. skip_binders ( ) ) {
1082+ let bound_error = error. bound_atom ( ) ;
1083+ let ( cond, error) = match ( cond. skip_binders ( ) , bound_error. skip_binder ( ) ) {
10821084 ( ty:: PredicateAtom :: Trait ( ..) , ty:: PredicateAtom :: Trait ( error, _) ) => {
1083- ( cond, ty :: Binder :: bind ( error) )
1085+ ( cond, bound_error . rebind ( error) )
10841086 }
10851087 _ => {
10861088 // FIXME: make this work in other cases too.
@@ -1089,9 +1091,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
10891091 } ;
10901092
10911093 for obligation in super :: elaborate_predicates ( self . tcx , std:: iter:: once ( cond) ) {
1092- if let ty:: PredicateAtom :: Trait ( implication, _) = obligation. predicate . skip_binders ( ) {
1094+ let bound_predicate = obligation. predicate . bound_atom ( ) ;
1095+ if let ty:: PredicateAtom :: Trait ( implication, _) = bound_predicate. skip_binder ( ) {
10931096 let error = error. to_poly_trait_ref ( ) ;
1094- let implication = ty :: Binder :: bind ( implication. trait_ref ) ;
1097+ let implication = bound_predicate . rebind ( implication. trait_ref ) ;
10951098 // FIXME: I'm just not taking associated types at all here.
10961099 // Eventually I'll need to implement param-env-aware
10971100 // `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic.
@@ -1169,12 +1172,13 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
11691172 //
11701173 // this can fail if the problem was higher-ranked, in which
11711174 // cause I have no idea for a good error message.
1172- if let ty:: PredicateAtom :: Projection ( data) = predicate. skip_binders ( ) {
1175+ let bound_predicate = predicate. bound_atom ( ) ;
1176+ if let ty:: PredicateAtom :: Projection ( data) = bound_predicate. skip_binder ( ) {
11731177 let mut selcx = SelectionContext :: new ( self ) ;
11741178 let ( data, _) = self . replace_bound_vars_with_fresh_vars (
11751179 obligation. cause . span ,
11761180 infer:: LateBoundRegionConversionTime :: HigherRankedType ,
1177- & ty :: Binder :: bind ( data) ,
1181+ & bound_predicate . rebind ( data) ,
11781182 ) ;
11791183 let mut obligations = vec ! [ ] ;
11801184 let normalized_ty = super :: normalize_projection_type (
@@ -1455,10 +1459,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
14551459 return ;
14561460 }
14571461
1458- let mut err = match predicate. skip_binders ( ) {
1462+ let bound_predicate = predicate. bound_atom ( ) ;
1463+ let mut err = match bound_predicate. skip_binder ( ) {
14591464 ty:: PredicateAtom :: Trait ( data, _) => {
1460- let trait_ref = ty :: Binder :: bind ( data. trait_ref ) ;
1461- let self_ty = trait_ref . skip_binder ( ) . self_ty ( ) ;
1465+ let self_ty = data. trait_ref . self_ty ( ) ;
1466+ let trait_ref = bound_predicate . rebind ( data . trait_ref ) ;
14621467 debug ! ( "self_ty {:?} {:?} trait_ref {:?}" , self_ty, self_ty. kind( ) , trait_ref) ;
14631468
14641469 if predicate. references_error ( ) {
@@ -1582,7 +1587,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15821587 self . emit_inference_failure_err ( body_id, span, a. into ( ) , ErrorCode :: E0282 )
15831588 }
15841589 ty:: PredicateAtom :: Projection ( data) => {
1585- let trait_ref = ty :: Binder :: bind ( data) . to_poly_trait_ref ( self . tcx ) ;
1590+ let trait_ref = bound_predicate . rebind ( data) . to_poly_trait_ref ( self . tcx ) ;
15861591 let self_ty = trait_ref. skip_binder ( ) . self_ty ( ) ;
15871592 let ty = data. ty ;
15881593 if predicate. references_error ( ) {
0 commit comments