Use total size instead of max variant size in aggregates.

This commit is contained in:
Scott Olson 2016-03-17 04:57:50 -06:00
parent 573c11cef5
commit 432619ea5e
2 changed files with 4 additions and 4 deletions

View file

@ -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,
}

View 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 @@ 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,