Open
Description
This is motivated by rust-lang/rust#119674:
For a type like enum E { A, B(char) }
, currently SetDiscriminant(place, 1)
is just a NOP, since niche-encoded variants do not need to store the discriminant explicitly.
However, that means that SetDiscriminant; Discriminant
doesn't necessarily return the just-written discriminant, even for enums: we might be calling SetDiscriminant(place, 1)
on a place that doesn't actually carry the niched value, but it remains a NOP. That seems unfortunate.
I think it'd make sense if SetDiscriminant
on niched variants were to do the equivalent of read_discriminant
, and cause UB if the already encoded discriminant does not match the niched variant.
Metadata
Metadata
Assignees
Labels
No labels