]> git.lizzy.rs Git - rust.git/commitdiff
Go back to a single visit_fn function in visit.rs
authorMarijn Haverbeke <marijnh@gmail.com>
Fri, 23 Dec 2011 17:45:02 +0000 (18:45 +0100)
committerMarijn Haverbeke <marijnh@gmail.com>
Fri, 23 Dec 2011 17:45:02 +0000 (18:45 +0100)
14 files changed:
src/comp/middle/alias.rs
src/comp/middle/ast_map.rs
src/comp/middle/freevars.rs
src/comp/middle/kind.rs
src/comp/middle/last_use.rs
src/comp/middle/resolve.rs
src/comp/middle/tstate/annotate.rs
src/comp/middle/tstate/auxiliary.rs
src/comp/middle/tstate/bitvectors.rs
src/comp/middle/tstate/ck.rs
src/comp/middle/tstate/collect_locals.rs
src/comp/middle/tstate/pre_post_conditions.rs
src/comp/middle/typeck.rs
src/comp/syntax/visit.rs

index 5e80f7b3dbb264e26a6c52b2ff8f795364e4f34b..959f5e02e175f3a4bda79b9a1d711b1f9cf3a46f 100644 (file)
@@ -61,7 +61,7 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
                copy_map: std::map::new_int_hash(),
                ref_map: std::map::new_int_hash(),
                mutable silent: false};
-    let v = @{visit_fn_body: bind visit_fn_body(cx, _, _, _, _, _, _, _),
+    let v = @{visit_fn: bind visit_fn(cx, _, _, _, _, _, _, _, _),
               visit_expr: bind visit_expr(cx, _, _, _),
               visit_block: bind visit_block(cx, _, _, _)
               with *visit::default_visitor::<scope>()};
@@ -71,9 +71,9 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate) -> (copy_map, ref_map) {
     ret (cx.copy_map, cx.ref_map);
 }
 
