From 64759c9f25993d255c7ced4edecdd14a75e149b0 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sat, 1 Jun 2013 17:39:39 -0400 Subject: [PATCH] librustc: Have destructor run for unit-like structs. --- src/librustc/middle/trans/expr.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index fa8c3cd8879..997819453ec 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -727,8 +727,14 @@ fn trans_def_dps_unadjusted(bcx: block, ref_expr: @ast::expr, } } ast::def_struct(*) => { - // Nothing to do here. - // FIXME #6572: May not be true in the case of classes with destructors. + let ty = expr_ty(bcx, ref_expr); + match ty::get(ty).sty { + ty::ty_struct(did, _) if ty::has_dtor(ccx.tcx, did) => { + let repr = adt::represent_type(ccx, ty); + adt::trans_start_init(bcx, repr, lldest, 0); + } + _ => {} + } return bcx; } _ => {