Skip to content

Commit 13fe116

Browse files
committed
---
yaml --- r: 6382 b: refs/heads/master c: 8cf3ca3 h: refs/heads/master v: v3
1 parent ce065cf commit 13fe116

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 1cccefd8bbf0a8df6074f0c26a451dee876bc31a
2+
refs/heads/master: 8cf3ca3b55dbab193903a00eb427156365e44c67

trunk/src/comp/middle/trans.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3621,13 +3621,19 @@ fn trans_arg_expr(cx: @block_ctxt, arg: ty::arg, lldestty0: TypeRef,
36213621
}
36223622
} else if arg.mode == ast::by_copy {
36233623
let {bcx: cx, val: alloc} = alloc_ty(bcx, e_ty);
3624+
let last_use = ccx.last_uses.contains_key(e.id);
36243625
bcx = cx;
36253626
if lv.kind == temporary { revoke_clean(bcx, val); }
36263627
if lv.kind == owned || !ty::type_is_immediate(ccx.tcx, e_ty) {
36273628
bcx = memmove_ty(bcx, alloc, val, e_ty);
3629+
if last_use && ty::type_needs_drop(ccx.tcx, e_ty) {
3630+
bcx = zero_alloca(bcx, val, e_ty);
3631+
}
36283632
} else { Store(bcx, val, alloc); }
36293633
val = alloc;
3630-
if lv.kind != temporary { bcx = take_ty(bcx, val, e_ty); }
3634+
if lv.kind != temporary && !last_use {
3635+
bcx = take_ty(bcx, val, e_ty);
3636+
}
36313637
} else if ty::type_is_immediate(ccx.tcx, e_ty) && lv.kind != owned {
36323638
let r = do_spill(bcx, val, e_ty);
36333639
val = r.val;

0 commit comments

Comments
 (0)