@@ -310,16 +310,18 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
310
310
}
311
311
312
312
// ...also include the other query region constraints from the query.
313
- output_query_region_constraints. reserve ( query_result. value . region_constraints . len ( ) ) ;
314
- for r_c in query_result. value . region_constraints . iter ( ) {
315
- let & ty:: OutlivesPredicate ( k1, r2) = r_c. skip_binder ( ) ; // reconstructed below
316
- let k1 = substitute_value ( self . tcx , & result_subst, & k1) ;
317
- let r2 = substitute_value ( self . tcx , & result_subst, & r2) ;
318
- if k1 != r2. into ( ) {
319
- output_query_region_constraints
320
- . push ( ty:: Binder :: bind ( ty:: OutlivesPredicate ( k1, r2) ) ) ;
321
- }
322
- }
313
+ output_query_region_constraints. extend (
314
+ query_result. value . region_constraints . iter ( ) . filter_map ( |r_c| {
315
+ let & ty:: OutlivesPredicate ( k1, r2) = r_c. skip_binder ( ) ; // reconstructed below
316
+ let k1 = substitute_value ( self . tcx , & result_subst, & k1) ;
317
+ let r2 = substitute_value ( self . tcx , & result_subst, & r2) ;
318
+ if k1 != r2. into ( ) {
319
+ Some ( ty:: Binder :: bind ( ty:: OutlivesPredicate ( k1, r2) ) )
320
+ } else {
321
+ None
322
+ }
323
+ } )
324
+ ) ;
323
325
324
326
let user_result: R =
325
327
query_result. substitute_projected ( self . tcx , & result_subst, |q_r| & q_r. value ) ;
@@ -576,31 +578,30 @@ pub fn make_query_outlives<'tcx>(
576
578
assert ! ( verifys. is_empty( ) ) ;
577
579
assert ! ( givens. is_empty( ) ) ;
578
580
579
- let mut outlives: Vec < _ > = constraints
580
- . into_iter ( )
581
- . map ( |( k, _) | match * k {
582
- // Swap regions because we are going from sub (<=) to outlives
583
- // (>=).
584
- Constraint :: VarSubVar ( v1, v2) => ty:: OutlivesPredicate (
585
- tcx. mk_region ( ty:: ReVar ( v2) ) . into ( ) ,
586
- tcx. mk_region ( ty:: ReVar ( v1) ) ,
587
- ) ,
588
- Constraint :: VarSubReg ( v1, r2) => {
589
- ty:: OutlivesPredicate ( r2. into ( ) , tcx. mk_region ( ty:: ReVar ( v1) ) )
590
- }
591
- Constraint :: RegSubVar ( r1, v2) => {
592
- ty:: OutlivesPredicate ( tcx. mk_region ( ty:: ReVar ( v2) ) . into ( ) , r1)
593
- }
594
- Constraint :: RegSubReg ( r1, r2) => ty:: OutlivesPredicate ( r2. into ( ) , r1) ,
595
- } )
596
- . map ( ty:: Binder :: dummy) // no bound regions in the code above
597
- . collect ( ) ;
598
-
599
- outlives. extend (
600
- outlives_obligations
601
- . map ( |( ty, r) | ty:: OutlivesPredicate ( ty. into ( ) , r) )
602
- . map ( ty:: Binder :: dummy) , // no bound regions in the code above
603
- ) ;
581
+ let outlives: Vec < _ > = constraints
582
+ . into_iter ( )
583
+ . map ( |( k, _) | match * k {
584
+ // Swap regions because we are going from sub (<=) to outlives
585
+ // (>=).
586
+ Constraint :: VarSubVar ( v1, v2) => ty:: OutlivesPredicate (
587
+ tcx. mk_region ( ty:: ReVar ( v2) ) . into ( ) ,
588
+ tcx. mk_region ( ty:: ReVar ( v1) ) ,
589
+ ) ,
590
+ Constraint :: VarSubReg ( v1, r2) => {
591
+ ty:: OutlivesPredicate ( r2. into ( ) , tcx. mk_region ( ty:: ReVar ( v1) ) )
592
+ }
593
+ Constraint :: RegSubVar ( r1, v2) => {
594
+ ty:: OutlivesPredicate ( tcx. mk_region ( ty:: ReVar ( v2) ) . into ( ) , r1)
595
+ }
596
+ Constraint :: RegSubReg ( r1, r2) => ty:: OutlivesPredicate ( r2. into ( ) , r1) ,
597
+ } )
598
+ . map ( ty:: Binder :: dummy) // no bound regions in the code above
599
+ . chain (
600
+ outlives_obligations
601
+ . map ( |( ty, r) | ty:: OutlivesPredicate ( ty. into ( ) , r) )
602
+ . map ( ty:: Binder :: dummy) , // no bound regions in the code above
603
+ )
604
+ . collect ( ) ;
604
605
605
606
outlives
606
607
}
0 commit comments