Skip to content

Commit cd911de

Browse files
edwardwalexcrichton
authored andcommitted
---
yaml --- r: 114077 b: refs/heads/master c: 5bf268d h: refs/heads/master i: 114075: 7114d2a v: v3
1 parent 102a4ae commit cd911de

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
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: 655487b59666afe5a5c9e0a305c27be342b8fa46
2+
refs/heads/master: 5bf268d0b028d8e8abe62166c533f8515955bc6b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/librustc/middle/check_match.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,15 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
239239
return not_useful
240240
}
241241
let real_pat = match m.iter().find(|r| r.get(0).id != 0) {
242-
Some(r) => *r.get(0), None => v[0]
242+
Some(r) => {
243+
match r.get(0).node {
244+
// An arm of the form `ref x @ sub_pat` has type
245+
// `sub_pat`, not `&sub_pat` as `x` itself does.
246+
PatIdent(BindByRef(_), _, Some(sub)) => sub,
247+
_ => *r.get(0)
248+
}
249+
}
250+
None => v[0]
243251
};
244252
let left_ty = if real_pat.id == 0 { ty::mk_nil() }
245253
else { ty::node_id_to_type(cx.tcx, real_pat.id) };

trunk/src/test/run-pass/issue-8391.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let _x = match Some(1) {
13-
_y @ Some(_) => 1,
12+
let x = match Some(1) {
13+
ref _y @ Some(_) => 1,
1414
None => 2,
1515
};
16+
assert_eq!(x, 1);
1617
}

0 commit comments

Comments
 (0)