auto merge of #11727 : sanxiyn/rust/trailing-comma, r=alexcrichton
Fix #6506. Fix #7358.
This commit is contained in:
commit
de50c56a5c
2 changed files with 19 additions and 2 deletions
|
@ -2021,7 +2021,7 @@ impl Parser {
|
||||||
let es = self.parse_unspanned_seq(
|
let es = self.parse_unspanned_seq(
|
||||||
&token::LPAREN,
|
&token::LPAREN,
|
||||||
&token::RPAREN,
|
&token::RPAREN,
|
||||||
seq_sep_trailing_disallowed(token::COMMA),
|
seq_sep_trailing_allowed(token::COMMA),
|
||||||
|p| p.parse_expr()
|
|p| p.parse_expr()
|
||||||
);
|
);
|
||||||
hi = self.last_span.hi;
|
hi = self.last_span.hi;
|
||||||
|
@ -2994,6 +2994,7 @@ impl Parser {
|
||||||
if self.look_ahead(1, |t| *t != token::RPAREN) {
|
if self.look_ahead(1, |t| *t != token::RPAREN) {
|
||||||
while self.token == token::COMMA {
|
while self.token == token::COMMA {
|
||||||
self.bump();
|
self.bump();
|
||||||
|
if self.token == token::RPAREN { break; }
|
||||||
fields.push(self.parse_pat());
|
fields.push(self.parse_pat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3573,7 +3574,7 @@ impl Parser {
|
||||||
self.parse_unspanned_seq(
|
self.parse_unspanned_seq(
|
||||||
&token::LPAREN,
|
&token::LPAREN,
|
||||||
&token::RPAREN,
|
&token::RPAREN,
|
||||||
seq_sep_trailing_disallowed(token::COMMA),
|
seq_sep_trailing_allowed(token::COMMA),
|
||||||
|p| {
|
|p| {
|
||||||
if p.token == token::DOTDOTDOT {
|
if p.token == token::DOTDOTDOT {
|
||||||
p.bump();
|
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
Add a link
Reference in a new issue