Closed ltratt closed 1 month ago
I suppose ideally we'd have a TiVec
whose index type (and thus max length too) is parameterised. The issue stems from the assumption that vector indices are usize
.
This seems OK to me. We just let the API do the external type safety, and internally you have to just be careful.
I suppose ideally we'd have a TiVec whose index type (and thus max length too) is parameterised. The issue stems from the assumption that vector indices are usize.
It's a surprisingly hard problem, in essence because trait implementations are sort-of global. I'm not sure that one can get the effect one would ideally like.
Oops! Force pushed cargo fmt
update.
TiVec
has the unfortunate property that it requires us to implementimpl From<usize> for *Idx
, which means we have a method which silently takes an arbitraryusize
and tries to squeeze it into au16
. Even though the method has a big warning on it, the nature of trait method resolution means that it's unlikely we'll notice that. TheFrom
is thus an unfortunate footgun.On reflection, I think we don't really need
TiVec
insidejit_ir/mod.rs
-- its main utility is to force users of the JIT IR to be careful with their use of types, which happens naturally because they're forced to use methods which take in, and return,*Idx
types. This commit thus de-TiVec
ifiesjit_ir/mod.rs
.