Skip to content
Prev Previous commit
Next Next commit
assert that types without discriminant use variant idx of 0
  • Loading branch information
RalfJung committed May 25, 2020
commit f8f80334872cf63412b0fe2e79b87505af2ba6a1
3 changes: 2 additions & 1 deletion src/librustc_mir/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Scalar::from_uint(discr.val, discr_layout.size)
}
None => {
// On a type without actual discriminants, return variant idx as `u8`.
// On a type without actual discriminants, variant is 0. Return variant idx as `u8`.
assert_eq!(index.as_u32(), 0);
let discr_layout = self.layout_of(self.tcx.types.u8)?;
Scalar::from_uint(index.as_u32(), discr_layout.size)
}
Expand Down