From 432619ea5eda876a510c39699a362f87a42b38b5 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Thu, 17 Mar 2016 04:57:50 -0600 Subject: [PATCH] Use total size instead of max variant size in aggregates. --- src/interpreter.rs | 2 +- src/memory.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index ff54f18f755f..2ccd5adeecbf 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -576,7 +576,7 @@ impl<'a, 'tcx: 'a> Interpreter<'a, 'tcx> { }; Repr::Aggregate { discr_size: discr_size, - max_variant_size: max_variant_size, + size: max_variant_size + discr_size, variants: variants, } diff --git a/src/memory.rs b/src/memory.rs index a2632007d802..667f28e987c2 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -54,8 +54,8 @@ pub enum Repr { /// structs and tuples. discr_size: usize, - /// The size of the largest variant in bytes. - max_variant_size: usize, + /// The size of the entire aggregate, including the discriminant. + size: usize, /// The representations of the contents of each variant. variants: Vec>, @@ -366,7 +366,7 @@ impl Repr { pub fn size(&self) -> usize { match *self { Repr::Primitive { size } => size, - Repr::Aggregate { discr_size, max_variant_size, .. } => discr_size + max_variant_size, + Repr::Aggregate { size, .. } => size, Repr::Array { elem_size, length } => elem_size * length, Repr::Pointer => POINTER_SIZE, Repr::FatPointer => POINTER_SIZE * 2,