Skip to content

Commit

Permalink
use pre-existing abi_align method instead of magic formula
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 9, 2017
1 parent 1844381 commit 8030800
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/lvalue.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -217,8 +217,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
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(),
};
Expand Down

0 comments on commit 8030800

Please sign in to comment.