In the past there’s been proposals to add new kinds of references for handling uninitialized data. This is a feature I’d really like and I think I could put together an RFC for it, but I’m wondering if it’s something that’s likely to get attention anytime in the near future or if the RFC would just collect dust.
Very briefly: my proposal would be to add three new kinds references:
&out T: data must be moved out from the reference before the end of the region, leaving the reference uninitialized.
&in T: the reference is initially uninitialized and data must be moved into it before the end of the region.
&uninit T: the reference is initially uninitialized and must be left uninitialized at the end of the region, but can be used as temporary storage in the mean time.
I think it’s possible to make these work alongside unwinding without needing linear types, though there may be complications I’m not seeing (discussions welcome!). I’m just wondering whether, with the other work that’s going on in the compiler at the moment, this is a good time to push this or whether to wait another year.