Skip to content

Commit 64759c9

Browse files
committed
librustc: Have destructor run for unit-like structs.
1 parent 44af506 commit 64759c9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/librustc/middle/trans/expr.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,14 @@ fn trans_def_dps_unadjusted(bcx: block, ref_expr: @ast::expr,
727727
}
728728
}
729729
ast::def_struct(*) => {
730-
// Nothing to do here.
731-
// FIXME #6572: May not be true in the case of classes with destructors.
730+
let ty = expr_ty(bcx, ref_expr);
731+
match ty::get(ty).sty {
732+
ty::ty_struct(did, _) if ty::has_dtor(ccx.tcx, did) => {
733+
let repr = adt::represent_type(ccx, ty);
734+
adt::trans_start_init(bcx, repr, lldest, 0);
735+
}
736+
_ => {}
737+
}
732738
return bcx;
733739
}
734740
_ => {

0 commit comments

Comments
 (0)