1
Fork 0

Allow WellFormed goals to be returned from relating in new solver

This commit is contained in:
Michael Goulet 2025-03-23 18:56:34 +00:00
parent 90f5eab952
commit 251455bcc5
3 changed files with 57 additions and 7 deletions

View file

@ -971,15 +971,17 @@ where
rhs: T,
) -> Result<(), NoSolution> {
let goals = self.delegate.relate(param_env, lhs, variance, rhs, self.origin_span)?;
if cfg!(debug_assertions) {
for g in goals.iter() {
match g.predicate.kind().skip_binder() {
ty::PredicateKind::Subtype { .. } | ty::PredicateKind::AliasRelate(..) => {}
p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
for &goal in goals.iter() {
let source = match goal.predicate.kind().skip_binder() {
ty::PredicateKind::Subtype { .. } | ty::PredicateKind::AliasRelate(..) => {
GoalSource::TypeRelating
}
}
// FIXME(-Znext-solver=coinductive): should these WF goals also be unproductive?
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
};
self.add_goal(source, goal);
}
self.add_goals(GoalSource::TypeRelating, goals);
Ok(())
}