diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-12-19 09:21:05 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-12-19 09:29:41 -0800 |
| commit | bfb760c697715c5662c4d8330d7e2d0b7910224e (patch) | |
| tree | ce0f3e990d3922b766be7d7eaff189118bbf3fe6 /src/libsyntax/parse/parser.rs | |
| parent | e86cdaf23ded0d25582a33fea761963cf0eb4f41 (diff) | |
| download | rust-bfb760c697715c5662c4d8330d7e2d0b7910224e.tar.gz rust-bfb760c697715c5662c4d8330d7e2d0b7910224e.zip | |
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
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 35ea06d62ca..729d0320435 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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 { |
