Allow trailing commas in argument lists and tuple patterns
This commit is contained in:
parent
750d48b0ad
commit
7689353918
2 changed files with 19 additions and 2 deletions
|
@ -2021,7 +2021,7 @@ impl Parser {
|
|||
let es = self.parse_unspanned_seq(
|
||||
&token::LPAREN,
|
||||
&token::RPAREN,
|
||||
seq_sep_trailing_disallowed(token::COMMA),
|
||||
seq_sep_trailing_allowed(token::COMMA),
|
||||
|p| p.parse_expr()
|
||||
);
|
||||
hi = self.last_span.hi;
|
||||
|
@ -2994,6 +2994,7 @@ impl Parser {
|
|||
if self.look_ahead(1, |t| *t != token::RPAREN) {
|
||||
while self.token == token::COMMA {
|
||||
self.bump();
|
||||
if self.token == token::RPAREN { break; }
|
||||
fields.push(self.parse_pat());
|
||||
}
|
||||
}
|
||||
|
@ -3573,7 +3574,7 @@ impl Parser {
|
|||
self.parse_unspanned_seq(
|
||||
&token::LPAREN,
|
||||
&token::RPAREN,
|
||||
seq_sep_trailing_disallowed(token::COMMA),
|
||||
seq_sep_trailing_allowed(token::COMMA),
|
||||
|p| {
|
||||
if p.token == token::DOTDOTDOT {
|
||||
p.bump();
|
||||
|
|
16
src/test/run-pass/trailing-comma.rs
Normal file
16
src/test/run-pass/trailing-comma.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn f(_: int,) {}
|
||||
|
||||
pub fn main() {
|
||||
f(0,);
|
||||
let (_, _,) = (1, 1,);
|
||||
}
|
Loading…
Add table
Reference in a new issue