@@ -255,9 +255,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
255
255
return ;
256
256
}
257
257
258
- match obligation. predicate . skip_binders ( ) {
258
+ let bound_predicate = obligation. predicate . bound_atom ( ) ;
259
+ match bound_predicate. skip_binder ( ) {
259
260
ty:: PredicateAtom :: Trait ( trait_predicate, _) => {
260
- let trait_predicate = ty :: Binder :: bind ( trait_predicate) ;
261
+ let trait_predicate = bound_predicate . rebind ( trait_predicate) ;
261
262
let trait_predicate = self . resolve_vars_if_possible ( & trait_predicate) ;
262
263
263
264
if self . tcx . sess . has_errors ( ) && trait_predicate. references_error ( ) {
@@ -531,7 +532,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
531
532
}
532
533
533
534
ty:: PredicateAtom :: RegionOutlives ( predicate) => {
534
- let predicate = ty :: Binder :: bind ( predicate) ;
535
+ let predicate = bound_predicate . rebind ( predicate) ;
535
536
let predicate = self . resolve_vars_if_possible ( & predicate) ;
536
537
let err = self
537
538
. region_outlives_predicate ( & obligation. cause , predicate)
@@ -1078,9 +1079,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1078
1079
}
1079
1080
1080
1081
// 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 ( ) ) {
1082
1084
( ty:: PredicateAtom :: Trait ( ..) , ty:: PredicateAtom :: Trait ( error, _) ) => {
1083
- ( cond, ty :: Binder :: bind ( error) )
1085
+ ( cond, bound_error . rebind ( error) )
1084
1086
}
1085
1087
_ => {
1086
1088
// FIXME: make this work in other cases too.
@@ -1089,9 +1091,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1089
1091
} ;
1090
1092
1091
1093
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 ( ) {
1093
1096
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 ) ;
1095
1098
// FIXME: I'm just not taking associated types at all here.
1096
1099
// Eventually I'll need to implement param-env-aware
1097
1100
// `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic.
@@ -1169,12 +1172,13 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1169
1172
//
1170
1173
// this can fail if the problem was higher-ranked, in which
1171
1174
// 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 ( ) {
1173
1177
let mut selcx = SelectionContext :: new ( self ) ;
1174
1178
let ( data, _) = self . replace_bound_vars_with_fresh_vars (
1175
1179
obligation. cause . span ,
1176
1180
infer:: LateBoundRegionConversionTime :: HigherRankedType ,
1177
- & ty :: Binder :: bind ( data) ,
1181
+ & bound_predicate . rebind ( data) ,
1178
1182
) ;
1179
1183
let mut obligations = vec ! [ ] ;
1180
1184
let normalized_ty = super :: normalize_projection_type (
@@ -1455,10 +1459,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1455
1459
return ;
1456
1460
}
1457
1461
1458
- let mut err = match predicate. skip_binders ( ) {
1462
+ let bound_predicate = predicate. bound_atom ( ) ;
1463
+ let mut err = match bound_predicate. skip_binder ( ) {
1459
1464
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 ) ;
1462
1467
debug ! ( "self_ty {:?} {:?} trait_ref {:?}" , self_ty, self_ty. kind( ) , trait_ref) ;
1463
1468
1464
1469
if predicate. references_error ( ) {
@@ -1582,7 +1587,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1582
1587
self . emit_inference_failure_err ( body_id, span, a. into ( ) , ErrorCode :: E0282 )
1583
1588
}
1584
1589
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 ) ;
1586
1591
let self_ty = trait_ref. skip_binder ( ) . self_ty ( ) ;
1587
1592
let ty = data. ty ;
1588
1593
if predicate. references_error ( ) {
0 commit comments