1
Fork 0

Normalize obligations for closure confirmation

This commit is contained in:
jackh726 2021-08-28 17:48:30 -04:00
parent 347d503333
commit cacc3ee801
17 changed files with 263 additions and 87 deletions

View file

@ -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);