aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2011-03-07 00:13:56 -0800
committerGraydon Hoare <[email protected]>2011-03-07 00:13:56 -0800
commit60657fa8aa1706fec7925b74dffdb1a0c82ceb0b (patch)
tree72d8b659c089fe9b671dcde593c2c100f744c5ce /src/comp
parentFix off-by-one in vector append code. (diff)
downloadrust-60657fa8aa1706fec7925b74dffdb1a0c82ceb0b.tar.xz
rust-60657fa8aa1706fec7925b74dffdb1a0c82ceb0b.zip
Set the cleanup on the post-growth vector, not the temporary one.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 05aadee2..0c0d92d4 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -2470,10 +2470,11 @@ fn trans_vec_add(@block_ctxt cx, @ty.t t,
ValueRef lhs, ValueRef rhs) -> result {
auto r = alloc_ty(cx, t);
auto tmp = r.val;
- find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tmp, t));
r = copy_ty(r.bcx, INIT, tmp, lhs, t);
auto bcx = trans_vec_append(r.bcx, t, tmp, rhs).bcx;
- ret res(bcx, load_scalar_or_boxed(bcx, tmp, t));
+ tmp = load_scalar_or_boxed(bcx, tmp, t);
+ find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tmp, t));
+ ret res(bcx, tmp);
}