]> git.lizzy.rs Git - rust.git/commitdiff
Use total size instead of max variant size in aggregates.
authorScott Olson <scott@solson.me>
Thu, 17 Mar 2016 10:57:50 +0000 (04:57 -0600)
committerScott Olson <scott@solson.me>
Thu, 17 Mar 2016 10:57:50 +0000 (04:57 -0600)
src/interpreter.rs
src/memory.rs

index ff54f18f755f2f6b632e6bd3883da0c406f6be95..2ccd5adeecbf5980bb72d9ca336bf887c522ff4a 100644 (file)
@@ -576,7 +576,7 @@ fn make_aggregate_repr<V>(&self, variant_fields: V) -> Repr
         };
         Repr::Aggregate {
             discr_size: discr_size,
-            max_variant_size: max_variant_size,
+            size: max_variant_size + discr_size,
             variants: variants,
         }
 
index a2632007d802d8fa98c88f8c288fc9f7e26e8b32..667f28e987c2c804f3c3a3ee04dc1cdeb8bae7ea 100644 (file)
@@ -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<Vec<FieldRepr>>,
@@ -366,7 +366,7 @@ pub fn usize() -> Self {
     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,