From 0f1f5e67ea13eb9ac19a88dfc1cd4894450ed879 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 22 Aug 2011 14:33:31 -0700 Subject: [PATCH] Create correct drop glue for istrs. Issue #855 --- src/comp/middle/trans.rs | 4 ++++ src/test/run-pass/istr.rs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 2239718cc245..309be3fd2db9 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -1426,6 +1426,10 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: ty::t) { let rslt = iter_structural_ty(cx, v1, t, drop_ty); maybe_free_ivec_heap_part(rslt.bcx, v1, tm.ty) } + ty::ty_istr. { + maybe_free_ivec_heap_part(cx, v0, + ty::mk_mach(ccx.tcx, ast::ty_u8)) + } ty::ty_box(_) { decr_refcnt_maybe_free(cx, v0, v0, t) } ty::ty_uniq(_) { trans_shared_free(cx, cx.build.Load(v0)) } ty::ty_obj(_) { diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index 624b7edb1027..2eef9399e8da 100644 --- a/src/test/run-pass/istr.rs +++ b/src/test/run-pass/istr.rs @@ -11,7 +11,13 @@ fn test_heap_lit() { ~"a big string"; } +fn test_heap_assign() { + let s: istr; + s = ~"AAAA"; +} + fn main() { test_stack_assign(); test_heap_lit(); + test_heap_assign(); } \ No newline at end of file