diff options
| author | bors <bors@rust-lang.org> | 2013-05-07 00:18:37 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-07 00:18:37 -0700 |
| commit | 7b2020f2c3f51de0dd4dcfe4a107673eda6f25e7 (patch) | |
| tree | 75adf0b0609e8c8185568cd151b6b1ef3a745f74 /src/libsyntax | |
| parent | 3225870191f7e6b601d70fa5aa08617eb04b170b (diff) | |
| parent | cb918e1a831782d6072a0b93dd57614cb9c2d961 (diff) | |
| download | rust-7b2020f2c3f51de0dd4dcfe4a107673eda6f25e7.tar.gz rust-7b2020f2c3f51de0dd4dcfe4a107673eda6f25e7.zip | |
auto merge of #6245 : youknowone/rust/match-range-static, r=graydon
Fix unintended error problem of:
````
static s: int = 1;
static e: int = 42;
fn main() {
match 7 {
s..e => (),
^~ error: expected `=>` but found `..`
_ => (),
}
}
````
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6b8411a9ead..810efd39177 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2383,7 +2383,13 @@ pub impl Parser { can_be_enum_or_struct = false } - if is_plain_ident(&*self.token) && !can_be_enum_or_struct { + if self.look_ahead(1) == token::DOTDOT { + let start = self.parse_expr_res(RESTRICT_NO_BAR_OP); + self.eat(&token::DOTDOT); + let end = self.parse_expr_res(RESTRICT_NO_BAR_OP); + pat = pat_range(start, end); + } + else if is_plain_ident(&*self.token) && !can_be_enum_or_struct { let name = self.parse_path_without_tps(); let sub; if self.eat(&token::AT) { @@ -2392,7 +2398,7 @@ pub impl Parser { } else { // or just foo sub = None; - }; + } pat = pat_ident(binding_mode, name, sub); } else { // parse an enum pat |
