about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-08-13 16:06:21 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-08-13 16:07:12 -0700
commit87f4c153110743844e4b3a4bb9dcde31a5ef3eb4 (patch)
tree527389e5547b3e42a27dcf209d6ac6cf3d8ff6fe /src/libsyntax
parentc7ed9908d6023a278b2a53711abea50d186b71bc (diff)
downloadrust-87f4c153110743844e4b3a4bb9dcde31a5ef3eb4.tar.gz
rust-87f4c153110743844e4b3a4bb9dcde31a5ef3eb4.zip
rustc: Make functional record and struct update use ".." instead of "with".
"with" is still accepted for backwards compatibility.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/parser.rs15
-rw-r--r--src/libsyntax/print/pprust.rs8
2 files changed, 19 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index fbfd5aa6634..6ea5596fa2c 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -928,7 +928,8 @@ class parser {
                             !self.is_keyword(~"with") {
                         self.expect(token::COMMA);
                         if self.token == token::RBRACE ||
-                                self.is_keyword(~"with") {
+                                self.is_keyword(~"with") ||
+                                self.token == token::DOTDOT {
                             // Accept an optional trailing comma.
                             break;
                         }
@@ -936,7 +937,7 @@ class parser {
                     }
 
                     let base;
-                    if self.eat_keyword(~"with") {
+                    if self.eat_keyword(~"with") || self.eat(token::DOTDOT) {
                         base = some(self.parse_expr());
                     } else {
                         base = none;
@@ -1548,6 +1549,16 @@ class parser {
         let mut fields = ~[self.parse_field(token::COLON)];
         let mut base = none;
         while self.token != token::RBRACE {
+            if self.token == token::COMMA
+                && self.look_ahead(1) == token::DOTDOT {
+                self.bump();
+                self.bump();
+                base = some(self.parse_expr()); break;
+            }
+
+            // XXX: Remove "with" after all code is converted over and there's
+            // a snapshot.
+
             // optional comma before "with"
             if self.token == token::COMMA
                 && self.token_is_keyword(~"with",
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index be4786e7b1d..15b0c66d6c8 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1039,7 +1039,9 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
           some(expr) => {
             if vec::len(fields) > 0u { space(s.s); }
             ibox(s, indent_unit);
-            word_space(s, ~"with");
+            word(s.s, ~",");
+            space(s.s);
+            word(s.s, ~"..");
             print_expr(s, expr);
             end(s);
           }
@@ -1055,7 +1057,9 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
             some(expr) => {
                 if vec::len(fields) > 0u { space(s.s); }
                 ibox(s, indent_unit);
-                word_space(s, ~"with");
+                word(s.s, ~",");
+                space(s.s);
+                word(s.s, ~"..");
                 print_expr(s, expr);
                 end(s);
             }