about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-08-28 15:54:45 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-09-06 06:11:12 -0700
commit5e36a997945ddc3964a1fe937bc5390cc5b526c8 (patch)
tree0c37dfa0d20004d0098e0bbb620744a1ad4a81d8 /src/libsyntax/print
parentadc1427282b4da8f963550e87cdbe512157958b4 (diff)
downloadrust-5e36a997945ddc3964a1fe937bc5390cc5b526c8.tar.gz
rust-5e36a997945ddc3964a1fe937bc5390cc5b526c8.zip
Refactor trans to replace lvalue and friends with Datum.
Also:
- report illegal move/ref combos whether or not ref comes first
- commented out fix for #3387, too restrictive and causes an ICE
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index dd5fc57f684..8b17760c7f2 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1169,29 +1169,38 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
               None => ()
             }
             word_space(s, ~"=>");
+
             // Extract the expression from the extra block the parser adds
-            assert arm.body.node.view_items.is_empty();
-            assert arm.body.node.stmts.is_empty();
-            assert arm.body.node.rules == ast::default_blk;
-            match arm.body.node.expr {
-              Some(expr) => {
-                match expr.node {
-                  ast::expr_block(blk) => {
-                    // the block will close the pattern's ibox
-                    print_block_unclosed_indent(s, blk, alt_indent_unit);
-                  }
-                  _ => {
-                    end(s); // close the ibox for the pattern
-                    print_expr(s, expr);
-                  }
-                }
-                if !expr_is_simple_block(expr)
-                    && i < len - 1 {
-                    word(s.s, ~",");
+            // in the case of foo => expr
+            if arm.body.node.view_items.is_empty() &&
+                arm.body.node.stmts.is_empty() &&
+                arm.body.node.rules == ast::default_blk &&
+                arm.body.node.expr.is_some()
+            {
+                match arm.body.node.expr {
+                    Some(expr) => {
+                        match expr.node {
+                            ast::expr_block(blk) => {
+                                // the block will close the pattern's ibox
+                                print_block_unclosed_indent(
+                                    s, blk, alt_indent_unit);
+                            }
+                            _ => {
+                                end(s); // close the ibox for the pattern
+                                print_expr(s, expr);
+                            }
+                        }
+                        if !expr_is_simple_block(expr)
+                            && i < len - 1 {
+                            word(s.s, ~",");
+                        }
+                        end(s); // close enclosing cbox
+                    }
+                    None => fail
                 }
-                end(s); // close enclosing cbox
-              }
-              None => fail
+            } else {
+                // the block will close the pattern's ibox
+                print_block_unclosed_indent(s, arm.body, alt_indent_unit);
             }
         }
         bclose_(s, expr.span, alt_indent_unit);