From c44c7c5ab3fdd4e48fbb8f9a5e80d70a33a98f03 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 17 Dec 2010 17:21:56 -0800 Subject: rustc: Zero out slots after dropping them --- src/comp/middle/trans.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 6a926b9d..2b6ab9b0 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, -- cgit v1.2.3