Simplify code further
This commit is contained in:
parent
c3fe2590f5
commit
ca328e1bb4
2 changed files with 11 additions and 26 deletions
|
@ -242,20 +242,14 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
let lvalue = self.trans_lvalue(&bcx, location);
|
||||
let mut lvalue = self.trans_lvalue(&bcx, location);
|
||||
let drop_fn = glue::get_drop_glue(bcx.ccx, ty);
|
||||
let drop_ty = glue::get_drop_glue_type(bcx.ccx.shared(), ty);
|
||||
let ptr = if bcx.ccx.shared().type_is_sized(ty) {
|
||||
let value = if drop_ty != ty {
|
||||
bcx.pointercast(lvalue.llval, type_of::type_of(bcx.ccx, drop_ty).ptr_to())
|
||||
} else {
|
||||
lvalue.llval
|
||||
};
|
||||
LvalueRef::new_sized_ty(value, ty)
|
||||
} else {
|
||||
LvalueRef::new_unsized_ty(lvalue.llval, lvalue.llextra, ty)
|
||||
};
|
||||
let args = &[ptr.llval, ptr.llextra][..1 + ptr.has_extra() as usize];
|
||||
if bcx.ccx.shared().type_is_sized(ty) && drop_ty != ty {
|
||||
lvalue.llval = bcx.pointercast(
|
||||
lvalue.llval, type_of::type_of(bcx.ccx, drop_ty).ptr_to());
|
||||
}
|
||||
let args = &[lvalue.llval, lvalue.llextra][..1 + lvalue.has_extra() as usize];
|
||||
if let Some(unwind) = unwind {
|
||||
bcx.invoke(
|
||||
drop_fn,
|
||||
|
|
|
@ -50,13 +50,6 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
|
|||
LvalueRef::new_sized(llval, LvalueTy::from_ty(ty))
|
||||
}
|
||||
|
||||
pub fn new_unsized(llval: ValueRef, llextra: ValueRef, ty: LvalueTy<'tcx>) -> LvalueRef<'tcx> {
|
||||
LvalueRef {
|
||||
llval: llval,
|
||||
llextra: llextra,
|
||||
ty: ty,
|
||||
}
|
||||
}
|
||||
pub fn new_unsized_ty(llval: ValueRef, llextra: ValueRef, ty: Ty<'tcx>) -> LvalueRef<'tcx> {
|
||||
LvalueRef {
|
||||
llval: llval,
|
||||
|
@ -81,7 +74,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
|
|||
!self.llextra.is_null()
|
||||
}
|
||||
|
||||
pub fn struct_field_ptr(
|
||||
fn struct_field_ptr(
|
||||
self,
|
||||
bcx: &Builder<'a, 'tcx>,
|
||||
st: &layout::Struct,
|
||||
|
@ -298,14 +291,12 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
|
|||
let (llprojected, llextra) = match projection.elem {
|
||||
mir::ProjectionElem::Deref => bug!(),
|
||||
mir::ProjectionElem::Field(ref field, _) => {
|
||||
let is_sized = self.ccx.shared().type_is_sized(projected_ty.to_ty(tcx));
|
||||
let base = if is_sized {
|
||||
LvalueRef::new_sized(tr_base.llval, tr_base.ty)
|
||||
let llextra = if self.ccx.shared().type_is_sized(projected_ty.to_ty(tcx)) {
|
||||
ptr::null_mut()
|
||||
} else {
|
||||
LvalueRef::new_unsized(tr_base.llval, tr_base.llextra, tr_base.ty)
|
||||
tr_base.llextra
|
||||
};
|
||||
let llprojected = base.trans_field_ptr(bcx, field.index());
|
||||
(llprojected, base.llextra)
|
||||
(tr_base.trans_field_ptr(bcx, field.index()), llextra)
|
||||
}
|
||||
mir::ProjectionElem::Index(ref index) => {
|
||||
let index = self.trans_operand(bcx, index);
|
||||
|
|
Loading…
Add table
Reference in a new issue