From ee209ccd74eb9d1266046782645974694bc9fa1a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 13 Jul 2017 20:39:49 -0700 Subject: [PATCH] fix handling univariant enums (62) --- src/librustc_mir/interpret/lvalue.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/lvalue.rs b/src/librustc_mir/interpret/lvalue.rs index 60ce28f82323..f2eacd594ae0 100644 --- a/src/librustc_mir/interpret/lvalue.rs +++ b/src/librustc_mir/interpret/lvalue.rs @@ -652,8 +652,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let variant = &adt.variants[variant_idx]; if variant.fields.len() > 0 { - // Downcast to this variant - let lvalue = self.eval_lvalue_projection(lvalue, ty, &mir::ProjectionElem::Downcast(adt, variant_idx))?; + // Downcast to this variant, if needed + let lvalue = if adt.variants.len() > 1 { + self.eval_lvalue_projection(lvalue, ty, &mir::ProjectionElem::Downcast(adt, variant_idx))? + } else { + lvalue + }; // Recursively validate the fields self.validate_variant(lvalue, ty, variant, subst, vctx)