Skip to content

Commit 1ceb768

Browse files
committed
---
yaml --- r: 31743 b: refs/heads/dist-snap c: febd7ee h: refs/heads/master i: 31741: 9c883d9 31739: 8bf671a 31735: 7bbbef4 31727: 9901c02 31711: 9052fef 31679: 52d81e7 31615: 91ec669 31487: ef870a7 31231: 1afb289 30719: 6c92920 v: v3
1 parent 084fb6a commit 1ceb768

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
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: d99ca69cf7207e31d7ddffe849a4235cc63899d7
10+
refs/heads/dist-snap: febd7ee239c1182147317a0e31057a0e69e260ff
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/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)