minirust icon indicating copy to clipboard operation
minirust copied to clipboard

Support enums

Open RalfJung opened this issue 2 years ago • 1 comments

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

RalfJung avatar Jul 10 '22 02:07 RalfJung

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:

JakobDegen avatar Jul 10 '22 09:07 JakobDegen

Support for enums was added in the following PRs:

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.

essickmango avatar Mar 25 '24 09:03 essickmango

One point I recently noticed is still missing is enums inside unions: mark_used_bytes does not support enums yet.

RalfJung avatar Mar 25 '24 10:03 RalfJung

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.

RalfJung avatar Mar 25 '24 10:03 RalfJung

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. :)

RalfJung avatar Mar 25 '24 10:03 RalfJung