about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-07-28 12:01:45 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-08-01 17:51:37 +0200
commit985c32ef4c930cdfba23db2191014d772c354407 (patch)
treef9cfb1ad055221eb63cfd22e49cbe18d59dcf520 /src/comp/syntax/parse
parent48ec25da423cd6535e6354a00fa6c98f3f2b4065 (diff)
downloadrust-985c32ef4c930cdfba23db2191014d772c354407.tar.gz
rust-985c32ef4c930cdfba23db2191014d772c354407.zip
Partially implement destructuring locals
You can now say

    let {bcx, val} = some_result_returner();

Similar for loop variables. Assigning to such variables is not safe
yet. Function arguments also remain a TODO.
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 3fba6f614f0..9c929390bd2 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1337,9 +1337,6 @@ fn parse_alt_expr(p: &parser) -> @ast::expr {
     expect(p, token::LBRACE);
     let arms: ast::arm[] = ~[];
     while p.peek() != token::RBRACE {
-        // Optionally eat the case keyword.
-        // FIXME remove this (and the optional parens) once we've updated our
-        // code to not use the old syntax
         let pats = parse_pats(p);
         let blk = parse_block(p);
         arms += ~[{pats: pats, block: blk}];
@@ -1472,7 +1469,7 @@ fn parse_pat(p: &parser) -> @ast::pat {
                          _ { true }
                        }) {
             hi = p.get_hi_pos();
-            pat = ast::pat_bind(parse_ident(p));
+            pat = ast::pat_bind(parse_value_ident(p));
         } else {
             let tag_path = parse_path_and_ty_param_substs(p);
             hi = tag_path.span.hi;
@@ -1497,14 +1494,13 @@ fn parse_pat(p: &parser) -> @ast::pat {
 
 fn parse_local(p: &parser, allow_init: bool) -> @ast::local {
     let lo = p.get_lo_pos();
-    let ident = parse_value_ident(p);
+    let pat = parse_pat(p);
     let ty = none;
     if eat(p, token::COLON) { ty = some(parse_ty(p)); }
     let init = if allow_init { parse_initializer(p) } else { none };
     ret @spanned(lo, p.get_last_hi_pos(),
                  {ty: ty,
-                  infer: false,
-                  ident: ident,
+                  pat: pat,
                   init: init,
                   id: p.get_id()});
 }