Skip to content

Commit

Permalink
Only accept ... in range patterns.
Browse files Browse the repository at this point in the history
Closes rust-lang#17295

[breaking-change]

We previously accepted `..` and then `..` or `...`. To fix change `..` to `...` in range patterns.
  • Loading branch information
nrc committed Sep 25, 2014
1 parent 3be6a2f commit 69b5f2d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 69b5f2d

Please sign in to comment.