Skip to content

Commit

Permalink
* dropnzero_val fn added
Browse files Browse the repository at this point in the history
* zero-mem for not needed drop situation placed in Ignore
  • Loading branch information
vertexclique committed Oct 30, 2012
1 parent a3b83c6 commit bf792b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/rustc/middle/trans/datum.rs
Expand Up @@ -542,6 +542,25 @@ impl Datum {
};
}

fn dropnzero_val(bcx: block) -> block {
if !ty::type_needs_drop(bcx.tcx(), self.ty) {
return bcx;
}

return match self.mode {
ByRef => {
glue::drop_ty(bcx, self.val, self.ty);
zero_mem(bcx, self.val, self.ty);
return bcx;
}
ByValue => {
glue::drop_ty_immediate(bcx, self.val, self.ty);
zero_mem(bcx, self.val, self.ty);
return bcx;
}
};
}

fn box_body(bcx: block) -> Datum {
/*!
*
Expand Down
2 changes: 1 addition & 1 deletion src/rustc/middle/trans/expr.rs
Expand Up @@ -573,7 +573,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
if bcx.expr_is_lval(a) {
let datum = unpack_datum!(bcx, trans_to_datum(bcx, a));
return match dest {
Ignore => datum.drop_val(bcx),
Ignore => datum.dropnzero_val(bcx),
SaveIn(addr) => datum.move_to(bcx, INIT, addr)
};
} else {
Expand Down

0 comments on commit bf792b9

Please sign in to comment.