Use Term in ProjectionPredicate
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
This commit is contained in:
parent
fb57b7518d
commit
67f56671d0
51 changed files with 274 additions and 259 deletions
|
@ -1304,7 +1304,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
debug!(
|
||||
"report_projection_error normalized_ty={:?} data.ty={:?}",
|
||||
normalized_ty, data.ty
|
||||
normalized_ty,
|
||||
data.term.ty()
|
||||
);
|
||||
|
||||
let is_normalized_ty_expected = !matches!(
|
||||
|
@ -1318,12 +1319,12 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
if let Err(error) = self.at(&obligation.cause, obligation.param_env).eq_exp(
|
||||
is_normalized_ty_expected,
|
||||
normalized_ty,
|
||||
data.ty,
|
||||
data.term.ty(),
|
||||
) {
|
||||
values = Some(infer::ValuePairs::Types(ExpectedFound::new(
|
||||
is_normalized_ty_expected,
|
||||
normalized_ty,
|
||||
data.ty,
|
||||
data.term.ty(),
|
||||
)));
|
||||
|
||||
err_buf = error;
|
||||
|
@ -1803,7 +1804,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
let self_ty = data.projection_ty.self_ty();
|
||||
let ty = data.ty;
|
||||
let ty = data.term.ty();
|
||||
if predicate.references_error() || self.is_tainted_by_errors() {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ fn project_and_unify_type<'cx, 'tcx>(
|
|||
let infcx = selcx.infcx();
|
||||
match infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.eq(normalized_ty, obligation.predicate.ty)
|
||||
.eq(normalized_ty, obligation.predicate.term.ty())
|
||||
{
|
||||
Ok(InferOk { obligations: inferred_obligations, value: () }) => {
|
||||
obligations.extend(inferred_obligations);
|
||||
|
@ -1615,7 +1615,7 @@ fn confirm_generator_candidate<'cx, 'tcx>(
|
|||
substs: trait_ref.substs,
|
||||
item_def_id: obligation.predicate.item_def_id,
|
||||
},
|
||||
ty,
|
||||
term: ty.into(),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1641,7 +1641,7 @@ fn confirm_discriminant_kind_candidate<'cx, 'tcx>(
|
|||
|
||||
let predicate = ty::ProjectionPredicate {
|
||||
projection_ty: ty::ProjectionTy { substs, item_def_id: discriminant_def_id },
|
||||
ty: self_ty.discriminant_ty(tcx),
|
||||
term: self_ty.discriminant_ty(tcx).into(),
|
||||
};
|
||||
|
||||
// We get here from `poly_project_and_unify_type` which replaces bound vars
|
||||
|
@ -1674,7 +1674,7 @@ fn confirm_pointee_candidate<'cx, 'tcx>(
|
|||
|
||||
let predicate = ty::ProjectionPredicate {
|
||||
projection_ty: ty::ProjectionTy { substs, item_def_id: metadata_def_id },
|
||||
ty: metadata_ty,
|
||||
term: metadata_ty.into(),
|
||||
};
|
||||
|
||||
confirm_param_env_candidate(selcx, obligation, ty::Binder::dummy(predicate), false)
|
||||
|
@ -1747,7 +1747,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
|
|||
substs: trait_ref.substs,
|
||||
item_def_id: fn_once_output_def_id,
|
||||
},
|
||||
ty: ret_type,
|
||||
term: ret_type.into(),
|
||||
});
|
||||
|
||||
confirm_param_env_candidate(selcx, obligation, predicate, true)
|
||||
|
@ -1803,7 +1803,7 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
|
|||
Ok(InferOk { value: _, obligations }) => {
|
||||
nested_obligations.extend(obligations);
|
||||
assoc_ty_own_obligations(selcx, obligation, &mut nested_obligations);
|
||||
Progress { ty: cache_entry.ty, obligations: nested_obligations }
|
||||
Progress { ty: cache_entry.term.ty(), obligations: nested_obligations }
|
||||
}
|
||||
Err(e) => {
|
||||
let msg = format!(
|
||||
|
|
|
@ -62,7 +62,7 @@ pub(crate) fn update<'tcx, T>(
|
|||
if let ty::PredicateKind::Projection(predicate) = obligation.predicate.kind().skip_binder() {
|
||||
// If the projection predicate (Foo::Bar == X) has X as a non-TyVid,
|
||||
// we need to make it into one.
|
||||
if let Some(vid) = predicate.ty.ty_vid() {
|
||||
if let Some(vid) = predicate.term.ty().ty_vid() {
|
||||
debug!("relationship: {:?}.output = true", vid);
|
||||
engine.relationships().entry(vid).or_default().output = true;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ pub fn predicate_obligations<'a, 'tcx>(
|
|||
}
|
||||
ty::PredicateKind::Projection(t) => {
|
||||
wf.compute_projection(t.projection_ty);
|
||||
wf.compute(t.ty.into());
|
||||
wf.compute(t.term.ty().into());
|
||||
}
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
wf.compute(arg);
|
||||
|
@ -219,7 +219,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
|||
// projection coming from another associated type. See
|
||||
// `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs` and
|
||||
// `traits-assoc-type-in-supertrait-bad.rs`.
|
||||
if let ty::Projection(projection_ty) = proj.ty.kind() {
|
||||
if let ty::Projection(projection_ty) = proj.term.ty().kind() {
|
||||
if let Some(&impl_item_id) =
|
||||
tcx.impl_item_implementor_ids(impl_def_id).get(&projection_ty.item_def_id)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue