Skip to content

Commit d66bfe9

Browse files
committed
Force builtin traits to be non-enumerable
There's no way to enumerate all types these can apply to. Flounder if we have to prove that one of these traits applies to an inference variable.
1 parent d636c06 commit d66bfe9

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

chalk-solve/src/clauses/builtin_traits.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub fn add_builtin_program_clauses<I: Interner>(
2828
let ty = self_ty.kind(db.interner()).clone();
2929

3030
match well_known {
31+
// There are no builtin impls provided for the following traits:
32+
WellKnownTrait::Unpin | WellKnownTrait::Drop | WellKnownTrait::CoerceUnsized => (),
33+
// Built-in traits are non-enumerable.
34+
_ if self_ty.is_general_var(db.interner(), binders) => return Err(Floundered),
3135
WellKnownTrait::Sized => {
3236
sized::add_sized_program_clauses(db, builder, trait_ref, ty, binders)?;
3337
}
@@ -48,8 +52,6 @@ pub fn add_builtin_program_clauses<I: Interner>(
4852
WellKnownTrait::Generator => {
4953
generator::add_generator_program_clauses(db, builder, self_ty)?;
5054
}
51-
// There are no builtin impls provided for the following traits:
52-
WellKnownTrait::Unpin | WellKnownTrait::Drop | WellKnownTrait::CoerceUnsized => (),
5355
}
5456
Ok(())
5557
})

chalk-solve/src/clauses/builtin_traits/fn_family.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ pub fn add_fn_trait_program_clauses<I: Interner>(
156156
});
157157
Ok(())
158158
}
159-
// Function traits are non-enumerable
160-
TyKind::InferenceVar(..) | TyKind::BoundVar(_) | TyKind::Alias(..) => Err(Floundered),
161159
_ => Ok(()),
162160
}
163161
}

tests/test/cycle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ fn infinite_recursion() {
226226
fn cycle_with_ambiguity() {
227227
test! {
228228
program {
229-
#[non_enumerable]
230229
#[lang(sized)]
231230
trait Sized { }
232231
trait From<T> {}

tests/test/tuples.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ fn tuple_trait_impl() {
3939
fn tuples_are_copy() {
4040
test! {
4141
program {
42-
// FIXME: If we don't declare Copy non-enumerable, `exists<T> { T:
43-
// Copy }` gives wrong results, because it doesn't consider the
44-
// built-in impls.
45-
#[non_enumerable]
4642
#[lang(copy)]
4743
trait Copy { }
4844

@@ -107,8 +103,6 @@ fn tuples_are_sized() {
107103
program {
108104
#[lang(sized)]
109105
trait Sized { }
110-
111-
trait Foo {}
112106
}
113107

114108
goal {
@@ -179,7 +173,6 @@ fn tuples_are_sized() {
179173
fn tuples_are_clone() {
180174
test! {
181175
program {
182-
#[non_enumerable] // see above
183176
#[lang(clone)]
184177
trait Clone { }
185178

0 commit comments

Comments
 (0)