@@ -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 }
@@ -433,16 +434,21 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
433434 UnpackedKind :: Type ( result_value) => {
434435 // e.g., here `result_value` might be `?0` in the example above...
435436 if let ty:: Bound ( b) = result_value. sty {
437+ // ...in which case we would set `canonical_vars[0]` to `Some(?U)`.
438+
439+ // We only allow a `ty::INNERMOST` index in substitutions.
436440 assert_eq ! ( b. index, ty:: INNERMOST ) ;
437- // in which case we would set `canonical_vars[0]` to `Some(?U)`.
438441 opt_values[ b. var ] = Some ( * original_value) ;
439442 }
440443 }
441444 UnpackedKind :: Lifetime ( result_value) => {
442445 // e.g., here `result_value` might be `'?1` in the example above...
443- if let & ty:: RegionKind :: ReCanonical ( index) = result_value {
444- // in which case we would set `canonical_vars[0]` to `Some('static)`.
445- opt_values[ index] = Some ( * original_value) ;
446+ if let & ty:: RegionKind :: ReLateBound ( index, br) = result_value {
447+ // ... in which case we would set `canonical_vars[0]` to `Some('static)`.
448+
449+ // We only allow a `ty::INNERMOST` index in substitutions.
450+ assert_eq ! ( index, ty:: INNERMOST ) ;
451+ opt_values[ br. as_bound_var ( ) ] = Some ( * original_value) ;
446452 }
447453 }
448454 }
@@ -525,21 +531,23 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
525531 . iter ( )
526532 . map ( move |constraint| {
527533 let ty:: OutlivesPredicate ( k1, r2) = constraint. skip_binder ( ) ; // restored below
528- let k1 = substitute_value ( self . tcx , result_subst, k1 ) ;
529- let r2 = substitute_value ( self . tcx , result_subst, r2 ) ;
534+ let k1 = substitute_value ( self . tcx , result_subst, & ty :: Binder :: bind ( * k1 ) ) ;
535+ let r2 = substitute_value ( self . tcx , result_subst, & ty :: Binder :: bind ( * r2 ) ) ;
530536
531537 Obligation :: new (
532538 cause. clone ( ) ,
533539 param_env,
534- match k1. unpack ( ) {
540+ match k1. skip_binder ( ) . unpack ( ) {
535541 UnpackedKind :: Lifetime ( r1) => ty:: Predicate :: RegionOutlives (
536- ty:: Binder :: dummy (
537- ty:: OutlivesPredicate ( r1, r2)
538- ) ) ,
542+ ty:: Binder :: bind (
543+ ty:: OutlivesPredicate ( r1, r2. skip_binder ( ) )
544+ )
545+ ) ,
539546 UnpackedKind :: Type ( t1) => ty:: Predicate :: TypeOutlives (
540- ty:: Binder :: dummy ( ty:: OutlivesPredicate (
541- t1, r2
542- ) ) )
547+ ty:: Binder :: bind (
548+ ty:: OutlivesPredicate ( t1, r2. skip_binder ( ) )
549+ )
550+ ) ,
543551 }
544552 )
545553 } )
@@ -621,11 +629,11 @@ pub fn make_query_outlives<'tcx>(
621629 }
622630 Constraint :: RegSubReg ( r1, r2) => ty:: OutlivesPredicate ( r2. into ( ) , r1) ,
623631 } )
624- . map ( ty:: Binder :: dummy) // no bound regions in the code above
632+ . map ( ty:: Binder :: dummy) // no bound vars in the code above
625633 . chain (
626634 outlives_obligations
627635 . map ( |( ty, r) | ty:: OutlivesPredicate ( ty. into ( ) , r) )
628- . map ( ty:: Binder :: dummy) , // no bound regions in the code above
636+ . map ( ty:: Binder :: dummy) // no bound vars in the code above
629637 )
630638 . collect ( ) ;
631639
0 commit comments