diff --git a/src/rustc/middle/trans/expr.rs b/src/rustc/middle/trans/expr.rs index dee553536048a..06c2421a452d7 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -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)); @@ -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 { diff --git a/src/test/run-pass/unused-move.rs b/src/test/run-pass/unused-move.rs new file mode 100644 index 0000000000000..4cabac321376c --- /dev/null +++ b/src/test/run-pass/unused-move.rs @@ -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; +} \ No newline at end of file