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 `..` _ => (), } } ````
This commit is contained in:
commit
7b2020f2c3
2 changed files with 18 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue