Fix w/ comments
This commit is contained in:
parent
c654e4d6f4
commit
78fb74a600
40 changed files with 281 additions and 199 deletions
|
@ -1356,11 +1356,26 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
normalized_ty,
|
||||
data.term,
|
||||
) {
|
||||
values = Some(infer::ValuePairs::Terms(ExpectedFound::new(
|
||||
is_normalized_ty_expected,
|
||||
normalized_ty,
|
||||
data.term,
|
||||
)));
|
||||
values = Some(match (normalized_ty, data.term) {
|
||||
(ty::Term::Ty(normalized_ty), ty::Term::Ty(ty)) => {
|
||||
infer::ValuePairs::Types(ExpectedFound::new(
|
||||
is_normalized_ty_expected,
|
||||
normalized_ty,
|
||||
ty,
|
||||
))
|
||||
}
|
||||
(ty::Term::Const(normalized_ct), ty::Term::Const(ct)) => {
|
||||
infer::ValuePairs::Consts(ExpectedFound::new(
|
||||
is_normalized_ty_expected,
|
||||
normalized_ct,
|
||||
ct,
|
||||
))
|
||||
}
|
||||
(_, _) => span_bug!(
|
||||
obligation.cause.span,
|
||||
"found const or type where other expected"
|
||||
),
|
||||
});
|
||||
err_buf = error;
|
||||
err = &err_buf;
|
||||
}
|
||||
|
|
|
@ -199,61 +199,30 @@ fn project_and_unify_type<'cx, 'tcx>(
|
|||
let mut obligations = vec![];
|
||||
|
||||
let infcx = selcx.infcx();
|
||||
match obligation.predicate.term {
|
||||
ty::Term::Ty(obligation_pred_ty) => {
|
||||
let normalized_ty = match opt_normalize_projection_type(
|
||||
selcx,
|
||||
obligation.param_env,
|
||||
obligation.predicate.projection_ty,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth,
|
||||
&mut obligations,
|
||||
) {
|
||||
Ok(Some(n)) => n.ty().unwrap(),
|
||||
Ok(None) => return Ok(Ok(None)),
|
||||
Err(InProgress) => return Ok(Err(InProgress)),
|
||||
};
|
||||
debug!(?normalized_ty, ?obligations, "project_and_unify_type result");
|
||||
match infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.eq(normalized_ty, obligation_pred_ty)
|
||||
{
|
||||
Ok(InferOk { obligations: inferred_obligations, value: () }) => {
|
||||
obligations.extend(inferred_obligations);
|
||||
Ok(Ok(Some(obligations)))
|
||||
}
|
||||
Err(err) => {
|
||||
debug!("project_and_unify_type: equating types encountered error {:?}", err);
|
||||
Err(MismatchedProjectionTypes { err })
|
||||
}
|
||||
}
|
||||
let normalized = match opt_normalize_projection_type(
|
||||
selcx,
|
||||
obligation.param_env,
|
||||
obligation.predicate.projection_ty,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth,
|
||||
&mut obligations,
|
||||
) {
|
||||
Ok(Some(n)) => n,
|
||||
Ok(None) => return Ok(Ok(None)),
|
||||
Err(InProgress) => return Ok(Err(InProgress)),
|
||||
};
|
||||
debug!(?normalized, ?obligations, "project_and_unify_type result");
|
||||
match infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.eq(normalized, obligation.predicate.term)
|
||||
{
|
||||
Ok(InferOk { obligations: inferred_obligations, value: () }) => {
|
||||
obligations.extend(inferred_obligations);
|
||||
Ok(Ok(Some(obligations)))
|
||||
}
|
||||
ty::Term::Const(obligation_pred_const) => {
|
||||
let normalized_const = match opt_normalize_projection_type(
|
||||
selcx,
|
||||
obligation.param_env,
|
||||
obligation.predicate.projection_ty,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth,
|
||||
&mut obligations,
|
||||
) {
|
||||
Ok(Some(n)) => n.ct().unwrap(),
|
||||
Ok(None) => return Ok(Ok(None)),
|
||||
Err(InProgress) => return Ok(Err(InProgress)),
|
||||
};
|
||||
match infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.eq(normalized_const, obligation_pred_const)
|
||||
{
|
||||
Ok(InferOk { obligations: inferred_obligations, value: () }) => {
|
||||
obligations.extend(inferred_obligations);
|
||||
Ok(Ok(Some(obligations)))
|
||||
}
|
||||
Err(err) => {
|
||||
debug!("project_and_unify_type: equating consts encountered error {:?}", err);
|
||||
Err(MismatchedProjectionTypes { err })
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
debug!("project_and_unify_type: equating types encountered error {:?}", err);
|
||||
Err(MismatchedProjectionTypes { err })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -934,6 +903,8 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
|
|||
// created (and hence the new ones will quickly be
|
||||
// discarded as duplicated). But when doing trait
|
||||
// evaluation this is not the case, and dropping the trait
|
||||
// evaluations can causes ICEs (e.g., #43132).
|
||||
debug!(?ty, "found normalized ty");
|
||||
obligations.extend(ty.obligations);
|
||||
return Ok(Some(ty.value));
|
||||
}
|
||||
|
@ -1127,6 +1098,8 @@ fn project<'cx, 'tcx>(
|
|||
Ok(Projected::Progress(confirm_candidate(selcx, obligation, candidate)))
|
||||
}
|
||||
ProjectionCandidateSet::None => Ok(Projected::NoProgress(
|
||||
// FIXME(associated_const_generics): this may need to change in the future?
|
||||
// need to investigate whether or not this is fine.
|
||||
selcx
|
||||
.tcx()
|
||||
.mk_projection(obligation.predicate.item_def_id, obligation.predicate.substs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue