That's what "huge cache" means. People keep using array lengths directly as a problem but remember you can compute arbitrary types from such constants with associated types and those are not cached across crates, but non-deterministic CTFE could break the typesystem if any query ever executed isn't cached and reused
If you have a conflict between sibling crates you must deny linking them, otherwise they could interpret the same associated type as different types.
I don't think "huge cache" would be exactly the same as what /u/tending suggested. "Huge cache", if I understand correctly, would imply that the following would have the same type signatures:
fn f(t: &[T; random()])
fn g(t: &[T; random()])
Whereas I would interpret /u/tending such as they would have different type signatures.
I think the disconnect here comes from that people (including me) would have expected that each type declaration is evaluated exactly once during compilation, but apparently that is not the case?
That's not the kind of function we're worried about (we can actually make those cases work, they're not much worse than include_str! etc.), think more:
fn f<T>(t: &[T; random() % size_of::<T>()])
That is, the call is evaluated from application of generics. There's an even worse one based on associated types, but I don't have the link on hand.
12
u/eddyb Jul 19 '18 edited Jul 20 '18
That's what "huge cache" means. People keep using array lengths directly as a problem but remember you can compute arbitrary types from such constants with associated typesand those are not cached across crates, but non-deterministic CTFE could break the typesystem ifanyquery ever executed isn't cached and reusedIf you have a conflict between sibling crates youmustdeny linking them, otherwise they could interpret the same associated type as different types.EDIT: please refer to https://www.reddit.com/r/rust/comments/907a6d/thoughts_on_compiletime_function_evaluation_and/e2pdqnt/ instead