Skip to content

Commit f8f8033

Browse files
committed
assert that types without discriminant use variant idx of 0
1 parent 5a3971c commit f8f8033

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
596596
Scalar::from_uint(discr.val, discr_layout.size)
597597
}
598598
None => {
599-
// On a type without actual discriminants, return variant idx as `u8`.
599+
// On a type without actual discriminants, variant is 0. Return variant idx as `u8`.
600+
assert_eq!(index.as_u32(), 0);
600601
let discr_layout = self.layout_of(self.tcx.types.u8)?;
601602
Scalar::from_uint(index.as_u32(), discr_layout.size)
602603
}

0 commit comments

Comments
 (0)