Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused move crash fix #3889

Merged
merged 3 commits into from
Oct 31, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/rustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ impl Dest : cmp::Eq {
pure fn ne(other: &Dest) -> bool { !self.eq(other) }
}

fn drop_and_cancel_clean(dat: Datum, bcx: block) -> block {
let bcx = dat.drop_val(bcx);
dat.cancel_clean(bcx);
return bcx;
}

fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));

Expand Down Expand Up @@ -573,7 +579,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 => drop_and_cancel_clean(datum, bcx),
SaveIn(addr) => datum.move_to(bcx, INIT, addr)
};
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/test/run-pass/unused-move.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Issue #3878
// Issue Name: Unused move causes a crash
// Abstract: zero-fill to block after drop

fn main()
{
let y = ~1;
move y;
}