about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2010-12-17 17:21:56 -0800
committerPatrick Walton <pcwalton@mimiga.net>2010-12-17 17:21:56 -0800
commitc44c7c5ab3fdd4e48fbb8f9a5e80d70a33a98f03 (patch)
treee9f3a2fb028520284f8f9c662d461beca181c909 /src
parent56e040e61a382a831faa5c563c46ffee2f4d7333 (diff)
rustc: Zero out slots after dropping them
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 6a926b9d7b5..2b6ab9b0569 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -768,7 +768,7 @@ fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
 type val_and_ty_fn =
     fn(@block_ctxt cx, ValueRef v, @typeck.ty t) -> result;
 
-// Iterates through the elements of a tup, rec or tag.
+// Iterates through the elements of a box, tup, rec or tag.
 fn iter_structural_ty(@block_ctxt cx,
                       ValueRef v,
                       @typeck.ty t,
@@ -968,7 +968,13 @@ fn incr_all_refcnts(@block_ctxt cx,
 fn drop_slot(@block_ctxt cx,
              ValueRef slot,
              @typeck.ty t) -> result {
-    be drop_ty(cx, load_non_structural(cx, slot, t), t);
+    auto llptr = load_non_structural(cx, slot, t);
+    auto re = drop_ty(cx, llptr, t);
+
+    auto llty = val_ty(slot);
+    auto llelemty = lib.llvm.llvm.LLVMGetElementType(llty);
+    re.bcx.build.Store(C_null(llelemty), slot);
+    ret re;
 }
 
 fn drop_ty(@block_ctxt cx,