From ab0a884a7373145222dfbadc8ec741f767cc45d1 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Mon, 30 Sep 2013 22:40:44 -0400 Subject: [PATCH] fix dropping non-primitive immediates Closes #9446 --- src/librustc/middle/trans/glue.rs | 16 +++------------- src/test/run-pass/issue-9446.rs | 4 +--- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index a10f53ebcbc..cecea270330 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -77,19 +77,9 @@ pub fn drop_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block { pub fn drop_ty_immediate(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block { let _icx = push_ctxt("drop_ty_immediate"); - match ty::get(t).sty { - ty::ty_uniq(_) - | ty::ty_evec(_, ty::vstore_uniq) - | ty::ty_estr(ty::vstore_uniq) => { - free_ty_immediate(bcx, v, t) - } - ty::ty_box(_) | ty::ty_opaque_box - | ty::ty_evec(_, ty::vstore_box) - | ty::ty_estr(ty::vstore_box) => { - decr_refcnt_maybe_free(bcx, v, None, t) - } - _ => bcx.tcx().sess.bug("drop_ty_immediate: non-box ty") - } + let vp = alloca(bcx, type_of(bcx.ccx(), t), ""); + Store(bcx, v, vp); + drop_ty(bcx, vp, t) } pub fn free_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block { diff --git a/src/test/run-pass/issue-9446.rs b/src/test/run-pass/issue-9446.rs index 0a0d64e122c..e97960b3f02 100644 --- a/src/test/run-pass/issue-9446.rs +++ b/src/test/run-pass/issue-9446.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - struct Wrapper(~str); impl Wrapper { @@ -26,7 +24,7 @@ impl Drop for Wrapper { fn drop(&mut self) {} } -fn main() { +pub fn main() { { // This runs without complaint. let x = Wrapper::new(~"Bob");