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]
This commit is contained in:
parent
38015eeb70
commit
416144b827
35 changed files with 161 additions and 164 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue