minirust icon indicating copy to clipboard operation
minirust copied to clipboard

In SetDiscriminant, validate that a subsequent GetDiscriminant produces the right result

Open RalfJung opened this issue 10 months ago • 0 comments

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.

RalfJung avatar Apr 19 '24 15:04 RalfJung