use constraint sets for lhs contrained typevars

This commit is contained in:
Douglas Creager 2025-08-27 09:15:22 -04:00
parent c6f5bca2a8
commit 19c421a27b

View file

@ -1612,9 +1612,17 @@ impl<'db> Type<'db> {
.constraints(db) .constraints(db)
.when_some_and(|constraints| { .when_some_and(|constraints| {
constraints.iter().when_all(db, |constraint| { constraints.iter().when_all(db, |constraint| {
ConstraintSet::constrain_typevar(
db,
bound_typevar,
*constraint,
*constraint,
)
.implies(db, || {
self.has_relation_to_impl(db, *constraint, relation, visitor) self.has_relation_to_impl(db, *constraint, relation, visitor)
}) })
}) })
})
.is_never_satisfied() => .is_never_satisfied() =>
{ {
// TODO: The repetition here isn't great, but we really need the fallthrough logic, // TODO: The repetition here isn't great, but we really need the fallthrough logic,
@ -1626,9 +1634,17 @@ impl<'db> Type<'db> {
.constraints(db) .constraints(db)
.when_some_and(|constraints| { .when_some_and(|constraints| {
constraints.iter().when_all(db, |constraint| { constraints.iter().when_all(db, |constraint| {
ConstraintSet::constrain_typevar(
db,
bound_typevar,
*constraint,
*constraint,
)
.implies(db, || {
self.has_relation_to_impl(db, *constraint, relation, visitor) self.has_relation_to_impl(db, *constraint, relation, visitor)
}) })
}) })
})
} }
(Type::TypeVar(_), _) if relation.is_assignability() => { (Type::TypeVar(_), _) if relation.is_assignability() => {