Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infer: remove Box from a returned Iterator #56742

Merged
merged 1 commit into from
Dec 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions src/librustc/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use traits::{Obligation, ObligationCause, PredicateObligation};
use ty::fold::TypeFoldable;
use ty::subst::{Kind, UnpackedKind};
use ty::{self, BoundVar, Lift, Ty, TyCtxt};
use util::captures::Captures;

impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> {
/// The "main method" for a canonicalized trait query. Given the
Expand Down Expand Up @@ -527,32 +528,30 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
param_env: ty::ParamEnv<'tcx>,
unsubstituted_region_constraints: &'a [QueryRegionConstraint<'tcx>],
result_subst: &'a CanonicalVarValues<'tcx>,
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a {
Box::new(
unsubstituted_region_constraints
.iter()
.map(move |constraint| {
let constraint = substitute_value(self.tcx, result_subst, constraint);
let &ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below

Obligation::new(
cause.clone(),
param_env,
match k1.unpack() {
UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
ty::Binder::bind(
ty::OutlivesPredicate(r1, r2)
)
),
UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives(
ty::Binder::bind(
ty::OutlivesPredicate(t1, r2)
)
),
}
)
})
) as Box<dyn Iterator<Item = _>>
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'gcx> {
unsubstituted_region_constraints
.iter()
.map(move |constraint| {
let constraint = substitute_value(self.tcx, result_subst, constraint);
let &ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below

Obligation::new(
cause.clone(),
param_env,
match k1.unpack() {
UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
ty::Binder::bind(
ty::OutlivesPredicate(r1, r2)
)
),
UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives(
ty::Binder::bind(
ty::OutlivesPredicate(t1, r2)
)
),
}
)
})
}

/// Given two sets of values for the same set of canonical variables, unify them.
Expand Down