minirust
minirust copied to clipboard
In SetDiscriminant, validate that a subsequent GetDiscriminant produces the right result
SetDiscriminant can be a NOP when writing the discriminant of the niched variant in a niche-optimized enum. We still want it to be UB to call SetDiscriminant with such a variant when the enum does not actually encode that variant, so Miri reads the discriminant immediately after writing it, and raises UB if the value does not match. MiniRust should do the same.