Skip to content

Commit ab0a884

Browse files
committed
fix dropping non-primitive immediates
Closes #9446
1 parent 4dd3ccb commit ab0a884

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/librustc/middle/trans/glue.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,9 @@ pub fn drop_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
7777

7878
pub fn drop_ty_immediate(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
7979
let _icx = push_ctxt("drop_ty_immediate");
80-
match ty::get(t).sty {
81-
ty::ty_uniq(_)
82-
| ty::ty_evec(_, ty::vstore_uniq)
83-
| ty::ty_estr(ty::vstore_uniq) => {
84-
free_ty_immediate(bcx, v, t)
85-
}
86-
ty::ty_box(_) | ty::ty_opaque_box
87-
| ty::ty_evec(_, ty::vstore_box)
88-
| ty::ty_estr(ty::vstore_box) => {
89-
decr_refcnt_maybe_free(bcx, v, None, t)
90-
}
91-
_ => bcx.tcx().sess.bug("drop_ty_immediate: non-box ty")
92-
}
80+
let vp = alloca(bcx, type_of(bcx.ccx(), t), "");
81+
Store(bcx, v, vp);
82+
drop_ty(bcx, vp, t)
9383
}
9484

9585
pub fn free_ty(cx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {

src/test/run-pass/issue-9446.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-test
12-
1311
struct Wrapper(~str);
1412

1513
impl Wrapper {
@@ -26,7 +24,7 @@ impl Drop for Wrapper {
2624
fn drop(&mut self) {}
2725
}
2826

29-
fn main() {
27+
pub fn main() {
3028
{
3129
// This runs without complaint.
3230
let x = Wrapper::new(~"Bob");

0 commit comments

Comments
 (0)