diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-09-26 21:13:20 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-09-30 09:11:26 -0700 |
| commit | 416144b8279fbffceacea6d0fd90e0fd1f8ce53d (patch) | |
| tree | 0f7f628dd1388f378ac4836e32359b18a7297212 /src/libsyntax/parse | |
| parent | 38015eeb7010e5954a1bc60fddc1214a5f359627 (diff) | |
| download | rust-416144b8279fbffceacea6d0fd90e0fd1f8ce53d.tar.gz rust-416144b8279fbffceacea6d0fd90e0fd1f8ce53d.zip | |
librustc: Forbid `..` in range patterns.
This breaks code that looks like:
match foo {
1..3 => { ... }
}
Instead, write:
match foo {
1...3 => { ... }
}
Closes #17295.
[breaking-change]
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 11 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 68ddd17dd01..38c985af370 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -637,7 +637,7 @@ impl<'a> StringReader<'a> { 'b' => { self.bump(); base = 2; num_digits = self.scan_digits(2); } 'o' => { self.bump(); base = 8; num_digits = self.scan_digits(8); } 'x' => { self.bump(); base = 16; num_digits = self.scan_digits(16); } - '0'..'9' | '_' | '.' => { + '0'...'9' | '_' | '.' => { num_digits = self.scan_digits(10) + 1; } 'u' | 'i' => { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 415ff6a4097..e46e67d7bd3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3237,8 +3237,7 @@ impl<'a> Parser<'a> { // These expressions are limited to literals (possibly // preceded by unary-minus) or identifiers. let val = self.parse_literal_maybe_minus(); - // FIXME(#17295) remove the DOTDOT option. - if (self.token == token::DOTDOTDOT || self.token == token::DOTDOT) && + if (self.token == token::DOTDOTDOT) && self.look_ahead(1, |t| { *t != token::COMMA && *t != token::RBRACKET }) { @@ -3283,16 +3282,12 @@ impl<'a> Parser<'a> { } }); - // FIXME(#17295) remove the DOTDOT option. - if self.look_ahead(1, |t| *t == token::DOTDOTDOT || *t == token::DOTDOT) && + if self.look_ahead(1, |t| *t == token::DOTDOTDOT) && self.look_ahead(2, |t| { *t != token::COMMA && *t != token::RBRACKET }) { let start = self.parse_expr_res(RestrictionNoBarOp); - // FIXME(#17295) remove the DOTDOT option (self.eat(&token::DOTDOTDOT)). - if self.token == token::DOTDOTDOT || self.token == token::DOTDOT { - self.bump(); - } + self.eat(&token::DOTDOTDOT); let end = self.parse_expr_res(RestrictionNoBarOp); pat = PatRange(start, end); } else if is_plain_ident(&self.token) && !can_be_enum_or_struct { |
