1
Fork 0

fix safe-transmute handling of enums

This commit is contained in:
Ralf Jung 2024-11-30 19:33:23 +01:00
parent a36652c274
commit 611a99188e
7 changed files with 74 additions and 63 deletions

View file

@ -1505,7 +1505,11 @@ impl BackendRepr {
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
/// Single enum variants, structs/tuples, unions, and all non-ADTs.
Single { index: VariantIdx },
Single {
/// Always 0 for non-enums/generators.
/// For enums without a variant, this is an invalid index!
index: VariantIdx,
},
/// Enum-likes with more than one variant: each variant comes with
/// a *discriminant* (usually the same as the variant index but the user can