about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-05-17 21:08:55 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-05-17 21:09:34 -0700
commitfdf8c498823452c720cb48e2f36841b9d4b72c25 (patch)
treef04ba9dcfe9921f5d9ce5e8b6a038f899af3ec48 /src/comp
parentdc78544d3627dd39cf2c721a16219b16276d6660 (diff)
downloadrust-fdf8c498823452c720cb48e2f36841b9d4b72c25.tar.gz
rust-fdf8c498823452c720cb48e2f36841b9d4b72c25.zip
rustc: Don't rebuild the AST when typechecking statements
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/typeck.rs36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 4470d0defa7..66240834a28 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -2598,46 +2598,26 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast::decl decl) -> @ast::decl {
     }
 }
 
-fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) -> @ast::stmt {
+fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) {
+    auto node_id;
     alt (stmt.node) {
         case (ast::stmt_decl(?decl,?a)) {
+            node_id = a.id;
             alt (decl.node) {
-                case (ast::decl_local(_)) {
-                    auto decl_1 = check_decl_local(fcx, decl);
-
-                    auto new_ann = plain_ann(a.id, fcx.ccx.tcx);
-                    write_nil_type(fcx.ccx.tcx, fcx.ccx.node_types, a.id);
-
-                    ret @fold::respan[ast::stmt_](stmt.span,
-                           ast::stmt_decl(decl_1, new_ann));
-                }
-
-                case (ast::decl_item(_)) {
-                    // Ignore for now. We'll return later.
-                    auto new_ann = plain_ann(a.id, fcx.ccx.tcx);
-                    write_nil_type(fcx.ccx.tcx, fcx.ccx.node_types, a.id);
-
-                    ret @fold::respan[ast::stmt_](stmt.span,
-                           ast::stmt_decl(decl, new_ann));
-                }
+                case (ast::decl_local(_)) { check_decl_local(fcx, decl); }
+                case (ast::decl_item(_)) { /* ignore for now */ }
             }
-
-            //         ret stmt;
         }
-
         case (ast::stmt_expr(?expr,?a)) {
+            node_id = a.id;
+
             check_expr(fcx, expr);
             auto ety = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types, expr);
             Pushdown::pushdown_expr(fcx, ety, expr);
-
-            auto new_ann = plain_ann(a.id, fcx.ccx.tcx);
-            write_nil_type(fcx.ccx.tcx, fcx.ccx.node_types, a.id);
-
-            ret @fold::respan(stmt.span, ast::stmt_expr(expr, new_ann));
         }
     }
 
-    fail;
+    write_nil_type(fcx.ccx.tcx, fcx.ccx.node_types, node_id);
 }
 
 fn check_block(&@fn_ctxt fcx, &ast::block block) {