Skip to content

Commit 740763f

Browse files
committed
Merge remote-tracking branch 'vertexclique/incoming'
2 parents cb4de73 + add4127 commit 740763f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/rustc/middle/trans/expr.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ impl Dest : cmp::Eq {
159159
pure fn ne(other: &Dest) -> bool { !self.eq(other) }
160160
}
161161

162+
fn drop_and_cancel_clean(dat: Datum, bcx: block) -> block {
163+
let bcx = dat.drop_val(bcx);
164+
dat.cancel_clean(bcx);
165+
return bcx;
166+
}
167+
162168
fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
163169
debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));
164170
return match bcx.tcx().adjustments.find(expr.id) {
@@ -581,7 +587,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
581587
if bcx.expr_is_lval(a) {
582588
let datum = unpack_datum!(bcx, trans_to_datum(bcx, a));
583589
return match dest {
584-
Ignore => datum.drop_val(bcx),
590+
Ignore => drop_and_cancel_clean(datum, bcx),
585591
SaveIn(addr) => datum.move_to(bcx, INIT, addr)
586592
};
587593
} else {

src/test/run-pass/unused-move.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Issue #3878
2+
// Issue Name: Unused move causes a crash
3+
// Abstract: zero-fill to block after drop
4+
5+
fn main()
6+
{
7+
let y = ~1;
8+
move y;
9+
}

0 commit comments

Comments
 (0)