Closed
Description
In #73137 (comment), an invalid Downcast
is being generated for the generator state enum (the wrong variant is used). The MIR interpreter code doesn't actually verify that the expected and actual discriminants match when performing a Downcast
. While doing this would not have caught the previous issue, it would allow us to detect U.B. at the point where it actually occurs, rather than needing to wait for invalid data to be read due to the wrong downcast.
This would require us to do several operations where we currently just change the layout of an MPlaceTy
, so it might make sense to only run this check in Miri (not normal const-eval).