From 711ff657e260def1c05d27d6447fa6b6733a5b2a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 23 Dec 2011 18:24:49 +0100 Subject: [PATCH] Get rid of visit_fn_block in visit.rs It seems redundant and error-prone. --- src/comp/middle/resolve.rs | 13 +------------ src/comp/syntax/visit.rs | 25 ++----------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 68d4d5aac30..3a2b6ef966c 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -337,9 +337,7 @@ fn resolve_names(e: @env, c: @ast::crate) { visit_ty: bind walk_ty(e, _, _, _), visit_constr: bind walk_constr(e, _, _, _, _, _), visit_fn_proto: - bind visit_fn_proto_with_scope(e, _, _, _, _, _, _, _, _), - visit_fn_block: - bind visit_fn_block_with_scope(e, _, _, _, _, _, _) + bind visit_fn_proto_with_scope(e, _, _, _, _, _, _, _, _) with *visit::default_visitor()}; visit::visit_crate(*c, cons(scope_crate, @nil), visit::mk_vt(v)); e.used_imports.track = false; @@ -444,15 +442,6 @@ fn visit_fn_proto_with_scope(e: @env, decl: ast::fn_decl, tp: [ast::ty_param], visit::visit_fn_proto(decl, tp, body, sp, name, id, cons(scope, @sc), v); } -fn visit_fn_block_with_scope(_e: @env, decl: fn_decl, blk: ast::blk, - span: span, id: node_id, - sc: scopes, v: vt) { - let scope = scope_fn_expr(decl, id, []); - log(debug, ("scope=", scope)); - visit::visit_fn_block(decl, blk, span, id, cons(scope, @sc), v); - log(debug, ("unscope")); -} - fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt) { let pos = @mutable 0u, loc = @mutable 0u; let block_sc = cons(scope_block(b, pos, loc), @sc); diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index ecdf8c9a05d..3c77db09d49 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -36,10 +36,7 @@ visit_fn_proto: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id, E, vt), - // Function sugar like { || ... }: - visit_fn_block: fn@(fn_decl, blk, span, node_id, E, vt), - - // Invoked by both visit_fn_proto and visit_fn_block above. + // Invoked by both visit_fn_proto above. // Intended to be a common flow point for all fn decls in AST. visit_fn_body: fn@(fn_decl, blk, span, fn_ident, node_id, E, vt)}; @@ -58,7 +55,6 @@ fn default_visitor() -> visitor { visit_ty: bind skip_ty::(_, _, _), visit_constr: bind visit_constr::(_, _, _, _, _), visit_fn_proto: bind visit_fn_proto::(_, _, _, _, _, _, _, _), - visit_fn_block: bind visit_fn_block::(_, _, _, _, _, _), visit_fn_body: bind visit_fn_body::(_, _, _, _, _, _, _)}; } @@ -220,11 +216,6 @@ fn visit_fn_proto(decl: fn_decl, _tp: [ty_param], body: blk, sp: span, v.visit_fn_body(decl, body, sp, i, id, e, v); } -fn visit_fn_block(decl: fn_decl, body: blk, sp: span, id: node_id, - e: E, v: vt) { - v.visit_fn_body(decl, body, sp, option::none, id, e, v); -} - fn visit_fn_body(decl: fn_decl, body: blk, _sp: span, _name: fn_ident, _id: node_id, e: E, v: vt) { @@ -321,7 +312,7 @@ fn visit_expr(ex: @expr, e: E, v: vt) { v.visit_fn_proto(decl, [], body, ex.span, none, ex.id, e, v); } expr_fn_block(decl, body) { - v.visit_fn_block(decl, body, ex.span, ex.id, e, v); + v.visit_fn_proto(decl, [], body, ex.span, none, ex.id, e, v); } expr_block(b) { v.visit_block(b, e, v); } expr_assign(a, b) { v.visit_expr(b, e, v); v.visit_expr(a, e, v); } @@ -398,7 +389,6 @@ fn visit_arm(a: arm, e: E, v: vt) { visit_ty: fn@(@ty), visit_constr: fn@(@path, span, node_id), visit_fn_proto: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id), - visit_fn_block: fn@(fn_decl, blk, span, node_id), visit_fn_body: fn@(fn_decl, blk, span, fn_ident, node_id)}; fn simple_ignore_ty(_t: @ty) {} @@ -420,8 +410,6 @@ fn default_simple_visitor() -> simple_visitor { visit_fn_proto: fn(_d: fn_decl, _tps: [ty_param], _b: blk, _sp: span, _ident: fn_ident, _id: node_id) { }, - visit_fn_block: - fn(_f: fn_decl, _b: blk, _sp: span, _node_id: node_id) { }, visit_fn_body: fn(_f: fn_decl, _b: blk, _sp: span, _nm: fn_ident, _node_id: node_id) { } @@ -489,13 +477,6 @@ fn v_fn(f: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id), f(decl, tps, body, sp, ident, id); visit_fn_proto(decl, tps, body, sp, ident, id, e, v); } - fn v_fn_block(f: fn@(fn_decl, blk, span, node_id), - fn_decl: fn_decl, blk: blk, - sp: span, node_id: node_id, - &&e: (), v: vt<()>) { - f(fn_decl, blk, sp, node_id); - visit_fn_block(fn_decl, blk, sp, node_id, e, v); - } fn v_fn_body(f: fn@(fn_decl, blk, span, fn_ident, node_id), fn_decl: fn_decl, blk: blk, sp: span, name: fn_ident, node_id: node_id, @@ -524,8 +505,6 @@ fn v_fn_body(f: fn@(fn_decl, blk, span, fn_ident, node_id), visit_constr: bind v_constr(v.visit_constr, _, _, _, _, _), visit_fn_proto: bind v_fn(v.visit_fn_proto, _, _, _, _, _, _, _, _), - visit_fn_block: - bind v_fn_block(v.visit_fn_block, _, _, _, _, _, _), visit_fn_body: bind v_fn_body(v.visit_fn_body, _, _, _, _, _, _, _), });