Skip to content

Commit

Permalink
[const-prop] Expand comment about casting ZST enums
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Dec 31, 2019
1 parent 1886985 commit 001cea4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/librustc_mir/transform/const_prop.rs
Expand Up @@ -554,7 +554,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
this.ecx.read_immediate(this.ecx.eval_operand(op, None)?)
})?;

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

0 comments on commit 001cea4

Please sign in to comment.