From 416144b8279fbffceacea6d0fd90e0fd1f8ce53d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 26 Sep 2014 21:13:20 -0700 Subject: 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] --- src/libsyntax/parse/lexer/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src/libsyntax') 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 { -- cgit 1.4.1-3-g733a5