-fn visit_fn_body(cx: @ctx, decl: ast::fn_decl, body: ast::blk,
-                 sp: span, _name: ast::fn_ident,
-                 id: ast::node_id, sc: scope, v: vt<scope>) {
+fn visit_fn(cx: @ctx, decl: ast::fn_decl, _ts: [ast::ty_param],
+            body: ast::blk, sp: span, _name: ast::fn_ident,
+            id: ast::node_id, sc: scope, v: vt<scope>) {
     visit::visit_fn_decl(decl, sc, v);
     let fty = ty::node_id_to_type(cx.tcx, id);
     let args = ty::ty_fn_args(cx.tcx, fty);
index 0b0d0337d2d002dfc77b36fee944126539307da8..995c16ddb2c47cfaf60182e83f0ad28e4ad364e3 100644 (file)
@@ -32,7 +32,7 @@ fn map_crate(c: crate) -> map {
         (@{visit_item: bind map_item(cx, _),
            visit_native_item: bind map_native_item(cx, _),
            visit_expr: bind map_expr(cx, _),
-           visit_fn_body: bind map_fn_body(cx, _, _, _, _, _),
+           visit_fn: bind map_fn(cx, _, _, _, _, _, _),
            visit_local: bind map_local(cx, _),
            visit_arm: bind map_arm(cx, _)
            with *visit::default_simple_visitor()});
@@ -40,8 +40,8 @@ fn map_crate(c: crate) -> map {
     ret cx.map;
 }
 
-fn map_fn_body(cx: ctx, decl: fn_decl, _body: blk,
-               _sp: codemap::span, _n: fn_ident, _id: node_id) {
+fn map_fn(cx: ctx, decl: fn_decl, _tps: [ty_param], _body: blk,
+          _sp: codemap::span, _n: fn_ident, _id: node_id) {
     for a in decl.inputs {
         cx.map.insert(a.id, node_arg(a, cx.local_id));
         cx.local_id += 1u;
index 9490b9e9ac1a8a8dca1f90231c81fd97db34e85e..9e18bae4a2ea79b4befc4c707dbb13eb1479a297 100644 (file)
@@ -82,15 +82,15 @@ fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) ->
    freevar_map {
     let freevars = new_int_hash();
 
-    let walk_fn_body = lambda (_decl: ast::fn_decl, blk: ast::blk,
-                               _sp: span, _nm: ast::fn_ident,
-                               nid: ast::node_id) {
+    let walk_fn = lambda (_decl: ast::fn_decl, _tps: [ast::ty_param],
+                          blk: ast::blk, _sp: span, _nm: ast::fn_ident,
+                          nid: ast::node_id) {
         let vars = collect_freevars(def_map, blk);
         freevars.insert(nid, vars);
     };
 
     let visitor =
-        visit::mk_simple_visitor(@{visit_fn_body: walk_fn_body
+        visit::mk_simple_visitor(@{visit_fn: walk_fn
                                    with *visit::default_simple_visitor()});
     visit::visit_crate(*crate, (), visitor);
 
index 241ca951e24c3cf26010616dc412bff51c7c4387..2c9952ddec9d5a437c03cb4308f8710e1d388824 100644 (file)
@@ -43,7 +43,7 @@ fn check_crate(tcx: ty::ctxt, method_map: typeck::method_map,
     let visit = visit::mk_vt(@{
         visit_expr: check_expr,
         visit_stmt: check_stmt,
-        visit_fn_body: check_fn_body
+        visit_fn: check_fn
         with *visit::default_visitor()
     });
     visit::visit_crate(*crate, ctx, visit);
@@ -66,8 +66,8 @@ fn with_closure_check_fn(cx: ctx, id: node_id,
 
 // Check that the free variables used in a shared/sendable closure conform
 // to the copy/move kind bounds. Then recursively check the function body.
-fn check_fn_body(decl: fn_decl, body: blk, sp: span, i: fn_ident, id: node_id,
-                 cx: ctx, v: visit::vt<ctx>) {
+fn check_fn(decl: fn_decl, tps: [ty_param], body: blk, sp: span,
+            i: fn_ident, id: node_id, cx: ctx, v: visit::vt<ctx>) {
 
     // n.b.: This could be the body of either a fn decl or a fn expr.  In the
     // former case, the prototype will be proto_bare and no check occurs.  In
@@ -87,7 +87,7 @@ fn check_fn_body(decl: fn_decl, body: blk, sp: span, i: fn_ident, id: node_id,
         }
     }
 
-    visit::visit_fn_body(decl, body, sp, i, id, cx, v);
+    visit::visit_fn(decl, tps, body, sp, i, id, cx, v);
 }
 
 fn check_fn_cap_clause(cx: ctx,
index 3f5454700c1563261cb071b68a0dd94ecc99223c..7b1a0b6c0a3fba8f9d9b10621ce7d7388c10f6d2 100644 (file)
@@ -43,7 +43,7 @@
 fn find_last_uses(c: @crate, def_map: resolve::def_map,
                   ref_map: alias::ref_map, tcx: ty::ctxt) -> last_uses {
     let v = visit::mk_vt(@{visit_expr: visit_expr,
-                           visit_fn_body: visit_fn_body
+                           visit_fn: visit_fn
                            with *visit::default_visitor()});
     let cx = {last_uses: std::map::new_int_hash(),
               def_map: def_map,
@@ -153,19 +153,19 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
     }
 }
 
-fn visit_fn_body(decl: fn_decl, body: blk,
-                 sp: span, nm: fn_ident, id: node_id,
-                 cx: ctx, v: visit::vt<ctx>) {
+fn visit_fn(decl: fn_decl, tps: [ty_param], body: blk,
+            sp: span, nm: fn_ident, id: node_id,
+            cx: ctx, v: visit::vt<ctx>) {
     let fty = ty::node_id_to_type(cx.tcx, id);
     let proto = ty::ty_fn_proto(cx.tcx, fty);
     if proto == proto_block {
         visit_block(func, cx, {||
-            visit::visit_fn_body(decl, body, sp, nm, id, cx, v);
+            visit::visit_fn(decl, tps, body, sp, nm, id, cx, v);
         });
     } else {
         let old = nil;
         cx.blocks <-> old;
-        visit::visit_fn_body(decl, body, sp, nm, id, cx, v);
+        visit::visit_fn(decl, tps, body, sp, nm, id, cx, v);
         cx.blocks <-> old;
         leave_fn(cx);
     }
index 3a2b6ef966c2ec2d0259f58197b4cffe8dc9d0e5..3c633e0e9ff1fa9fc6abb284094711f50850fe50 100644 (file)
@@ -336,8 +336,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
           visit_expr: bind walk_expr(e, _, _, _),
           visit_ty: bind walk_ty(e, _, _, _),
           visit_constr: bind walk_constr(e, _, _, _, _, _),
-          visit_fn_proto:
-              bind visit_fn_proto_with_scope(e, _, _, _, _, _, _, _, _)
+          visit_fn: bind visit_fn_with_scope(e, _, _, _, _, _, _, _, _)
           with *visit::default_visitor()};
     visit::visit_crate(*c, cons(scope_crate, @nil), visit::mk_vt(v));
     e.used_imports.track = false;
@@ -403,8 +402,8 @@ fn visit_item_with_scope(i: @ast::item, sc: scopes, v: vt<scopes>) {
         alt ifce { some(ty) { v.visit_ty(ty, sc, v); } _ {} }
         v.visit_ty(sty, sc, v);
         for m in methods {
-            v.visit_fn_proto(m.decl, tps + m.tps, m.body, m.span,
-                             some(m.ident), m.id, sc, v);
+            v.visit_fn(m.decl, tps + m.tps, m.body, m.span,
+                       some(m.ident), m.id, sc, v);
         }
       }
       _ { visit::visit_item(i, sc, v); }
@@ -416,9 +415,9 @@ fn visit_native_item_with_scope(ni: @ast::native_item, sc: scopes,
     visit::visit_native_item(ni, cons(scope_native_item(ni), @sc), v);
 }
 
-fn visit_fn_proto_with_scope(e: @env, decl: ast::fn_decl, tp: [ast::ty_param],
-                             body: ast::blk, sp: span, name: fn_ident,
-                             id: node_id, sc: scopes, v: vt<scopes>) {
+fn visit_fn_with_scope(e: @env, decl: ast::fn_decl, tp: [ast::ty_param],
+                       body: ast::blk, sp: span, name: fn_ident,
+                       id: node_id, sc: scopes, v: vt<scopes>) {
     // is this a main fn declaration?
     alt name {
       some(nm) {
@@ -439,7 +438,7 @@ fn visit_fn_proto_with_scope(e: @env, decl: ast::fn_decl, tp: [ast::ty_param],
       _ { scope_fn_expr(decl, id, tp) }
     };
 
-    visit::visit_fn_proto(decl, tp, body, sp, name, id, cons(scope, @sc), v);
+    visit::visit_fn(decl, tp, body, sp, name, id, cons(scope, @sc), v);
 }
 
 fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt<scopes>) {
index 65988ef917e4f304c537da166504a73aaa749299..cc1360114cdaa9f4f4bb2a3d3fb017a9c0e4caf2 100644 (file)
@@ -56,8 +56,8 @@ fn visit_fn(ccx: crate_ctxt, num_constraints: uint, body: blk) {
     init_vecs(ccx, node_id_vec, num_constraints);
 }
 
-fn annotate_in_fn_body(ccx: crate_ctxt, _decl: fn_decl, body: blk,
-                       _sp: span, _n: fn_ident, id: node_id) {
+fn annotate_in_fn(ccx: crate_ctxt, _decl: fn_decl, _ts: [ty_param], body: blk,
+                  _sp: span, _n: fn_ident, id: node_id) {
     let f_info = get_fn_info(ccx, id);
     visit_fn(ccx, num_constraints(f_info), body);
 }
@@ -65,7 +65,7 @@ fn annotate_in_fn_body(ccx: crate_ctxt, _decl: fn_decl, body: blk,
 fn annotate_crate(ccx: crate_ctxt, crate: crate) {
     let do_ann =
         visit::mk_simple_visitor(
-            @{visit_fn_body: bind annotate_in_fn_body(ccx, _, _, _, _, _)
+            @{visit_fn: bind annotate_in_fn(ccx, _, _, _, _, _, _)
               with *visit::default_simple_visitor()});
     visit::visit_crate(crate, (), do_ann);
 }
index fe9a7b496dba10ee3b5db586a112a01f660a8ba2..340b2264354bd8ff36249458a98eb5159f626c10 100644 (file)
@@ -1008,7 +1008,7 @@ fn op_to_oper_ty(io: init_op) -> oper_type {
 }
 
 // default function visitor
-fn do_nothing<T>(_decl: fn_decl, _body: blk,
+fn do_nothing<T>(_decl: fn_decl, _ts: [ty_param], _body: blk,
                  _sp: span, _i: fn_ident, _id: node_id,
                  _t: T, _v: visit::vt<T>) {
 }
index 10f5cfa10fe4729c8b3a14fec8f412049b99b78f..120e33d9254891843680c375f62a3418ddad9d8d 100644 (file)
@@ -151,7 +151,7 @@ fn relax_precond_block(fcx: fn_ctxt, i: node_id, b: blk) {
           visit_stmt: relax_precond_stmt,
           visit_item:
               fn (_i: @item, _cx: relax_ctxt, _vt: visit::vt<relax_ctxt>) { },
-          visit_fn_body: bind do_nothing(_, _, _, _, _, _, _)
+          visit_fn: bind do_nothing(_, _, _, _, _, _, _, _)
              with *visitor};
     let v1 = visit::mk_vt(visitor);
     v1.visit_block(b, cx, v1);
index 0b2f9a3e9a557311fab6d2008701e8274e7299c2..f790334fbc492ef0b1bfa204070cc0e76189136e 100644 (file)
@@ -106,9 +106,9 @@ fn check_states_against_conditions(fcx: fn_ctxt,
     let visitor = visit::mk_vt(
         @{visit_stmt: check_states_stmt,
           visit_expr: check_states_expr,
-          visit_fn_body: bind do_nothing::<fn_ctxt>(_, _, _, _, _, _, _)
+          visit_fn: bind do_nothing::<fn_ctxt>(_, _, _, _, _, _, _, _)
           with *visit::default_visitor::<fn_ctxt>()});
-    visit::visit_fn_body(f_decl, f_body, sp, nm, id, fcx, visitor);
+    visit::visit_fn(f_decl, [], f_body, sp, nm, id, fcx, visitor);
 
     /* Check that the return value is initialized */
     let post = aux::block_poststate(fcx.ccx, f_body);
@@ -158,10 +158,10 @@ fn check_fn_states(fcx: fn_ctxt,
     check_states_against_conditions(fcx, f_decl, f_body, sp, nm, id);
 }
 
-fn fn_states(f_decl: ast::fn_decl, f_body: ast::blk,
+fn fn_states(f_decl: ast::fn_decl, tps: [ast::ty_param], f_body: ast::blk,
              sp: span, i: ast::fn_ident, id: node_id,
              ccx: crate_ctxt, v: visit::vt<crate_ctxt>) {
-    visit::visit_fn_body(f_decl, f_body, sp, i, id, ccx, v);
+    visit::visit_fn(f_decl, tps, f_body, sp, i, id, ccx, v);
     /* Look up the var-to-bit-num map for this function */
 
     assert (ccx.fm.contains_key(id));
@@ -182,13 +182,13 @@ fn check_crate(cx: ty::ctxt, crate: @crate) {
     /* Compute the pre and postcondition for every subexpression */
 
     let vtor = visit::default_visitor::<crate_ctxt>();
-    vtor = @{visit_fn_body: fn_pre_post with *vtor};
+    vtor = @{visit_fn: fn_pre_post with *vtor};
     visit::visit_crate(*crate, ccx, visit::mk_vt(vtor));
 
     /* Check the pre- and postcondition against the pre- and poststate
        for every expression */
     let vtor = visit::default_visitor::<crate_ctxt>();
-    vtor = @{visit_fn_body: fn_states with *vtor};
+    vtor = @{visit_fn: fn_states with *vtor};
     visit::visit_crate(*crate, ccx, visit::mk_vt(vtor));
 }
 //
index b853643362b85e58894a43d8bc2ce24a4755aeb7..457a6ca0173563d5a789159e8646686f37cbe247 100644 (file)
@@ -46,6 +46,7 @@ fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) {
 
 fn find_locals(tcx: ty::ctxt,
                f_decl: fn_decl,
+               tps: [ty_param],
                f_body: blk,
                sp: span,
                n: fn_ident,
@@ -56,10 +57,10 @@ fn find_locals(tcx: ty::ctxt,
     visitor =
         @{visit_local: collect_local,
           visit_expr: collect_pred,
-          visit_fn_body: bind do_nothing(_, _, _, _, _, _, _)
+          visit_fn: bind do_nothing(_, _, _, _, _, _, _, _)
           with *visitor};
-    visit::visit_fn_body(f_decl, f_body, sp,
-                         n, id, cx, visit::mk_vt(visitor));
+    visit::visit_fn(f_decl, tps, f_body, sp,
+                    n, id, cx, visit::mk_vt(visitor));
     ret cx;
 }
 
@@ -98,6 +99,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) ->
    to a bit number in the precondition/postcondition vectors */
 fn mk_fn_info(ccx: crate_ctxt,
               f_decl: fn_decl,
+              tps: [ty_param],
               f_body: blk,
               f_sp: span,
               f_name: fn_ident,
@@ -106,7 +108,8 @@ fn mk_fn_info(ccx: crate_ctxt,
     let res_map = @new_def_hash::<constraint>();
     let next: uint = 0u;
 
-    let cx: ctxt = find_locals(ccx.tcx, f_decl, f_body, f_sp, f_name, id);
+    let cx: ctxt = find_locals(ccx.tcx, f_decl, tps, f_body, f_sp,
+                               f_name, id);
     /* now we have to add bit nums for both the constraints
        and the variables... */
 
@@ -163,8 +166,8 @@ fn mk_fn_info(ccx: crate_ctxt,
    to bit number) */
 fn mk_f_to_fn_info(ccx: crate_ctxt, c: @crate) {
     let visitor =
-        visit::mk_simple_visitor(@{visit_fn_body:
-                                       bind mk_fn_info(ccx, _, _, _, _, _)
+        visit::mk_simple_visitor(@{visit_fn:
+                                       bind mk_fn_info(ccx, _, _, _, _, _, _)
                                    with *visit::default_simple_visitor()});
     visit::visit_crate(*c, (), visitor);
 }
index 8f960eea6c08144c429698a8d7aa4d509faf84c2..9a3100e7bb2edf0eec9a981787f8a3419ea118a5 100644 (file)
@@ -727,10 +727,10 @@ fn find_pre_post_fn(fcx: fn_ctxt, body: blk) {
     }
 }
 
-fn fn_pre_post(decl: fn_decl, body: blk, sp: span,
+fn fn_pre_post(decl: fn_decl, tps: [ty_param], body: blk, sp: span,
                i: fn_ident, id: node_id,
                ccx: crate_ctxt, v: visit::vt<crate_ctxt>) {
-    visit::visit_fn_body(decl, body, sp, i, id, ccx, v);
+    visit::visit_fn(decl, tps, body, sp, i, id, ccx, v);
     assert (ccx.fm.contains_key(id));
     let fcx =
         {enclosing: ccx.fm.get(id),
index 3a137bab2ce62ff36e49e4a3a4022bd8af6495e9..16a1801fd89b9834bfad76d1ce03c8f15d6c97ad 100644 (file)
@@ -1124,16 +1124,16 @@ fn gather_locals(ccx: @crate_ctxt,
         };
 
     // Don't descend into fns and items
-    fn visit_fn_body<T>(_decl: ast::fn_decl, _body: ast::blk,
-                        _sp: span, _nm: ast::fn_ident, _id: ast::node_id,
-                        _t: T, _v: visit::vt<T>) {
+    fn visit_fn<T>(_decl: ast::fn_decl, _ts: [ast::ty_param], _body: ast::blk,
+                   _sp: span, _nm: ast::fn_ident, _id: ast::node_id,
+                   _t: T, _v: visit::vt<T>) {
     }
     fn visit_item<E>(_i: @ast::item, _e: E, _v: visit::vt<E>) { }
 
     let visit =
         @{visit_local: visit_local,
           visit_pat: visit_pat,
-          visit_fn_body: bind visit_fn_body(_, _, _, _, _, _, _),
+          visit_fn: bind visit_fn(_, _, _, _, _, _, _, _),
           visit_item: bind visit_item(_, _, _)
               with *visit::default_visitor()};
 
index 3c77db09d499680fe82b3e4ab853e961874dff0e..22c3d104f3be70979caa0fb04e552adfe7d10ad5 100644 (file)
       visit_expr: fn@(@expr, E, vt<E>),
       visit_ty: fn@(@ty, E, vt<E>),
       visit_constr: fn@(@path, span, node_id, E, vt<E>),
-
-      // A function with a fully specified prototype:
-      visit_fn_proto: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id,
-                          E, vt<E>),
-
-      // 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>)};
+      visit_fn: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id,
+                    E, vt<E>)};
 
 fn default_visitor<E>() -> visitor<E> {
     ret @{visit_mod: bind visit_mod::<E>(_, _, _, _),
@@ -54,8 +48,7 @@ fn default_visitor<E>() -> visitor<E> {
           visit_expr: bind visit_expr::<E>(_, _, _),
           visit_ty: bind skip_ty::<E>(_, _, _),
           visit_constr: bind visit_constr::<E>(_, _, _, _, _),
-          visit_fn_proto: bind visit_fn_proto::<E>(_, _, _, _, _, _, _, _),
-          visit_fn_body: bind visit_fn_body::<E>(_, _, _, _, _, _, _)};
+          visit_fn: bind visit_fn::<E>(_, _, _, _, _, _, _, _)};
 }
 
 fn visit_crate<E>(c: crate, e: E, v: vt<E>) {
@@ -92,7 +85,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
     alt i.node {
       item_const(t, ex) { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); }
       item_fn(decl, tp, body) {
-        v.visit_fn_proto(decl, tp, body, i.span, some(i.ident), i.id, e, v);
+        v.visit_fn(decl, tp, body, i.span, some(i.ident), i.id, e, v);
       }
       item_mod(m) { v.visit_mod(m, i.span, e, v); }
       item_native_mod(nm) {
@@ -101,8 +94,8 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
       }
       item_ty(t, _) { v.visit_ty(t, e, v); }
       item_res(decl, tps, body, dtor_id, _) {
-        v.visit_fn_proto(decl, tps, body, i.span, some(i.ident), dtor_id,
-                         e, v);
+        v.visit_fn(decl, tps, body, i.span, some(i.ident), dtor_id,
+                   e, v);
       }
       item_tag(variants, _) {
         for vr: variant in variants {
@@ -112,16 +105,16 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
       item_obj(ob, _, _) {
         for f: obj_field in ob.fields { v.visit_ty(f.ty, e, v); }
         for m: @method in ob.methods {
-            v.visit_fn_proto(m.decl, m.tps, m.body, m.span,
-                             some(m.ident), m.id, e, v);
+            v.visit_fn(m.decl, m.tps, m.body, m.span,
+                       some(m.ident), m.id, e, v);
         }
       }
       item_impl(_, ifce, ty, methods) {
         alt ifce { some(ty) { v.visit_ty(ty, e, v); } _ {} }
         v.visit_ty(ty, e, v);
         for m in methods {
-            v.visit_fn_proto(m.decl, m.tps, m.body, m.span,
-                             some(m.ident), m.id, e, v);
+            v.visit_fn(m.decl, m.tps, m.body, m.span,
+                       some(m.ident), m.id, e, v);
         }
       }
       item_iface(_, methods) {
@@ -211,14 +204,8 @@ fn visit_fn_decl<E>(fd: fn_decl, e: E, v: vt<E>) {
     v.visit_ty(fd.output, e, v);
 }
 
-fn visit_fn_proto<E>(decl: fn_decl, _tp: [ty_param], body: blk, sp: span,
-                     i: fn_ident, id: node_id, e: E, v: vt<E>) {
-    v.visit_fn_body(decl, body, sp, i, 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>) {
+fn visit_fn<E>(decl: fn_decl, _tp: [ty_param], body: blk, _sp: span,
+               _i: fn_ident, _id: node_id, e: E, v: vt<E>) {
     visit_fn_decl(decl, e, v);
     v.visit_block(body, e, v);
 }
@@ -309,10 +296,10 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
         for a: arm in arms { v.visit_arm(a, e, v); }
       }
       expr_fn(decl, body, _) {
-        v.visit_fn_proto(decl, [], body, ex.span, none, ex.id, e, v);
+        v.visit_fn(decl, [], body, ex.span, none, ex.id, e, v);
       }
       expr_fn_block(decl, body) {
-        v.visit_fn_proto(decl, [], body, ex.span, none, ex.id, e, v);
+        v.visit_fn(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); }
@@ -355,8 +342,8 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
           some(ex) { v.visit_expr(ex, e, v); }
         }
         for m: @method in anon_obj.methods {
-            v.visit_fn_proto(m.decl, m.tps, m.body, m.span,
-                             some(m.ident), m.id, e, v);
+            v.visit_fn(m.decl, m.tps, m.body, m.span,
+                       some(m.ident), m.id, e, v);
         }
       }
       expr_mac(mac) { visit_mac(mac, e, v); }
@@ -388,8 +375,7 @@ fn visit_arm<E>(a: arm, e: E, v: vt<E>) {
       visit_expr: fn@(@expr),
       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_body: fn@(fn_decl, blk, span, fn_ident, node_id)};
+      visit_fn: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id)};
 
 fn simple_ignore_ty(_t: @ty) {}
 
@@ -407,12 +393,8 @@ fn default_simple_visitor() -> simple_visitor {
           visit_expr: fn(_e: @expr) { },
           visit_ty: simple_ignore_ty,
           visit_constr: fn(_p: @path, _sp: span, _id: node_id) { },
-          visit_fn_proto:
-              fn(_d: fn_decl, _tps: [ty_param], _b: blk, _sp: span,
-                 _ident: fn_ident, _id: node_id) { },
-          visit_fn_body:
-              fn(_f: fn_decl, _b: blk, _sp: span,
-                 _nm: fn_ident, _node_id: node_id) { }
+          visit_fn: fn(_d: fn_decl, _tps: [ty_param], _b: blk, _sp: span,
+                       _ident: fn_ident, _id: node_id) { }
          };
 }
 
@@ -475,14 +457,7 @@ fn v_fn(f: fn@(fn_decl, [ty_param], blk, span, fn_ident, node_id),
             decl: fn_decl, tps: [ty_param], body: blk, sp: span,
             ident: fn_ident, id: node_id, &&e: (), v: vt<()>) {
         f(decl, tps, body, sp, ident, id);
-        visit_fn_proto(decl, tps, body, sp, ident, 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,
-                 &&e: (), v: vt<()>) {
-        f(fn_decl, blk, sp, name, node_id);
-        visit_fn_body(fn_decl, blk, sp, name, node_id, e, v);
+        visit_fn(decl, tps, body, sp, ident, id, e, v);
     }
     let visit_ty = if v.visit_ty == simple_ignore_ty {
         bind skip_ty(_, _, _)
@@ -503,10 +478,7 @@ fn v_fn_body(f: fn@(fn_decl, blk, span, fn_ident, node_id),
                 visit_expr: bind v_expr(v.visit_expr, _, _, _),
                 visit_ty: visit_ty,
                 visit_constr: bind v_constr(v.visit_constr, _, _, _, _, _),
-                visit_fn_proto:
-                    bind v_fn(v.visit_fn_proto, _, _, _, _, _, _, _, _),
-                visit_fn_body:
-                    bind v_fn_body(v.visit_fn_body, _, _, _, _, _, _, _),
+                visit_fn: bind v_fn(v.visit_fn, _, _, _, _, _, _, _, _)
                });
 }