Skip to content

Commit 84291d3

Browse files
committed
---
yaml --- r: 127482 b: refs/heads/try c: 745fdd6 h: refs/heads/master v: v3
1 parent 6172ea2 commit 84291d3

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c4a63fabe345967e7d6b4570752ea081cae21785
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 12e0f72f517516ac4fce2aed85e6142e9b874bce
5-
refs/heads/try: bc206938562d9abc35f3f70e5c4dae6bef63fb33
5+
refs/heads/try: 745fdd6eba6c7803ed80281b4b08e6c4962f3c30
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/trans/_match.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,8 @@ pub fn trans_match<'a>(
12981298
fn is_discr_reassigned(bcx: &Block, discr: &ast::Expr, body: &ast::Expr) -> bool {
12991299
match discr.node {
13001300
ast::ExprPath(..) => match bcx.def(discr.id) {
1301-
def::DefLocal(vid, _) | def::DefBinding(vid, _) => {
1301+
def::DefArg(vid, _) | def::DefBinding(vid, _) |
1302+
def::DefLocal(vid, _) | def::DefUpvar(vid, _, _, _) => {
13021303
let mut rc = ReassignmentChecker {
13031304
node: vid,
13041305
reassigned: false
@@ -1326,9 +1327,11 @@ impl euv::Delegate for ReassignmentChecker {
13261327
fn borrow(&mut self, _: ast::NodeId, _: Span, _: mc::cmt, _: ty::Region,
13271328
_: ty::BorrowKind, _: euv::LoanCause) {}
13281329
fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
1330+
13291331
fn mutate(&mut self, _: ast::NodeId, _: Span, cmt: mc::cmt, _: euv::MutateMode) {
13301332
match cmt.cat {
1331-
mc::cat_local(vid) => self.reassigned = self.node == vid,
1333+
mc::cat_copied_upvar(mc::CopiedUpvar { upvar_id: vid, .. }) |
1334+
mc::cat_arg(vid) | mc::cat_local(vid) => self.reassigned = self.node == vid,
13321335
_ => {}
13331336
}
13341337
}

branches/try/src/test/run-pass/issue-15571.rs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,57 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn main() {
11+
fn match_on_local() {
1212
let mut foo = Some(box 5i);
1313
match foo {
1414
None => {},
1515
Some(x) => {
1616
foo = Some(x);
1717
}
18-
};
18+
}
1919
println!("'{}'", foo.unwrap());
2020
}
21+
22+
fn match_on_arg(mut foo: Option<Box<int>>) {
23+
match foo {
24+
None => {}
25+
Some(x) => {
26+
foo = Some(x);
27+
}
28+
}
29+
println!("'{}'", foo.unwrap());
30+
}
31+
32+
fn match_on_binding() {
33+
match Some(box 7i) {
34+
mut foo => {
35+
match foo {
36+
None => {},
37+
Some(x) => {
38+
foo = Some(x);
39+
}
40+
}
41+
println!("'{}'", foo.unwrap());
42+
}
43+
}
44+
}
45+
46+
fn match_on_upvar() {
47+
let mut foo = Some(box 8i);
48+
(proc() {
49+
match foo {
50+
None => {},
51+
Some(x) => {
52+
foo = Some(x);
53+
}
54+
}
55+
println!("'{}'", foo.unwrap());
56+
})();
57+
}
58+
59+
fn main() {
60+
match_on_local();
61+
match_on_arg(Some(box 6i));
62+
match_on_binding();
63+
match_on_upvar();
64+
}

0 commit comments

Comments
 (0)