Skip to content

Commit 184f510

Browse files
committed
libsyntax: Fix parsing of module-qualified structure patterns. rs=bugfix
1 parent cb7996a commit 184f510

File tree

2 files changed

+13
-29
lines changed

2 files changed

+13
-29
lines changed

src/libsyntax/parse/parser.rs

+1-29
Original file line numberDiff line numberDiff line change
@@ -2046,8 +2046,6 @@ impl Parser {
20462046
pat = self.parse_pat_ident(refutable, bind_by_value);
20472047
} else if self.eat_keyword(~"move") {
20482048
pat = self.parse_pat_ident(refutable, bind_by_move);
2049-
} else if !is_plain_ident(self.token) {
2050-
pat = self.parse_enum_variant(refutable);
20512049
} else {
20522050
let binding_mode;
20532051
// XXX: Aren't these two cases deadcode? -- bblum
@@ -2066,7 +2064,7 @@ impl Parser {
20662064
let cannot_be_enum_or_struct;
20672065
match self.look_ahead(1) {
20682066
token::LPAREN | token::LBRACKET | token::LT |
2069-
token::LBRACE =>
2067+
token::LBRACE | token::MOD_SEP =>
20702068
cannot_be_enum_or_struct = false,
20712069
_ =>
20722070
cannot_be_enum_or_struct = true
@@ -2163,32 +2161,6 @@ impl Parser {
21632161
pat_ident(binding_mode, name, sub)
21642162
}
21652163
2166-
fn parse_enum_variant(refutable: bool) -> ast::pat_ {
2167-
let enum_path = self.parse_path_with_tps(true);
2168-
match self.token {
2169-
token::LPAREN => {
2170-
match self.look_ahead(1u) {
2171-
token::BINOP(token::STAR) => { // foo(*)
2172-
self.expect(token::LPAREN);
2173-
self.expect(token::BINOP(token::STAR));
2174-
self.expect(token::RPAREN);
2175-
pat_enum(enum_path, None)
2176-
}
2177-
_ => { // foo(a, ..., z)
2178-
let args = self.parse_unspanned_seq(
2179-
token::LPAREN, token::RPAREN,
2180-
seq_sep_trailing_disallowed(token::COMMA),
2181-
|p| p.parse_pat(refutable));
2182-
pat_enum(enum_path, Some(args))
2183-
}
2184-
}
2185-
}
2186-
_ => { // option::None
2187-
pat_enum(enum_path, Some(~[]))
2188-
}
2189-
}
2190-
}
2191-
21922164
fn parse_local(is_mutbl: bool,
21932165
allow_init: bool) -> @local {
21942166
let lo = self.span.lo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mod m {
2+
pub struct S {
3+
x: int,
4+
y: int
5+
}
6+
}
7+
8+
fn main() {
9+
let x = m::S { x: 1, y: 2 };
10+
let m::S { x: a, y: b } = x;
11+
}
12+

0 commit comments

Comments
 (0)