Skip to content

Commit de50c56

Browse files
committed
auto merge of #11727 : sanxiyn/rust/trailing-comma, r=alexcrichton
Fix #6506. Fix #7358.
2 parents 750d48b + 7689353 commit de50c56

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/libsyntax/parse/parser.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ impl Parser {
20212021
let es = self.parse_unspanned_seq(
20222022
&token::LPAREN,
20232023
&token::RPAREN,
2024-
seq_sep_trailing_disallowed(token::COMMA),
2024+
seq_sep_trailing_allowed(token::COMMA),
20252025
|p| p.parse_expr()
20262026
);
20272027
hi = self.last_span.hi;
@@ -2994,6 +2994,7 @@ impl Parser {
29942994
if self.look_ahead(1, |t| *t != token::RPAREN) {
29952995
while self.token == token::COMMA {
29962996
self.bump();
2997+
if self.token == token::RPAREN { break; }
29972998
fields.push(self.parse_pat());
29982999
}
29993000
}
@@ -3573,7 +3574,7 @@ impl Parser {
35733574
self.parse_unspanned_seq(
35743575
&token::LPAREN,
35753576
&token::RPAREN,
3576-
seq_sep_trailing_disallowed(token::COMMA),
3577+
seq_sep_trailing_allowed(token::COMMA),
35773578
|p| {
35783579
if p.token == token::DOTDOTDOT {
35793580
p.bump();

src/test/run-pass/trailing-comma.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn f(_: int,) {}
12+
13+
pub fn main() {
14+
f(0,);
15+
let (_, _,) = (1, 1,);
16+
}

0 commit comments

Comments
 (0)