Skip to content

Commit 001cea4

Browse files
committed
[const-prop] Expand comment about casting ZST enums
1 parent 1886985 commit 001cea4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/librustc_mir/transform/const_prop.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
554554
this.ecx.read_immediate(this.ecx.eval_operand(op, None)?)
555555
})?;
556556

557-
// Do not try to read bits for ZSTs
557+
// Do not try to read bits for ZSTs. This can occur when casting an enum with one variant
558+
// to an integer. Such enums are represented as ZSTs but still have a discriminant value
559+
// which can be casted.
558560
if value.layout.is_zst() {
559561
return Some(());
560562
}

0 commit comments

Comments
 (0)