allow eq constraints on associated constants by JulianKnodt · Pull Request #87648 · rust-lang/rust (original) (raw)
Hmmmm, I think if it's a useful tool to simplify implementations, then it's probably useful, but at the same time I can't really picture what a
TyKind::Const
means. Is it an instance of a type which is const? Or does it represent an abstract const instantiation of a type?
it is essentially the equivalent of a built-in struct Foo<T, const C: T>;
without the struct/Adt
.
think about it this way: before const generics we had typenum
, this is essentially typenum
but directly supported by the compiler. typenum
encodes constants in the type system, with TyKind::Const
we do the same thing. We don't have to support any surface syntax for this, so users can't impl Trait for 42 {}
, but the type system would support constants as first class types.
If we want to we could even represent it as such. So not even adding a TyKind::Const
, but having Foo
be a lang item in libcore that all const generics desugar to, but I fear that is just as much of a problem as making bool
an enum bool { true, false }
lang item. Nice from a cleanliness perspective, but impractical and a performance problem.