@@ -308,11 +308,12 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
308308 // ...also include the other query region constraints from the query.
309309 output_query_region_constraints. extend (
310310 query_response. value . region_constraints . iter ( ) . filter_map ( |r_c| {
311- let & ty:: OutlivesPredicate ( k1, r2) = r_c. skip_binder ( ) ; // reconstructed below
312- let k1 = substitute_value ( self . tcx , & result_subst, & k1) ;
313- let r2 = substitute_value ( self . tcx , & result_subst, & r2) ;
314- if k1 != r2. into ( ) {
315- Some ( ty:: Binder :: bind ( ty:: OutlivesPredicate ( k1, r2) ) )
311+ let ty:: OutlivesPredicate ( k1, r2) = r_c. skip_binder ( ) ; // reconstructed below
312+ let k1 = substitute_value ( self . tcx , & result_subst, & ty:: Binder :: bind ( * k1) ) ;
313+ let r2 = substitute_value ( self . tcx , & result_subst, & ty:: Binder :: bind ( * r2) ) ;
314+ if k1 != r2. map_bound ( |bound| bound. into ( ) ) {
315+ let predicate = ty:: OutlivesPredicate ( * k1. skip_binder ( ) , * r2. skip_binder ( ) ) ;
316+ Some ( ty:: Binder :: bind ( predicate) )
316317 } else {
317318 None
318319 }
@@ -418,16 +419,21 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
418419 UnpackedKind :: Type ( result_value) => {
419420 // e.g., here `result_value` might be `?0` in the example above...
420421 if let ty:: Bound ( b) = result_value. sty {
422+ // ...in which case we would set `canonical_vars[0]` to `Some(?U)`.
423+
424+ // We only allow a `ty::INNERMOST` index in substitutions.
421425 assert_eq ! ( b. index, ty:: INNERMOST ) ;
422- // in which case we would set `canonical_vars[0]` to `Some(?U)`.
423426 opt_values[ b. var ] = Some ( * original_value) ;
424427 }
425428 }
426429 UnpackedKind :: Lifetime ( result_value) => {
427430 // e.g., here `result_value` might be `'?1` in the example above...
428- if let & ty:: RegionKind :: ReCanonical ( index) = result_value {
429- // in which case we would set `canonical_vars[0]` to `Some('static)`.
430- opt_values[ index] = Some ( * original_value) ;
431+ if let & ty:: RegionKind :: ReLateBound ( index, br) = result_value {
432+ // ... in which case we would set `canonical_vars[0]` to `Some('static)`.
433+
434+ // We only allow a `ty::INNERMOST` index in substitutions.
435+ assert_eq ! ( index, ty:: INNERMOST ) ;
436+ opt_values[ br. as_bound_var ( ) ] = Some ( * original_value) ;
431437 }
432438 }
433439 }
@@ -499,21 +505,23 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
499505 . iter ( )
500506 . map ( move |constraint| {
501507 let ty:: OutlivesPredicate ( k1, r2) = constraint. skip_binder ( ) ; // restored below
502- let k1 = substitute_value ( self . tcx , result_subst, k1 ) ;
503- let r2 = substitute_value ( self . tcx , result_subst, r2 ) ;
508+ let k1 = substitute_value ( self . tcx , result_subst, & ty :: Binder :: bind ( * k1 ) ) ;
509+ let r2 = substitute_value ( self . tcx , result_subst, & ty :: Binder :: bind ( * r2 ) ) ;
504510
505511 Obligation :: new (
506512 cause. clone ( ) ,
507513 param_env,
508- match k1. unpack ( ) {
514+ match k1. skip_binder ( ) . unpack ( ) {
509515 UnpackedKind :: Lifetime ( r1) => ty:: Predicate :: RegionOutlives (
510- ty:: Binder :: dummy (
511- ty:: OutlivesPredicate ( r1, r2)
512- ) ) ,
516+ ty:: Binder :: bind (
517+ ty:: OutlivesPredicate ( r1, r2. skip_binder ( ) )
518+ )
519+ ) ,
513520 UnpackedKind :: Type ( t1) => ty:: Predicate :: TypeOutlives (
514- ty:: Binder :: dummy ( ty:: OutlivesPredicate (
515- t1, r2
516- ) ) )
521+ ty:: Binder :: bind (
522+ ty:: OutlivesPredicate ( t1, r2. skip_binder ( ) )
523+ )
524+ ) ,
517525 }
518526 )
519527 } )
@@ -595,11 +603,11 @@ pub fn make_query_outlives<'tcx>(
595603 }
596604 Constraint :: RegSubReg ( r1, r2) => ty:: OutlivesPredicate ( r2. into ( ) , r1) ,
597605 } )
598- . map ( ty:: Binder :: dummy) // no bound regions in the code above
606+ . map ( ty:: Binder :: dummy) // no bound vars in the code above
599607 . chain (
600608 outlives_obligations
601609 . map ( |( ty, r) | ty:: OutlivesPredicate ( ty. into ( ) , r) )
602- . map ( ty:: Binder :: dummy) , // no bound regions in the code above
610+ . map ( ty:: Binder :: dummy) // no bound vars in the code above
603611 )
604612 . collect ( ) ;
605613
0 commit comments