@@ -308,12 +308,14 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
308
308
// ...also include the other query region constraints from the query.
309
309
output_query_region_constraints. extend (
310
310
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, & 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) )
311
+ let r_c = substitute_value ( self . tcx , & result_subst, r_c) ;
312
+
313
+ // Screen out `'a: 'a` cases -- we skip the binder here but
314
+ // only care the inner values to one another, so they are still at
315
+ // consistent binding levels.
316
+ let & ty:: OutlivesPredicate ( k1, r2) = r_c. skip_binder ( ) ;
317
+ if k1 != r2. into ( ) {
318
+ Some ( r_c)
317
319
} else {
318
320
None
319
321
}
@@ -530,22 +532,21 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
530
532
unsubstituted_region_constraints
531
533
. iter ( )
532
534
. map ( move |constraint| {
533
- let ty:: OutlivesPredicate ( k1, r2) = constraint. skip_binder ( ) ; // restored below
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) ) ;
535
+ let constraint = substitute_value ( self . tcx , result_subst, constraint) ;
536
+ let & ty:: OutlivesPredicate ( k1, r2) = constraint. skip_binder ( ) ; // restored below
536
537
537
538
Obligation :: new (
538
539
cause. clone ( ) ,
539
540
param_env,
540
- match k1. skip_binder ( ) . unpack ( ) {
541
+ match k1. unpack ( ) {
541
542
UnpackedKind :: Lifetime ( r1) => ty:: Predicate :: RegionOutlives (
542
543
ty:: Binder :: bind (
543
- ty:: OutlivesPredicate ( r1, r2. skip_binder ( ) )
544
+ ty:: OutlivesPredicate ( r1, r2)
544
545
)
545
546
) ,
546
547
UnpackedKind :: Type ( t1) => ty:: Predicate :: TypeOutlives (
547
548
ty:: Binder :: bind (
548
- ty:: OutlivesPredicate ( t1, r2. skip_binder ( ) )
549
+ ty:: OutlivesPredicate ( t1, r2)
549
550
)
550
551
) ,
551
552
}
0 commit comments