diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-09-30 22:40:44 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-10-01 00:38:37 -0400 |
| commit | ab0a884a7373145222dfbadc8ec741f767cc45d1 (patch) | |
| tree | e0c5262565609744cfe7c5f08f79cb80306ed2b4 | |
| parent | 4dd3ccb7ef5c8e675994701609e8ba01fe0c8ab0 (diff) | |
| download | rust-ab0a884a7373145222dfbadc8ec741f767cc45d1.tar.gz rust-ab0a884a7373145222dfbadc8ec741f767cc45d1.zip | |
fix dropping non-primitive immediates
Closes #9446
| -rw-r--r-- | src/librustc/middle/trans/glue.rs | 16 | ||||
| -rw-r--r-- | 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"); |
