minirust
minirust copied to clipboard
Support enums
We don't support encoding or decoding enums yet. Some interesting questions will arise when adding them.
Relevant material:
- https://github.com/camelid/type-layout by @camelid
- a very WIP writeup by @JakobDegen suggesting "DSLs" for describing very general encoding and decoding strategies for enums
Fwiw that document is not so WIP anymore, I went through and fixed a bunch of stuff at some point. Now it's just long :stuck_out_tongue:
Support for enums was added in the following PRs:
- Enum variant ValueExpr
- Enum memory representation and well-formedness
- Enum Downcast
- Enum GetDiscriminant and SetDiscriminant
- Switch terminator
- Alignment-check fixes (mainly around enums)
- Changes to discriminant handling
- Minimize support for everything enum related but niche tag encoding
- Minimize support for niche tag encoded enums
Currently the only enums that cannot be minimized are exponentially nested enums (each enum has four variants with one field of the nested enum, see tests/pass/enums.rs
) due to minimize always recompiling the type, and Option<NonZeroINT>::None
, which gets transformed into a Scalar Value that minimize would have to parse.
One point I recently noticed is still missing is enums inside unions: mark_used_bytes
does not support enums yet.
and Option<NonZeroINT>::None, which gets transformed into a Scalar Value that minimize would have to parse.
That issue is tracked separately in https://github.com/minirust/minirust/issues/158.
I opened https://github.com/minirust/minirust/issues/167 for the enum-in-union issue. This one here can be closed then, thanks to @essickmango. :)