Set groundwork for proper const normalization
This commit is contained in:
@@ -19,19 +19,25 @@ where
|
||||
goal: Goal<I, ty::NormalizesTo<I>>,
|
||||
) -> QueryResult<I> {
|
||||
let cx = self.cx();
|
||||
let free_ty = goal.predicate.alias;
|
||||
let free_alias = goal.predicate.alias;
|
||||
|
||||
// Check where clauses
|
||||
self.add_goals(
|
||||
GoalSource::Misc,
|
||||
cx.predicates_of(free_ty.def_id)
|
||||
.iter_instantiated(cx, free_ty.args)
|
||||
cx.predicates_of(free_alias.def_id)
|
||||
.iter_instantiated(cx, free_alias.args)
|
||||
.map(|pred| goal.with(cx, pred)),
|
||||
);
|
||||
|
||||
let actual = cx.type_of(free_ty.def_id).instantiate(cx, free_ty.args);
|
||||
self.instantiate_normalizes_to_term(goal, actual.into());
|
||||
let actual = if free_alias.kind(cx).is_type() {
|
||||
cx.type_of(free_alias.def_id).instantiate(cx, free_alias.args)
|
||||
} else {
|
||||
// FIXME(mgca): once const items are actual aliases defined as equal to type system consts
|
||||
// this should instead return that.
|
||||
panic!("normalizing free const aliases in the type system is unsupported");
|
||||
};
|
||||
|
||||
self.instantiate_normalizes_to_term(goal, actual.into());
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ where
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
{
|
||||
pub(super) fn normalize_inherent_associated_type(
|
||||
pub(super) fn normalize_inherent_associated_term(
|
||||
&mut self,
|
||||
goal: Goal<I, ty::NormalizesTo<I>>,
|
||||
) -> QueryResult<I> {
|
||||
let cx = self.cx();
|
||||
let inherent = goal.predicate.alias.expect_ty(cx);
|
||||
let inherent = goal.predicate.alias;
|
||||
|
||||
let impl_def_id = cx.parent(inherent.def_id);
|
||||
let impl_args = self.fresh_args_for_item(impl_def_id);
|
||||
@@ -48,8 +48,13 @@ where
|
||||
.map(|pred| goal.with(cx, pred)),
|
||||
);
|
||||
|
||||
let normalized = cx.type_of(inherent.def_id).instantiate(cx, inherent_args);
|
||||
self.instantiate_normalizes_to_term(goal, normalized.into());
|
||||
let normalized = if inherent.kind(cx).is_type() {
|
||||
cx.type_of(inherent.def_id).instantiate(cx, inherent_args).into()
|
||||
} else {
|
||||
// FIXME(mgca): Properly handle IACs in the type system
|
||||
panic!("normalizing inherent associated consts in the type system is unsupported");
|
||||
};
|
||||
self.instantiate_normalizes_to_term(goal, normalized);
|
||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,13 @@ where
|
||||
})
|
||||
})
|
||||
}
|
||||
ty::AliasTermKind::InherentTy => self.normalize_inherent_associated_type(goal),
|
||||
ty::AliasTermKind::InherentTy | ty::AliasTermKind::InherentConst => {
|
||||
self.normalize_inherent_associated_term(goal)
|
||||
}
|
||||
ty::AliasTermKind::OpaqueTy => self.normalize_opaque_type(goal),
|
||||
ty::AliasTermKind::FreeTy => self.normalize_free_alias(goal),
|
||||
ty::AliasTermKind::FreeTy | ty::AliasTermKind::FreeConst => {
|
||||
self.normalize_free_alias(goal)
|
||||
}
|
||||
ty::AliasTermKind::UnevaluatedConst => self.normalize_anon_const(goal),
|
||||
}
|
||||
}
|
||||
@@ -333,6 +337,8 @@ where
|
||||
cx.type_of(target_item_def_id).map_bound(|ty| ty.into())
|
||||
}
|
||||
ty::AliasTermKind::ProjectionConst => {
|
||||
// FIXME(mgca): once const items are actual aliases defined as equal to type system consts
|
||||
// this should instead return that.
|
||||
if cx.features().associated_const_equality() {
|
||||
panic!("associated const projection is not supported yet")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user