Skip to content

Commit c7eee8f

Browse files
committed
Stop registering cleanups for types that don't need them
1 parent 3158633 commit c7eee8f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/comp/middle/trans_common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,13 @@ tag cleanup {
264264
}
265265

266266
fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
267+
if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
267268
let scope_cx = find_scope_cx(cx);
268269
scope_cx.cleanups += [clean(bind drop_ty(_, val, ty))];
269270
scope_cx.lpad_dirty = true;
270271
}
271272
fn add_clean_temp(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
273+
if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
272274
fn spill_and_drop(cx: @block_ctxt, val: ValueRef, ty: ty::t) ->
273275
@block_ctxt {
274276
let bcx = cx;
@@ -283,6 +285,7 @@ fn add_clean_temp(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
283285
scope_cx.lpad_dirty = true;
284286
}
285287
fn add_clean_temp_mem(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
288+
if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
286289
let scope_cx = find_scope_cx(cx);
287290
scope_cx.cleanups += [clean_temp(val, bind drop_ty(_, val, ty))];
288291
scope_cx.lpad_dirty = true;

0 commit comments

Comments
 (0)