From 8030800b15931f50dbe8944addc1afb4c3750a67 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 9 Feb 2017 08:50:35 +0100 Subject: [PATCH] use pre-existing `abi_align` method instead of magic formula --- src/lvalue.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lvalue.rs b/src/lvalue.rs index 2cce67689d7..e86c480aa0b 100644 --- a/src/lvalue.rs +++ b/src/lvalue.rs @@ -1,6 +1,6 @@ use rustc::hir::def_id::DefId; use rustc::mir; -use rustc::ty::layout::Size; +use rustc::ty::layout::{Size, Align}; use rustc::ty::subst::Substs; use rustc::ty::{self, Ty}; use rustc_data_structures::indexed_vec::Idx; @@ -217,8 +217,7 @@ fn eval_lvalue_projection( let offset = match base_extra { LvalueExtra::Vtable(tab) => { let (_, align) = self.size_and_align_of_dst(base_ty, Value::ByValPair(PrimVal::Ptr(base_ptr), PrimVal::Ptr(tab)))?; - // magical formula taken from rustc - (offset.bytes() + (align - 1)) & (-(align as i64) as u64) + offset.abi_align(Align::from_bytes(align, align).unwrap()).bytes() } _ => offset.bytes(), };