Auto merge of #30486 - nagisa:mir-fix-geps, r=luqmana

Fixes https://github.com/rust-lang/rust/issues/30474
This commit is contained in:
bors 2015-12-21 02:26:10 +00:00
commit c6079d0586

View File

@ -132,7 +132,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
mir::ProjectionElem::Index(ref index) => {
let index = self.trans_operand(bcx, index);
let llindex = self.prepare_index(bcx, index.immediate());
(build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
let zero = common::C_uint(bcx.ccx(), 0u64);
(build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
ptr::null_mut())
}
mir::ProjectionElem::ConstantIndex { offset,
@ -140,7 +141,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
min_length: _ } => {
let lloffset = common::C_u32(bcx.ccx(), offset);
let llindex = self.prepare_index(bcx, lloffset);
(build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
let zero = common::C_uint(bcx.ccx(), 0u64);
(build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
ptr::null_mut())
}
mir::ProjectionElem::ConstantIndex { offset,
@ -150,7 +152,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
let lllen = self.lvalue_len(bcx, tr_base);
let llindex = build::Sub(bcx, lllen, lloffset, DebugLoc::None);
let llindex = self.prepare_index(bcx, llindex);
(build::InBoundsGEP(bcx, tr_base.llval, &[llindex]),
let zero = common::C_uint(bcx.ccx(), 0u64);
(build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]),
ptr::null_mut())
}
mir::ProjectionElem::Downcast(..) => {