Skip to content

Commit fd88e2b

Browse files
committed
syntax: Parse global paths in patterns
Closes #6449
1 parent e546452 commit fd88e2b

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2920,7 +2920,7 @@ impl<'a> Parser<'a> {
29202920
_ => {}
29212921
}
29222922

2923-
if !is_ident_or_path(&self.token)
2923+
if (!is_ident_or_path(&self.token) && self.token != token::MOD_SEP)
29242924
|| self.is_keyword(keywords::True)
29252925
|| self.is_keyword(keywords::False) {
29262926
// Parse an expression pattern or exp .. exp.

src/test/run-pass/issue-6449.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
enum Foo {
12+
Bar(int),
13+
Baz,
14+
}
15+
16+
enum Other {
17+
Other1(Foo),
18+
Other2(Foo, Foo),
19+
}
20+
21+
fn main() {
22+
match Baz {
23+
::Bar(3) => fail!(),
24+
::Bar(_) if false => fail!(),
25+
::Bar(..) if false => fail!(),
26+
::Bar(_n) => fail!(),
27+
::Baz => {}
28+
}
29+
match Bar(3) {
30+
::Bar(3) => {}
31+
::Bar(_) if false => fail!(),
32+
::Bar(..) if false => fail!(),
33+
::Bar(_n) => fail!(),
34+
::Baz => fail!(),
35+
}
36+
match Bar(4) {
37+
::Bar(3) => fail!(),
38+
::Bar(_) if false => fail!(),
39+
::Bar(..) if false => fail!(),
40+
::Bar(n) => assert_eq!(n, 4),
41+
::Baz => fail!(),
42+
}
43+
44+
match Other1(Baz) {
45+
::Other1(::Baz) => {}
46+
::Other1(::Bar(_)) => {}
47+
::Other2(::Baz, ::Bar(_)) => {}
48+
::Other2(::Bar(..), ::Baz) => {}
49+
::Other2(..) => {}
50+
}
51+
}

0 commit comments

Comments
 (0)