Accept trailing commas in struct patterns

We decided in the 12/10/13 weekly meeting that trailing commas should be
accepted pretty much anywhere. They are currently not allowed in struct
patterns, and this commit adds support for that.

Closes #10392
This commit is contained in:
Alex Crichton 2013-12-19 09:21:05 -08:00
parent e86cdaf23d
commit bfb760c697
4 changed files with 79 additions and 2 deletions

View file

@ -2800,8 +2800,13 @@ impl Parser {
let mut etc = false;
let mut first = true;
while *self.token != token::RBRACE {
if first { first = false; }
else { self.expect(&token::COMMA); }
if first {
first = false;
} else {
self.expect(&token::COMMA);
// accept trailing commas
if *self.token == token::RBRACE { break }
}
etc = *self.token == token::UNDERSCORE || *self.token == token::DOTDOT;
if *self.token == token::UNDERSCORE {