From 001cea4ac46d05ccfea8b4239ed2730edd724a7f Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Sun, 29 Dec 2019 10:34:09 -0500 Subject: [PATCH] [const-prop] Expand comment about casting ZST enums --- src/librustc_mir/transform/const_prop.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 9f474d97afb1..723ca79fa99a 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -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(()); }