Normalize obligations for closure confirmation
This commit is contained in:
parent
347d503333
commit
cacc3ee801
17 changed files with 263 additions and 87 deletions
|
@ -1734,7 +1734,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
|
|||
ty: ret_type,
|
||||
});
|
||||
|
||||
confirm_param_env_candidate(selcx, obligation, predicate, false)
|
||||
confirm_param_env_candidate(selcx, obligation, predicate, true)
|
||||
}
|
||||
|
||||
fn confirm_param_env_candidate<'cx, 'tcx>(
|
||||
|
@ -1754,8 +1754,18 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
|
|||
);
|
||||
|
||||
let cache_projection = cache_entry.projection_ty;
|
||||
let obligation_projection = obligation.predicate;
|
||||
let mut nested_obligations = Vec::new();
|
||||
let obligation_projection = obligation.predicate;
|
||||
let obligation_projection = ensure_sufficient_stack(|| {
|
||||
normalize_with_depth_to(
|
||||
selcx,
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
obligation_projection,
|
||||
&mut nested_obligations,
|
||||
)
|
||||
});
|
||||
let cache_projection = if potentially_unnormalized_candidate {
|
||||
ensure_sufficient_stack(|| {
|
||||
normalize_with_depth_to(
|
||||
|
@ -1771,6 +1781,8 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
|
|||
cache_projection
|
||||
};
|
||||
|
||||
debug!(?cache_projection, ?obligation_projection);
|
||||
|
||||
match infcx.at(cause, param_env).eq(cache_projection, obligation_projection) {
|
||||
Ok(InferOk { value: _, obligations }) => {
|
||||
nested_obligations.extend(obligations);
|
||||
|
|
|
@ -620,23 +620,37 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
_ => bug!("closure candidate for non-closure {:?}", obligation),
|
||||
};
|
||||
|
||||
let obligation_predicate = obligation.predicate.to_poly_trait_ref();
|
||||
let Normalized { value: obligation_predicate, mut obligations } =
|
||||
ensure_sufficient_stack(|| {
|
||||
normalize_with_depth(
|
||||
self,
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
obligation_predicate,
|
||||
)
|
||||
});
|
||||
|
||||
let trait_ref = self.closure_trait_ref_unnormalized(obligation, substs);
|
||||
let Normalized { value: trait_ref, mut obligations } = ensure_sufficient_stack(|| {
|
||||
normalize_with_depth(
|
||||
self,
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
trait_ref,
|
||||
)
|
||||
});
|
||||
let Normalized { value: trait_ref, obligations: trait_ref_obligations } =
|
||||
ensure_sufficient_stack(|| {
|
||||
normalize_with_depth(
|
||||
self,
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
trait_ref,
|
||||
)
|
||||
});
|
||||
|
||||
debug!(?closure_def_id, ?trait_ref, ?obligations, "confirm closure candidate obligations");
|
||||
|
||||
obligations.extend(trait_ref_obligations);
|
||||
obligations.extend(self.confirm_poly_trait_refs(
|
||||
obligation.cause.clone(),
|
||||
obligation.param_env,
|
||||
obligation.predicate.to_poly_trait_ref(),
|
||||
obligation_predicate,
|
||||
trait_ref,
|
||||
)?);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue