mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Get rid of visit_fn_block in visit.rs
It seems redundant and error-prone.
This commit is contained in:
parent
25e65239ad
commit
711ff657e2
@ -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<scopes>) {
|
||||
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<scopes>) {
|
||||
let pos = @mutable 0u, loc = @mutable 0u;
|
||||
let block_sc = cons(scope_block(b, pos, loc), @sc);
|
||||
|
@ -36,10 +36,7 @@ type visitor<E> =
|
||||
visit_fn_proto: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id,
|
||||
E, vt<E>),
|
||||
|
||||
// Function sugar like { || ... }:
|
||||
visit_fn_block: fn@(fn_decl, blk, span, node_id, E, vt<E>),
|
||||
|
||||
// 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<E>)};
|
||||
|
||||
@ -58,7 +55,6 @@ fn default_visitor<E>() -> visitor<E> {
|
||||
visit_ty: bind skip_ty::<E>(_, _, _),
|
||||
visit_constr: bind visit_constr::<E>(_, _, _, _, _),
|
||||
visit_fn_proto: bind visit_fn_proto::<E>(_, _, _, _, _, _, _, _),
|
||||
visit_fn_block: bind visit_fn_block::<E>(_, _, _, _, _, _),
|
||||
visit_fn_body: bind visit_fn_body::<E>(_, _, _, _, _, _, _)};
|
||||
}
|
||||
|
||||
@ -220,11 +216,6 @@ fn visit_fn_proto<E>(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<E>(decl: fn_decl, body: blk, sp: span, id: node_id,
|
||||
e: E, v: vt<E>) {
|
||||
v.visit_fn_body(decl, body, sp, option::none, id, e, v);
|
||||
}
|
||||
|
||||
fn visit_fn_body<E>(decl: fn_decl, body: blk, _sp: span,
|
||||
_name: fn_ident, _id: node_id,
|
||||
e: E, v: vt<E>) {
|
||||
@ -321,7 +312,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
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 @@ type simple_visitor =
|
||||
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 mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
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 mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
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, _, _, _, _, _, _, _),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user