Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Zero the struct in the take glue, not the drop glue
  • Loading branch information
Aatch committed Jun 25, 2013
1 parent d9f6dd2 commit 721164d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/librustc/middle/trans/glue.rs
Expand Up @@ -484,12 +484,6 @@ pub fn trans_struct_drop(mut bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
}

// Zero out the struct
unsafe {
let ty = Type::from_ref(llvm::LLVMTypeOf(v0));
memzero(bcx, v0, ty);
}

bcx
}

Expand Down Expand Up @@ -635,6 +629,23 @@ pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) {
ty::ty_opaque_closure_ptr(ck) => {
closure::make_opaque_cbox_take_glue(bcx, ck, v)
}
ty::ty_struct(did, ref substs) => {
let tcx = bcx.tcx();
let bcx = iter_structural_ty(bcx, v, t, take_ty);

match ty::ty_dtor(tcx, did) {
ty::TraitDtor(dtor, false) => {
// Zero out the struct
unsafe {
let ty = Type::from_ref(llvm::LLVMTypeOf(v));
memzero(bcx, v, ty);
}

}
_ => { }
}
bcx
}
_ if ty::type_is_structural(t) => {
iter_structural_ty(bcx, v, t, take_ty)
}
Expand Down

5 comments on commit 721164d

@bors
Copy link
Contributor

@bors bors commented on 721164d Jun 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from thestinger
at Aatch@721164d

@bors
Copy link
Contributor

@bors bors commented on 721164d Jun 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Aatch/rust/no-drop-flag = 721164d into auto

@bors
Copy link
Contributor

@bors bors commented on 721164d Jun 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aatch/rust/no-drop-flag = 721164d merged ok, testing candidate = d161e63

@bors
Copy link
Contributor

@bors bors commented on 721164d Jun 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = d161e63

Please sign in to comment.