about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLindsey Kuper <lindsey@rockstargirl.org>2012-05-31 11:33:18 -0700
committerLindsey Kuper <lindsey@rockstargirl.org>2012-05-31 12:20:26 -0700
commitf394933641b5894a4c408aaae59ea3f632b3ee64 (patch)
treee15e3b84575dba2bce5722b0506a489460baf786
parentabef5f54c99ab8a6a1ea73c9b946557c13caf719 (diff)
downloadrust-f394933641b5894a4c408aaae59ea3f632b3ee64.tar.gz
rust-f394933641b5894a4c408aaae59ea3f632b3ee64.zip
Allow optional comma before `with` in FRU. Closes #2463.
-rw-r--r--src/libsyntax/parse/parser.rs6
-rw-r--r--src/test/run-pass/issue-2463.rs19
2 files changed, 25 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 3cb40befa0e..a2c43ec3a2a 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -724,6 +724,12 @@ class parser {
                 let mut fields = [self.parse_field(token::COLON)];
                 let mut base = none;
                 while self.token != token::RBRACE {
+                    // optional comma before "with"
+                    if self.token == token::COMMA
+                        && self.token_is_keyword("with",
+                                                 self.look_ahead(1u)) {
+                        self.bump();
+                    }
                     if self.eat_keyword("with") {
                         base = some(self.parse_expr()); break;
                     }
diff --git a/src/test/run-pass/issue-2463.rs b/src/test/run-pass/issue-2463.rs
new file mode 100644
index 00000000000..f6d600e48b6
--- /dev/null
+++ b/src/test/run-pass/issue-2463.rs
@@ -0,0 +1,19 @@
+fn main() {
+
+    let x = {
+        f: 0,
+        g: 0,
+    };
+
+    let y = {
+        f: 1,
+        g: 1,
+        with x
+    };
+
+    let z = {
+        f: 1,
+        with x
+    };
+
+}