Skip to content

Commit d214b98

Browse files
committed
---
yaml --- r: 23081 b: refs/heads/master c: febd7ee h: refs/heads/master i: 23079: 3a0972e v: v3
1 parent 265c16e commit d214b98

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d99ca69cf7207e31d7ddffe849a4235cc63899d7
2+
refs/heads/master: febd7ee239c1182147317a0e31057a0e69e260ff
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rustc/middle/trans/base.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4206,9 +4206,26 @@ fn build_return(bcx: block) {
42064206
Br(bcx, bcx.fcx.llreturn);
42074207
}
42084208

4209+
fn ignore_lhs(_bcx: block, local: @ast::local) -> bool {
4210+
match local.node.pat.node {
4211+
ast::pat_wild => true, _ => false
4212+
}
4213+
}
4214+
42094215
fn init_local(bcx: block, local: @ast::local) -> block {
42104216
let _icx = bcx.insn_ctxt(~"init_local");
42114217
let ty = node_id_type(bcx, local.node.id);
4218+
4219+
if ignore_lhs(bcx, local) {
4220+
// Handle let _ = e; just like e;
4221+
match local.node.init {
4222+
some(init) => {
4223+
return trans_expr(bcx, init.expr, ignore);
4224+
}
4225+
none => { return bcx; }
4226+
}
4227+
}
4228+
42124229
let llptr = match bcx.fcx.lllocals.find(local.node.id) {
42134230
some(local_mem(v)) => v,
42144231
_ => { bcx.tcx().sess.span_bug(local.span,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test should behave exactly like issue-2735-3
2+
class defer {
3+
let b: &mut bool;
4+
new(b: &mut bool) {
5+
self.b = b;
6+
}
7+
drop { *(self.b) = true; }
8+
}
9+
10+
fn main() {
11+
let mut dtor_ran = false;
12+
let _ = defer(&mut dtor_ran);
13+
assert(dtor_ran);
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test should behave exactly like issue-2735-2
2+
class defer {
3+
let b: &mut bool;
4+
new(b: &mut bool) {
5+
self.b = b;
6+
}
7+
drop { *(self.b) = true; }
8+
}
9+
10+
fn main() {
11+
let mut dtor_ran = false;
12+
defer(&mut dtor_ran);
13+
assert(dtor_ran);
14+
}

0 commit comments

Comments
 (0)