Skip to content

Commit bf5a462

Browse files
committed
Finish removing struct layout dependencies from glue.
1 parent 4c76b30 commit bf5a462

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/librustc/middle/trans/adt.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ fn struct_GEP(bcx: block, st: &Struct, val: ValueRef, ix: uint,
266266
GEPi(bcx, val, [0, ix])
267267
}
268268

269+
pub fn trans_drop_flag_ptr(bcx: block, r: &Repr, val: ValueRef) -> ValueRef {
270+
match *r {
271+
Univariant(_, DtorPresent) => GEPi(bcx, val, [0, 1]),
272+
_ => bcx.ccx().sess.bug(~"tried to get drop flag of non-droppable \
273+
type")
274+
}
275+
}
276+
269277
pub fn trans_const(ccx: @CrateContext, r: &Repr, discr: int,
270278
vals: &[ValueRef]) -> ValueRef {
271279
match *r {

src/librustc/middle/trans/glue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ pub fn trans_struct_drop(bcx: block,
468468
substs: &ty::substs,
469469
take_ref: bool)
470470
-> block {
471-
let drop_flag = GEPi(bcx, v0, struct_dtor());
471+
let repr = adt::represent_type(bcx.ccx(), t);
472+
let drop_flag = adt::trans_drop_flag_ptr(bcx, &repr, v0);
472473
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
473474
let mut bcx = cx;
474475

@@ -502,7 +503,6 @@ pub fn trans_struct_drop(bcx: block,
502503
Call(bcx, dtor_addr, args);
503504

504505
// Drop the fields
505-
let repr = adt::represent_type(bcx.ccx(), t);
506506
let field_tys =
507507
ty::struct_mutable_fields(bcx.tcx(), class_did,
508508
substs);

0 commit comments

Comments
 (0)