Use visit_fn_{pre,post} to avoid going past lambdas during writeback instead of explicitly casing.
This commit is contained in:
parent
4499ebe858
commit
818d7c9398
@ -966,13 +966,8 @@ mod writeback {
|
||||
fn visit_stmt_pre(@fn_ctxt fcx, &@ast::stmt s) {
|
||||
resolve_type_vars_for_node(fcx, s.span, ty::stmt_node_id(s));
|
||||
}
|
||||
fn visit_expr_pre(@mutable bool ignore, @fn_ctxt fcx, &@ast::expr e) {
|
||||
fn visit_expr_pre(@fn_ctxt fcx, &@ast::expr e) {
|
||||
resolve_type_vars_for_node(fcx, e.span, e.id);
|
||||
alt (e.node) {
|
||||
// We don't want to recurse down into lambdas.
|
||||
case (ast::expr_fn(_)) { *ignore = true; }
|
||||
case (_) { }
|
||||
}
|
||||
}
|
||||
fn visit_expr_post(@mutable bool ignore, &@ast::expr e) {
|
||||
*ignore = false;
|
||||
@ -1000,8 +995,7 @@ mod writeback {
|
||||
}
|
||||
}
|
||||
fn resolve_type_vars_in_block(&@fn_ctxt fcx, &ast::block block) {
|
||||
// A trick to ignore any contained items.
|
||||
|
||||
// A trick to ignore any contained items and lambdas.
|
||||
auto ignore = @mutable false;
|
||||
fn visit_item_pre(@mutable bool ignore, &@ast::item item) {
|
||||
*ignore = true;
|
||||
@ -1009,14 +1003,23 @@ mod writeback {
|
||||
fn visit_item_post(@mutable bool ignore, &@ast::item item) {
|
||||
*ignore = false;
|
||||
}
|
||||
fn visit_fn_pre(@mutable bool ignore, &ast::_fn f, &span sp,
|
||||
&ast::fn_ident i, ast::node_id d) {
|
||||
*ignore = true;
|
||||
}
|
||||
fn visit_fn_post(@mutable bool ignore, &ast::_fn f, &span sp,
|
||||
&ast::fn_ident i, ast::node_id d) {
|
||||
*ignore = false;
|
||||
}
|
||||
fn keep_going(@mutable bool ignore) -> bool { ret !*ignore; }
|
||||
auto visit =
|
||||
rec(keep_going=bind keep_going(ignore),
|
||||
visit_item_pre=bind visit_item_pre(ignore, _),
|
||||
visit_item_post=bind visit_item_post(ignore, _),
|
||||
visit_fn_pre=bind visit_fn_pre(ignore, _, _, _, _),
|
||||
visit_fn_post=bind visit_fn_post(ignore, _, _, _, _),
|
||||
visit_stmt_pre=bind visit_stmt_pre(fcx, _),
|
||||
visit_expr_pre=bind visit_expr_pre(ignore, fcx, _),
|
||||
visit_expr_post=bind visit_expr_post(ignore, _),
|
||||
visit_expr_pre=bind visit_expr_pre(fcx, _),
|
||||
visit_block_pre=bind visit_block_pre(fcx, _),
|
||||
visit_pat_pre=bind visit_pat_pre(fcx, _),
|
||||
visit_local_pre=bind visit_local_pre(fcx, _)
|
||||
|
Loading…
x
Reference in New Issue
Block a user