You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnfoo<T:Trait>() where [u8; <TasTrait>::ASSOC]:OtherTrait {}
7
+
```
8
+
9
+
Help, our `where`-bounds don't hold:
10
+
11
+
### ICE example
12
+
13
+
(first discussed in https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds )
14
+
15
+
Core example is:
16
+
17
+
```rust
18
+
traitFoo {
19
+
typeAssoc;
20
+
}
21
+
constfnbar<T>()
22
+
where
23
+
T:Foo<Assoc=T>,
24
+
{
25
+
...
26
+
}
27
+
fnfun1<T>
28
+
where
29
+
T:Foo<Assoc=T>,
30
+
[u8; bar::<T>()]:Sized,
31
+
{}
32
+
implFoofori32 {
33
+
typeAssoc=u32;
34
+
}
35
+
fnmain() {
36
+
fun1::<i32>();
37
+
}
38
+
```
39
+
40
+
* The problem here is that when you call `fun1::<i32>` you wind up with this unevaluated constant `bar::<T>()`.
41
+
* We type-check that constant when type-checking `fun1` and determine that the source code is well-typed, under the assumption that `T: Foo<Assoc = T>`
42
+
* But in the body of `main` we get two distinct things to prove:
43
+
*`i32: Foo<Assoc = i32>` — unprovable
44
+
*`[u8; bar::<i32>()]: Sized` — no longer well typed
45
+
* The current code considers them independently and may well ICE when evaluating the second one (not probably in this particular example) because it assumed that the body of a constant is well typed when evaluating.
46
+
47
+
### Possible solutions
48
+
49
+
- don't assume substituted anon consts to be well typed
50
+
- dangerous, may hide actual bugs
51
+
- change typeck to not evaluate constants before proving there `where`-bounds
0 commit comments