Skip to content

Commit af3f907

Browse files
authored
Rollup merge of rust-lang#56742 - ljedrz:remove_query_response_box, r=oli-obk
infer: remove Box from a returned Iterator
2 parents 3552499 + 76cb35e commit af3f907

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

src/librustc/infer/canonical/query_response.rs

+25-26
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use traits::{Obligation, ObligationCause, PredicateObligation};
3636
use ty::fold::TypeFoldable;
3737
use ty::subst::{Kind, UnpackedKind};
3838
use ty::{self, BoundVar, Lift, Ty, TyCtxt};
39+
use util::captures::Captures;
3940

4041
impl<'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

Comments
 (0)