External Publication
Visit Post

For structs that have fields that have only one possible representation, enums should use that field as the discriminant

Rust Internals [Unofficial] June 8, 2026
Source

kpreid:

It is similar to the case of wanting to collapse two non-overlapping enums:

This is a harder problem, because it requires range discriminants.

If there's one spot with a single value per variant, that's something that could "just work" already if the layout algorithm can find it and put it in the https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/enum.Variants.html#variant.Multiple.field.tag_field.

Discussion in the ATmosphere

Loading comments...