Skip to content

Commit bf792b9

Browse files
committed
* dropnzero_val fn added
* zero-mem for not needed drop situation placed in Ignore
1 parent a3b83c6 commit bf792b9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/rustc/middle/trans/datum.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,25 @@ impl Datum {
542542
};
543543
}
544544

545+
fn dropnzero_val(bcx: block) -> block {
546+
if !ty::type_needs_drop(bcx.tcx(), self.ty) {
547+
return bcx;
548+
}
549+
550+
return match self.mode {
551+
ByRef => {
552+
glue::drop_ty(bcx, self.val, self.ty);
553+
zero_mem(bcx, self.val, self.ty);
554+
return bcx;
555+
}
556+
ByValue => {
557+
glue::drop_ty_immediate(bcx, self.val, self.ty);
558+
zero_mem(bcx, self.val, self.ty);
559+
return bcx;
560+
}
561+
};
562+
}
563+
545564
fn box_body(bcx: block) -> Datum {
546565
/*!
547566
*

src/rustc/middle/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
573573
if bcx.expr_is_lval(a) {
574574
let datum = unpack_datum!(bcx, trans_to_datum(bcx, a));
575575
return match dest {
576-
Ignore => datum.drop_val(bcx),
576+
Ignore => datum.dropnzero_val(bcx),
577577
SaveIn(addr) => datum.move_to(bcx, INIT, addr)
578578
};
579579
} else {

0 commit comments

Comments
 (0)