@@ -36,6 +36,7 @@ use traits::{Obligation, ObligationCause, PredicateObligation};
3636use ty:: fold:: TypeFoldable ;
3737use ty:: subst:: { Kind , UnpackedKind } ;
3838use ty:: { self , BoundVar , Lift , Ty , TyCtxt } ;
39+ use util:: captures:: Captures ;
3940
4041impl < ' cx , ' gcx , ' tcx > InferCtxtBuilder < ' cx , ' gcx , ' tcx > {
4142 /// The "main method" for a canonicalized trait query. Given the
@@ -527,32 +528,30 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
527528 param_env : ty:: ParamEnv < ' tcx > ,
528529 unsubstituted_region_constraints : & ' a [ QueryRegionConstraint < ' tcx > ] ,
529530 result_subst : & ' a CanonicalVarValues < ' tcx > ,
530- ) -> impl Iterator < Item = PredicateObligation < ' tcx > > + ' a {
531- Box :: new (
532- unsubstituted_region_constraints
533- . iter ( )
534- . map ( move |constraint| {
535- let constraint = substitute_value ( self . tcx , result_subst, constraint) ;
536- let & ty:: OutlivesPredicate ( k1, r2) = constraint. skip_binder ( ) ; // restored below
537-
538- Obligation :: new (
539- cause. clone ( ) ,
540- param_env,
541- match k1. unpack ( ) {
542- UnpackedKind :: Lifetime ( r1) => ty:: Predicate :: RegionOutlives (
543- ty:: Binder :: bind (
544- ty:: OutlivesPredicate ( r1, r2)
545- )
546- ) ,
547- UnpackedKind :: Type ( t1) => ty:: Predicate :: TypeOutlives (
548- ty:: Binder :: bind (
549- ty:: OutlivesPredicate ( t1, r2)
550- )
551- ) ,
552- }
553- )
554- } )
555- ) as Box < dyn Iterator < Item = _ > >
531+ ) -> impl Iterator < Item = PredicateObligation < ' tcx > > + ' a + Captures < ' gcx > {
532+ unsubstituted_region_constraints
533+ . iter ( )
534+ . map ( move |constraint| {
535+ let constraint = substitute_value ( self . tcx , result_subst, constraint) ;
536+ let & ty:: OutlivesPredicate ( k1, r2) = constraint. skip_binder ( ) ; // restored below
537+
538+ Obligation :: new (
539+ cause. clone ( ) ,
540+ param_env,
541+ match k1. unpack ( ) {
542+ UnpackedKind :: Lifetime ( r1) => ty:: Predicate :: RegionOutlives (
543+ ty:: Binder :: bind (
544+ ty:: OutlivesPredicate ( r1, r2)
545+ )
546+ ) ,
547+ UnpackedKind :: Type ( t1) => ty:: Predicate :: TypeOutlives (
548+ ty:: Binder :: bind (
549+ ty:: OutlivesPredicate ( t1, r2)
550+ )
551+ ) ,
552+ }
553+ )
554+ } )
556555 }
557556
558557 /// Given two sets of values for the same set of canonical variables, unify them.
0 commit comments