Make InstantiatedPredicates impl IntoIterator
This commit is contained in:
parent
91fd862df0
commit
9b28edb6d7
12 changed files with 74 additions and 65 deletions
|
@ -82,9 +82,7 @@ pub fn recompute_applicable_impls<'tcx>(
|
|||
|
||||
let predicates =
|
||||
tcx.predicates_of(obligation.cause.body_id.owner.to_def_id()).instantiate_identity(tcx);
|
||||
for obligation in
|
||||
elaborate_predicates_with_span(tcx, std::iter::zip(predicates.predicates, predicates.spans))
|
||||
{
|
||||
for obligation in elaborate_predicates_with_span(tcx, predicates.into_iter()) {
|
||||
let kind = obligation.predicate.kind();
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) = kind.skip_binder()
|
||||
&& param_env_candidate_may_apply(kind.rebind(trait_pred))
|
||||
|
|
|
@ -2070,7 +2070,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
// Find another predicate whose self-type is equal to the expected self type,
|
||||
// but whose substs don't match.
|
||||
let other_pred = std::iter::zip(&predicates.predicates, &predicates.spans)
|
||||
let other_pred = predicates.into_iter()
|
||||
.enumerate()
|
||||
.find(|(other_idx, (pred, _))| match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred))
|
||||
|
@ -2095,7 +2095,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
// If we found one, then it's very likely the cause of the error.
|
||||
if let Some((_, (_, other_pred_span))) = other_pred {
|
||||
err.span_note(
|
||||
*other_pred_span,
|
||||
other_pred_span,
|
||||
"closure inferred to have a different signature due to this bound",
|
||||
);
|
||||
}
|
||||
|
|
|
@ -115,14 +115,12 @@ pub fn predicates_for_generics<'tcx>(
|
|||
param_env: ty::ParamEnv<'tcx>,
|
||||
generic_bounds: ty::InstantiatedPredicates<'tcx>,
|
||||
) -> impl Iterator<Item = PredicateObligation<'tcx>> {
|
||||
std::iter::zip(generic_bounds.predicates, generic_bounds.spans).enumerate().map(
|
||||
move |(idx, (predicate, span))| Obligation {
|
||||
cause: cause(idx, span),
|
||||
recursion_depth: 0,
|
||||
param_env,
|
||||
predicate,
|
||||
},
|
||||
)
|
||||
generic_bounds.into_iter().enumerate().map(move |(idx, (predicate, span))| Obligation {
|
||||
cause: cause(idx, span),
|
||||
recursion_depth: 0,
|
||||
param_env,
|
||||
predicate,
|
||||
})
|
||||
}
|
||||
|
||||
/// Determines whether the type `ty` is known to meet `bound` and
|
||||
|
|
|
@ -2259,25 +2259,23 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
|
|||
tcx.predicates_of(impl_fn_def_id).instantiate(tcx, impl_fn_substs),
|
||||
&mut obligations,
|
||||
);
|
||||
obligations.extend(std::iter::zip(predicates.predicates, predicates.spans).map(
|
||||
|(pred, span)| {
|
||||
Obligation::with_depth(
|
||||
tcx,
|
||||
ObligationCause::new(
|
||||
obligation.cause.span,
|
||||
obligation.cause.body_id,
|
||||
if span.is_dummy() {
|
||||
super::ItemObligation(impl_fn_def_id)
|
||||
} else {
|
||||
super::BindingObligation(impl_fn_def_id, span)
|
||||
},
|
||||
),
|
||||
obligation.recursion_depth + 1,
|
||||
obligation.param_env,
|
||||
pred,
|
||||
)
|
||||
},
|
||||
));
|
||||
obligations.extend(predicates.into_iter().map(|(pred, span)| {
|
||||
Obligation::with_depth(
|
||||
tcx,
|
||||
ObligationCause::new(
|
||||
obligation.cause.span,
|
||||
obligation.cause.body_id,
|
||||
if span.is_dummy() {
|
||||
super::ItemObligation(impl_fn_def_id)
|
||||
} else {
|
||||
super::BindingObligation(impl_fn_def_id, span)
|
||||
},
|
||||
),
|
||||
obligation.recursion_depth + 1,
|
||||
obligation.param_env,
|
||||
pred,
|
||||
)
|
||||
}));
|
||||
|
||||
let ty = normalize_with_depth_to(
|
||||
selcx,
|
||||
|
|
|
@ -736,7 +736,7 @@ impl<'tcx> WfPredicates<'tcx> {
|
|||
trace!("{:#?}", predicates);
|
||||
debug_assert_eq!(predicates.predicates.len(), origins.len());
|
||||
|
||||
iter::zip(iter::zip(predicates.predicates, predicates.spans), origins.into_iter().rev())
|
||||
iter::zip(predicates, origins.into_iter().rev())
|
||||
.map(|((mut pred, span), origin_def_id)| {
|
||||
let code = if span.is_dummy() {
|
||||
traits::ItemObligation(origin_def_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue