Skip to content

Commit d217418

Browse files
committed
rustc: Make check_block not rebuild the AST
1 parent 10503a4 commit d217418

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/comp/middle/typeck.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,11 +2646,8 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) -> @ast::stmt {
26462646
fail;
26472647
}
26482648

2649-
fn check_block(&@fn_ctxt fcx, &ast::block block) -> ast::block {
2650-
let vec[@ast::stmt] stmts = [];
2651-
for (@ast::stmt s in block.node.stmts) {
2652-
vec::push[@ast::stmt](stmts, check_stmt(fcx, s));
2653-
}
2649+
fn check_block(&@fn_ctxt fcx, &ast::block block) {
2650+
for (@ast::stmt s in block.node.stmts) { check_stmt(fcx, s); }
26542651

26552652
alt (block.node.expr) {
26562653
case (none[@ast::expr]) { /* empty */ }
@@ -2661,11 +2658,7 @@ fn check_block(&@fn_ctxt fcx, &ast::block block) -> ast::block {
26612658
}
26622659
}
26632660

2664-
auto new_ann = plain_ann(block.node.a.id, fcx.ccx.tcx);
26652661
write_nil_type(fcx.ccx.tcx, fcx.ccx.node_types, block.node.a.id);
2666-
2667-
ret fold::respan(block.span,
2668-
rec(stmts=stmts, expr=block.node.expr, a=new_ann));
26692662
}
26702663

26712664
fn check_const(&@crate_ctxt ccx, &span sp, &ast::ident ident, &@ast::ty t,
@@ -2710,7 +2703,7 @@ fn check_fn(&@crate_ctxt ccx, &ast::fn_decl decl, ast::proto proto,
27102703
ccx = ccx);
27112704

27122705
// TODO: Make sure the type of the block agrees with the function type.
2713-
auto block_t = check_block(fcx, body);
2706+
check_block(fcx, body);
27142707
alt (decl.purity) {
27152708
case (ast::pure_fn) {
27162709
// per the previous comment, this just checks that the declared
@@ -2722,10 +2715,9 @@ fn check_fn(&@crate_ctxt ccx, &ast::fn_decl decl, ast::proto proto,
27222715
case (_) {}
27232716
}
27242717

2725-
writeback::resolve_local_types_in_block(fcx, block_t);
2718+
writeback::resolve_local_types_in_block(fcx, body);
27262719

2727-
auto fn_t = rec(decl=decl, proto=proto, body=block_t);
2728-
ret fn_t;
2720+
ret rec(decl=decl, proto=proto, body=body);
27292721
}
27302722

27312723
fn check_item_fn(&@crate_ctxt ccx, &span sp, &ast::ident ident, &ast::_fn f,

0 commit comments

Comments
 (0)