auto merge of #7084 : pnkfelix/rust/fsk-visitor-refactoring, r=pnkfelix

This step 1 in my plan for issue #7081: Refactor visit.rs with a `@Visitor` trait.
This commit is contained in:
bors 2013-06-12 14:34:34 -07:00
commit df483e82e7
36 changed files with 765 additions and 775 deletions

View File

@ -176,7 +176,7 @@ pub fn steal(crate: @ast::crate, tm: test_mode) -> StolenStuff {
visit_ty: |a| stash_ty_if(safe_to_steal_ty, tys, a, tm),
.. *visit::default_simple_visitor()
});
visit::visit_crate(crate, (), v);
visit::visit_crate(crate, ((), v));
StolenStuff {
exprs: (*exprs).clone(),
tys: (*tys).clone(),
@ -539,7 +539,7 @@ pub fn has_raw_pointers(c: @ast::crate) -> bool {
visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_ty: |a| visit_ty(has_rp, a),
.. *visit::default_simple_visitor()});
visit::visit_crate(c, (), v);
visit::visit_crate(c, ((), v));
return *has_rp;
}

View File

@ -52,7 +52,7 @@ pub fn read_crates(diag: @span_handler,
visit_item: |a| visit_item(e, a),
.. *visit::default_simple_visitor()});
visit_crate(e, crate);
visit::visit_crate(crate, (), v);
visit::visit_crate(crate, ((), v));
dump_crates(e.crate_cache);
warn_if_multiple_versions(e, diag, e.crate_cache);
}

View File

@ -1120,12 +1120,12 @@ fn encode_info_for_items(ecx: @EncodeContext,
encode_info_for_mod(ecx, ebml_w, &crate.node.module,
crate_node_id, [],
syntax::parse::token::special_idents::invalid);
visit::visit_crate(crate, (), visit::mk_vt(@visit::Visitor {
visit_expr: |_e, _cx, _v| { },
visit::visit_crate(crate, ((), visit::mk_vt(@visit::Visitor {
visit_expr: |_e, (_cx, _v)| { },
visit_item: {
let ebml_w = copy *ebml_w;
|i, cx, v| {
visit::visit_item(i, cx, v);
|i, (cx, v)| {
visit::visit_item(i, (cx, v));
match ecx.tcx.items.get_copy(&i.id) {
ast_map::node_item(_, pt) => {
let mut ebml_w = copy ebml_w;
@ -1137,8 +1137,8 @@ fn encode_info_for_items(ecx: @EncodeContext,
},
visit_foreign_item: {
let ebml_w = copy *ebml_w;
|ni, cx, v| {
visit::visit_foreign_item(ni, cx, v);
|ni, (cx, v)| {
visit::visit_foreign_item(ni, (cx, v));
match ecx.tcx.items.get_copy(&ni.id) {
ast_map::node_foreign_item(_, abi, _, pt) => {
let mut ebml_w = copy ebml_w;
@ -1155,7 +1155,7 @@ fn encode_info_for_items(ecx: @EncodeContext,
}
},
..*visit::default_visitor()
}));
})));
ebml_w.end_tag();
return /*bad*/copy *index;
}

View File

@ -62,7 +62,7 @@ pub fn check_loans(bccx: @BorrowckCtxt,
visit_pat: check_loans_in_pat,
visit_fn: check_loans_in_fn,
.. *visit::default_visitor()});
(vt.visit_block)(body, clcx, vt);
(vt.visit_block)(body, (clcx, vt));
}
enum MoveError {
@ -614,8 +614,8 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind,
body: &ast::blk,
sp: span,
id: ast::node_id,
this: @mut CheckLoanCtxt<'a>,
visitor: visit::vt<@mut CheckLoanCtxt<'a>>) {
(this, visitor): (@mut CheckLoanCtxt<'a>,
visit::vt<@mut CheckLoanCtxt<'a>>)) {
match *fk {
visit::fk_item_fn(*) |
visit::fk_method(*) => {
@ -629,7 +629,7 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind,
}
}
visit::visit_fn(fk, decl, body, sp, id, this, visitor);
visit::visit_fn(fk, decl, body, sp, id, (this, visitor));
fn check_captured_variables(this: @mut CheckLoanCtxt,
closure_id: ast::node_id,
@ -677,15 +677,15 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind,
}
fn check_loans_in_local<'a>(local: @ast::local,
this: @mut CheckLoanCtxt<'a>,
vt: visit::vt<@mut CheckLoanCtxt<'a>>) {
visit::visit_local(local, this, vt);
(this, vt): (@mut CheckLoanCtxt<'a>,
visit::vt<@mut CheckLoanCtxt<'a>>)) {
visit::visit_local(local, (this, vt));
}
fn check_loans_in_expr<'a>(expr: @ast::expr,
this: @mut CheckLoanCtxt<'a>,
vt: visit::vt<@mut CheckLoanCtxt<'a>>) {
visit::visit_expr(expr, this, vt);
(this, vt): (@mut CheckLoanCtxt<'a>,
visit::vt<@mut CheckLoanCtxt<'a>>)) {
visit::visit_expr(expr, (this, vt));
debug!("check_loans_in_expr(expr=%s)",
expr.repr(this.tcx()));
@ -740,8 +740,8 @@ fn check_loans_in_expr<'a>(expr: @ast::expr,
}
fn check_loans_in_pat<'a>(pat: @ast::pat,
this: @mut CheckLoanCtxt<'a>,
vt: visit::vt<@mut CheckLoanCtxt<'a>>)
(this, vt): (@mut CheckLoanCtxt<'a>,
visit::vt<@mut CheckLoanCtxt<'a>>))
{
this.check_for_conflicting_loans(pat.id);
@ -756,13 +756,13 @@ fn check_loans_in_pat<'a>(pat: @ast::pat,
// rewalk the patterns and rebuild the pattern
// categorizations.
visit::visit_pat(pat, this, vt);
visit::visit_pat(pat, (this, vt));
}
fn check_loans_in_block<'a>(blk: &ast::blk,
this: @mut CheckLoanCtxt<'a>,
vt: visit::vt<@mut CheckLoanCtxt<'a>>)
(this, vt): (@mut CheckLoanCtxt<'a>,
visit::vt<@mut CheckLoanCtxt<'a>>))
{
visit::visit_block(blk, this, vt);
visit::visit_block(blk, (this, vt));
this.check_for_conflicting_loans(blk.node.id);
}

View File

@ -92,19 +92,19 @@ pub fn gather_loans(bccx: @BorrowckCtxt,
visit_pat: add_pat_to_id_range,
visit_local: gather_loans_in_local,
.. *visit::default_visitor()});
(v.visit_block)(body, glcx, v);
(v.visit_block)(body, (glcx, v));
return (glcx.id_range, glcx.all_loans, glcx.move_data);
}
fn add_pat_to_id_range(p: @ast::pat,
this: @mut GatherLoanCtxt,
v: visit::vt<@mut GatherLoanCtxt>) {
(this, v): (@mut GatherLoanCtxt,
visit::vt<@mut GatherLoanCtxt>)) {
// NB: This visitor function just adds the pat ids into the id
// range. We gather loans that occur in patterns using the
// `gather_pat()` method below. Eventually these two should be
// brought together.
this.id_range.add(p.id);
visit::visit_pat(p, this, v);
visit::visit_pat(p, (this, v));
}
fn gather_loans_in_fn(fk: &visit::fn_kind,
@ -112,8 +112,8 @@ fn gather_loans_in_fn(fk: &visit::fn_kind,
body: &ast::blk,
sp: span,
id: ast::node_id,
this: @mut GatherLoanCtxt,
v: visit::vt<@mut GatherLoanCtxt>) {
(this, v): (@mut GatherLoanCtxt,
visit::vt<@mut GatherLoanCtxt>)) {
match fk {
// Do not visit items here, the outer loop in borrowck/mod
// will visit them for us in turn.
@ -124,22 +124,22 @@ fn gather_loans_in_fn(fk: &visit::fn_kind,
// Visit closures as part of the containing item.
&visit::fk_anon(*) | &visit::fk_fn_block(*) => {
this.push_repeating_id(body.node.id);
visit::visit_fn(fk, decl, body, sp, id, this, v);
visit::visit_fn(fk, decl, body, sp, id, (this, v));
this.pop_repeating_id(body.node.id);
}
}
}
fn gather_loans_in_block(blk: &ast::blk,
this: @mut GatherLoanCtxt,
vt: visit::vt<@mut GatherLoanCtxt>) {
(this, vt): (@mut GatherLoanCtxt,
visit::vt<@mut GatherLoanCtxt>)) {
this.id_range.add(blk.node.id);
visit::visit_block(blk, this, vt);
visit::visit_block(blk, (this, vt));
}
fn gather_loans_in_local(local: @ast::local,
this: @mut GatherLoanCtxt,
vt: visit::vt<@mut GatherLoanCtxt>) {
(this, vt): (@mut GatherLoanCtxt,
visit::vt<@mut GatherLoanCtxt>)) {
if local.node.init.is_none() {
// Variable declarations without initializers are considered "moves":
let tcx = this.bccx.tcx;
@ -163,12 +163,12 @@ fn gather_loans_in_local(local: @ast::local,
}
}
visit::visit_local(local, this, vt);
visit::visit_local(local, (this, vt));
}
fn gather_loans_in_expr(ex: @ast::expr,
this: @mut GatherLoanCtxt,
vt: visit::vt<@mut GatherLoanCtxt>) {
(this, vt): (@mut GatherLoanCtxt,
visit::vt<@mut GatherLoanCtxt>)) {
let bccx = this.bccx;
let tcx = bccx.tcx;
@ -208,7 +208,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
// for the lifetime `scope_r` of the resulting ptr:
let scope_r = ty_region(tcx, ex.span, ty::expr_ty(tcx, ex));
this.guarantee_valid(ex.id, ex.span, base_cmt, mutbl, scope_r);
visit::visit_expr(ex, this, vt);
visit::visit_expr(ex, (this, vt));
}
ast::expr_assign(l, _) | ast::expr_assign_op(_, _, l, _) => {
@ -225,7 +225,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
// with moves etc, just ignore.
}
}
visit::visit_expr(ex, this, vt);
visit::visit_expr(ex, (this, vt));
}
ast::expr_match(ex_v, ref arms) => {
@ -235,7 +235,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
this.gather_pat(cmt, *pat, arm.body.node.id, ex.id);
}
}
visit::visit_expr(ex, this, vt);
visit::visit_expr(ex, (this, vt));
}
ast::expr_index(_, _, arg) |
@ -249,36 +249,36 @@ fn gather_loans_in_expr(ex: @ast::expr,
let scope_r = ty::re_scope(ex.id);
let arg_cmt = this.bccx.cat_expr(arg);
this.guarantee_valid(arg.id, arg.span, arg_cmt, m_imm, scope_r);
visit::visit_expr(ex, this, vt);
visit::visit_expr(ex, (this, vt));
}
// see explanation attached to the `root_ub` field:
ast::expr_while(cond, ref body) => {
// during the condition, can only root for the condition
this.push_repeating_id(cond.id);
(vt.visit_expr)(cond, this, vt);
(vt.visit_expr)(cond, (this, vt));
this.pop_repeating_id(cond.id);
// during body, can only root for the body
this.push_repeating_id(body.node.id);
(vt.visit_block)(body, this, vt);
(vt.visit_block)(body, (this, vt));
this.pop_repeating_id(body.node.id);
}
// see explanation attached to the `root_ub` field:
ast::expr_loop(ref body, _) => {
this.push_repeating_id(body.node.id);
visit::visit_expr(ex, this, vt);
visit::visit_expr(ex, (this, vt));
this.pop_repeating_id(body.node.id);
}
ast::expr_fn_block(*) => {
gather_moves::gather_captures(this.bccx, this.move_data, ex);
visit::visit_expr(ex, this, vt);
visit::visit_expr(ex, (this, vt));
}
_ => {
visit::visit_expr(ex, this, vt);
visit::visit_expr(ex, (this, vt));
}
}
}
@ -702,13 +702,13 @@ impl GatherLoanCtxt {
// Setting up info that preserve needs.
// This is just the most convenient place to do it.
fn add_stmt_to_map(stmt: @ast::stmt,
this: @mut GatherLoanCtxt,
vt: visit::vt<@mut GatherLoanCtxt>) {
(this, vt): (@mut GatherLoanCtxt,
visit::vt<@mut GatherLoanCtxt>)) {
match stmt.node {
ast::stmt_expr(_, id) | ast::stmt_semi(_, id) => {
this.bccx.stmt_map.insert(id);
}
_ => ()
}
visit::visit_stmt(stmt, this, vt);
visit::visit_stmt(stmt, (this, vt));
}

View File

@ -81,7 +81,7 @@ pub fn check_crate(
let v = visit::mk_vt(@visit::Visitor {visit_fn: borrowck_fn,
..*visit::default_visitor()});
visit::visit_crate(crate, bccx, v);
visit::visit_crate(crate, (bccx, v));
if tcx.sess.borrowck_stats() {
io::println("--- borrowck stats ---");
@ -111,8 +111,8 @@ fn borrowck_fn(fk: &visit::fn_kind,
body: &ast::blk,
sp: span,
id: ast::node_id,
this: @BorrowckCtxt,
v: visit::vt<@BorrowckCtxt>) {
(this, v): (@BorrowckCtxt,
visit::vt<@BorrowckCtxt>)) {
match fk {
&visit::fk_anon(*) |
&visit::fk_fn_block(*) => {
@ -149,7 +149,7 @@ fn borrowck_fn(fk: &visit::fn_kind,
}
}
visit::visit_fn(fk, decl, body, sp, id, this, v);
visit::visit_fn(fk, decl, body, sp, id, (this, v));
}
// ----------------------------------------------------------------------

View File

@ -27,13 +27,13 @@ pub fn check_crate(sess: Session,
def_map: resolve::DefMap,
method_map: typeck::method_map,
tcx: ty::ctxt) {
visit::visit_crate(crate, false, visit::mk_vt(@visit::Visitor {
visit_item: |a,b,c| check_item(sess, ast_map, def_map, a, b, c),
visit::visit_crate(crate, (false, visit::mk_vt(@visit::Visitor {
visit_item: |a,b| check_item(sess, ast_map, def_map, a, b),
visit_pat: check_pat,
visit_expr: |a,b,c|
check_expr(sess, def_map, method_map, tcx, a, b, c),
visit_expr: |a,b|
check_expr(sess, def_map, method_map, tcx, a, b),
.. *visit::default_visitor()
}));
})));
sess.abort_if_errors();
}
@ -41,25 +41,25 @@ pub fn check_item(sess: Session,
ast_map: ast_map::map,
def_map: resolve::DefMap,
it: @item,
_is_const: bool,
v: visit::vt<bool>) {
(_is_const, v): (bool,
visit::vt<bool>)) {
match it.node {
item_const(_, ex) => {
(v.visit_expr)(ex, true, v);
(v.visit_expr)(ex, (true, v));
check_item_recursion(sess, ast_map, def_map, it);
}
item_enum(ref enum_definition, _) => {
for (*enum_definition).variants.each |var| {
for var.node.disr_expr.iter().advance |ex| {
(v.visit_expr)(*ex, true, v);
(v.visit_expr)(*ex, (true, v));
}
}
}
_ => visit::visit_item(it, false, v)
_ => visit::visit_item(it, (false, v))
}
}
pub fn check_pat(p: @pat, _is_const: bool, v: visit::vt<bool>) {
pub fn check_pat(p: @pat, (_is_const, v): (bool, visit::vt<bool>)) {
fn is_str(e: @expr) -> bool {
match e.node {
expr_vstore(
@ -74,12 +74,12 @@ pub fn check_pat(p: @pat, _is_const: bool, v: visit::vt<bool>) {
}
match p.node {
// Let through plain ~-string literals here
pat_lit(a) => if !is_str(a) { (v.visit_expr)(a, true, v); },
pat_lit(a) => if !is_str(a) { (v.visit_expr)(a, (true, v)); },
pat_range(a, b) => {
if !is_str(a) { (v.visit_expr)(a, true, v); }
if !is_str(b) { (v.visit_expr)(b, true, v); }
if !is_str(a) { (v.visit_expr)(a, (true, v)); }
if !is_str(b) { (v.visit_expr)(b, (true, v)); }
}
_ => visit::visit_pat(p, false, v)
_ => visit::visit_pat(p, (false, v))
}
}
@ -88,8 +88,8 @@ pub fn check_expr(sess: Session,
method_map: typeck::method_map,
tcx: ty::ctxt,
e: @expr,
is_const: bool,
v: visit::vt<bool>) {
(is_const, v): (bool,
visit::vt<bool>)) {
if is_const {
match e.node {
expr_unary(_, deref, _) => { }
@ -155,7 +155,7 @@ pub fn check_expr(sess: Session,
}
}
expr_paren(e) => { check_expr(sess, def_map, method_map,
tcx, e, is_const, v); }
tcx, e, (is_const, v)); }
expr_vstore(_, expr_vstore_slice) |
expr_vec(_, m_imm) |
expr_addr_of(m_imm, _) |
@ -193,7 +193,7 @@ pub fn check_expr(sess: Session,
}
_ => ()
}
visit::visit_expr(e, is_const, v);
visit::visit_expr(e, (is_const, v));
}
// Make sure a const item doesn't recursively refer to itself
@ -223,18 +223,18 @@ pub fn check_item_recursion(sess: Session,
visit_expr: visit_expr,
.. *visit::default_visitor()
});
(visitor.visit_item)(it, env, visitor);
(visitor.visit_item)(it, (env, visitor));
fn visit_item(it: @item, env: env, v: visit::vt<env>) {
fn visit_item(it: @item, (env, v): (env, visit::vt<env>)) {
if env.idstack.contains(&(it.id)) {
env.sess.span_fatal(env.root_it.span, "recursive constant");
}
env.idstack.push(it.id);
visit::visit_item(it, env, v);
visit::visit_item(it, (env, v));
env.idstack.pop();
}
fn visit_expr(e: @expr, env: env, v: visit::vt<env>) {
fn visit_expr(e: @expr, (env, v): (env, visit::vt<env>)) {
match e.node {
expr_path(*) => {
match env.def_map.find(&e.id) {
@ -242,7 +242,7 @@ pub fn check_item_recursion(sess: Session,
if ast_util::is_local(def_id) {
match env.ast_map.get_copy(&def_id.node) {
ast_map::node_item(it, _) => {
(v.visit_item)(it, env, v);
(v.visit_item)(it, (env, v));
}
_ => fail!("const not bound to an item")
}
@ -253,6 +253,6 @@ pub fn check_item_recursion(sess: Session,
}
_ => ()
}
visit::visit_expr(e, env, v);
visit::visit_expr(e, (env, v));
}
}

View File

@ -21,36 +21,36 @@ pub struct Context {
pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
visit::visit_crate(crate,
Context { in_loop: false, can_ret: true },
(Context { in_loop: false, can_ret: true },
visit::mk_vt(@visit::Visitor {
visit_item: |i, _cx, v| {
visit::visit_item(i, Context {
visit_item: |i, (_cx, v)| {
visit::visit_item(i, (Context {
in_loop: false,
can_ret: true
}, v);
}, v));
},
visit_expr: |e: @expr, cx: Context, v: visit::vt<Context>| {
visit_expr: |e: @expr, (cx, v): (Context, visit::vt<Context>)| {
match e.node {
expr_while(e, ref b) => {
(v.visit_expr)(e, cx, v);
(v.visit_block)(b, Context { in_loop: true,.. cx }, v);
(v.visit_expr)(e, (cx, v));
(v.visit_block)(b, (Context { in_loop: true,.. cx }, v));
}
expr_loop(ref b, _) => {
(v.visit_block)(b, Context { in_loop: true,.. cx }, v);
(v.visit_block)(b, (Context { in_loop: true,.. cx }, v));
}
expr_fn_block(_, ref b) => {
(v.visit_block)(b, Context {
(v.visit_block)(b, (Context {
in_loop: false,
can_ret: false
}, v);
}, v));
}
expr_loop_body(@expr {node: expr_fn_block(_, ref b), _}) => {
let sigil = ty::ty_closure_sigil(ty::expr_ty(tcx, e));
let blk = (sigil == BorrowedSigil);
(v.visit_block)(b, Context {
(v.visit_block)(b, (Context {
in_loop: true,
can_ret: blk
}, v);
}, v));
}
expr_break(_) => {
if !cx.in_loop {
@ -66,11 +66,11 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
if !cx.can_ret {
tcx.sess.span_err(e.span, "`return` in block function");
}
visit::visit_expr_opt(oe, cx, v);
visit::visit_expr_opt(oe, (cx, v));
}
_ => visit::visit_expr(e, cx, v)
_ => visit::visit_expr(e, (cx, v))
}
},
.. *visit::default_visitor()
}));
})));
}

View File

@ -41,13 +41,13 @@ pub fn check_crate(tcx: ty::ctxt,
let cx = @MatchCheckCtxt {tcx: tcx,
method_map: method_map,
moves_map: moves_map};
visit::visit_crate(crate, (), visit::mk_vt(@visit::Visitor {
visit_expr: |a,b,c| check_expr(cx, a, b, c),
visit_local: |a,b,c| check_local(cx, a, b, c),
visit_fn: |kind, decl, body, sp, id, e, v|
check_fn(cx, kind, decl, body, sp, id, e, v),
visit::visit_crate(crate, ((), visit::mk_vt(@visit::Visitor {
visit_expr: |a,b| check_expr(cx, a, b),
visit_local: |a,b| check_local(cx, a, b),
visit_fn: |kind, decl, body, sp, id, (e, v)|
check_fn(cx, kind, decl, body, sp, id, (e, v)),
.. *visit::default_visitor::<()>()
}));
})));
tcx.sess.abort_if_errors();
}
@ -59,8 +59,8 @@ pub fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool {
!cx.moves_map.contains(&expr.id)
}
pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, s: (), v: visit::vt<()>) {
visit::visit_expr(ex, s, v);
pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, (s, v): ((), visit::vt<()>)) {
visit::visit_expr(ex, (s, v));
match ex.node {
expr_match(scrut, ref arms) => {
// First, check legality of move bindings.
@ -751,9 +751,9 @@ pub fn default(cx: @MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> {
pub fn check_local(cx: @MatchCheckCtxt,
loc: @local,
s: (),
v: visit::vt<()>) {
visit::visit_local(loc, s, v);
(s, v): ((),
visit::vt<()>)) {
visit::visit_local(loc, (s, v));
if is_refutable(cx, loc.node.pat) {
cx.tcx.sess.span_err(loc.node.pat.span,
"refutable pattern in local binding");
@ -773,9 +773,9 @@ pub fn check_fn(cx: @MatchCheckCtxt,
body: &blk,
sp: span,
id: node_id,
s: (),
v: visit::vt<()>) {
visit::visit_fn(kind, decl, body, sp, id, s, v);
(s, v): ((),
visit::vt<()>)) {
visit::visit_fn(kind, decl, body, sp, id, (s, v));
for decl.inputs.each |input| {
if is_refutable(cx, input.pat) {
cx.tcx.sess.span_err(input.pat.span,

View File

@ -224,7 +224,7 @@ pub fn process_crate(crate: @ast::crate,
visit_expr_post: |e| { classify(e, tcx); },
.. *visit::default_simple_visitor()
});
visit::visit_crate(crate, (), v);
visit::visit_crate(crate, ((), v));
tcx.sess.abort_if_errors();
}

View File

@ -72,7 +72,7 @@ pub fn check_crate(tcx: ty::ctxt,
};
let visitor = visit::mk_vt(@visit::Visitor {
visit_fn: |fn_kind, fn_decl, block, span, node_id, _, visitor| {
visit_fn: |fn_kind, fn_decl, block, span, node_id, (_, visitor)| {
let (is_item_fn, is_unsafe_fn) = match *fn_kind {
fk_item_fn(_, _, purity, _) => (true, purity == unsafe_fn),
fk_method(_, _, method) => (true, method.purity == unsafe_fn),
@ -91,25 +91,25 @@ pub fn check_crate(tcx: ty::ctxt,
block,
span,
node_id,
(),
visitor);
((),
visitor));
context.unsafe_context = old_unsafe_context
},
visit_block: |block, _, visitor| {
visit_block: |block, (_, visitor)| {
let old_unsafe_context = context.unsafe_context;
if block.node.rules == unsafe_blk &&
context.unsafe_context == SafeContext {
context.unsafe_context = UnsafeBlock(block.node.id)
}
visit::visit_block(block, (), visitor);
visit::visit_block(block, ((), visitor));
context.unsafe_context = old_unsafe_context
},
visit_expr: |expr, _, visitor| {
visit_expr: |expr, (_, visitor)| {
match expr.node {
expr_method_call(callee_id, _, _, _, _, _) => {
let base_type = ty::node_id_to_type(tcx, callee_id);
@ -146,12 +146,12 @@ pub fn check_crate(tcx: ty::ctxt,
_ => {}
}
visit::visit_expr(expr, (), visitor)
visit::visit_expr(expr, ((), visitor))
},
.. *visit::default_visitor()
});
visit::visit_crate(crate, (), visitor)
visit::visit_crate(crate, ((), visitor))
}

View File

@ -59,10 +59,10 @@ pub fn find_entry_point(session: Session, crate: @crate, ast_map: ast_map::map)
non_main_fns: ~[],
};
visit_crate(crate, ctxt, mk_vt(@Visitor {
visit_item: |item, ctxt, visitor| find_item(item, ctxt, visitor),
visit_crate(crate, (ctxt, mk_vt(@Visitor {
visit_item: |item, (ctxt, visitor)| find_item(item, ctxt, visitor),
.. *default_visitor()
}));
})));
configure_main(ctxt);
}
@ -114,7 +114,7 @@ fn find_item(item: @item, ctxt: @mut EntryContext, visitor: EntryVisitor) {
_ => ()
}
visit_item(item, ctxt, visitor);
visit_item(item, (ctxt, visitor));
}
fn configure_main(ctxt: @mut EntryContext) {

View File

@ -40,12 +40,12 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
let seen = @mut HashMap::new();
let refs = @mut ~[];
fn ignore_item(_i: @ast::item, _depth: int, _v: visit::vt<int>) { }
fn ignore_item(_i: @ast::item, (_depth, _v): (int, visit::vt<int>)) { }
let walk_expr: @fn(expr: @ast::expr, depth: int, v: visit::vt<int>) =
|expr, depth, v| {
let walk_expr: @fn(expr: @ast::expr, (int, visit::vt<int>)) =
|expr, (depth, v)| {
match expr.node {
ast::expr_fn_block(*) => visit::visit_expr(expr, depth + 1, v),
ast::expr_fn_block(*) => visit::visit_expr(expr, (depth + 1, v)),
ast::expr_path(*) | ast::expr_self => {
let mut i = 0;
match def_map.find(&expr.id) {
@ -72,14 +72,14 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
}
}
}
_ => visit::visit_expr(expr, depth, v)
_ => visit::visit_expr(expr, (depth, v))
}
};
let v = visit::mk_vt(@visit::Visitor {visit_item: ignore_item,
visit_expr: walk_expr,
.. *visit::default_visitor()});
(v.visit_block)(blk, 1, v);
(v.visit_block)(blk, (1, v));
return @/*bad*/copy *refs;
}
@ -105,7 +105,7 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) ->
visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_fn: walk_fn,
.. *visit::default_simple_visitor()});
visit::visit_crate(crate, (), visitor);
visit::visit_crate(crate, ((), visitor));
return freevars;
}

View File

@ -78,7 +78,7 @@ pub fn check_crate(tcx: ty::ctxt,
visit_block: check_block,
.. *visit::default_visitor()
});
visit::visit_crate(crate, ctx, visit);
visit::visit_crate(crate, (ctx, visit));
tcx.sess.abort_if_errors();
}
@ -114,11 +114,11 @@ fn check_struct_safe_for_destructor(cx: Context,
}
}
fn check_block(block: &blk, cx: Context, visitor: visit::vt<Context>) {
visit::visit_block(block, cx, visitor);
fn check_block(block: &blk, (cx, visitor): (Context, visit::vt<Context>)) {
visit::visit_block(block, (cx, visitor));
}
fn check_item(item: @item, cx: Context, visitor: visit::vt<Context>) {
fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
// If this is a destructor, check kinds.
if !attrs_contains_name(item.attrs, "unsafe_destructor") {
match item.node {
@ -157,7 +157,7 @@ fn check_item(item: @item, cx: Context, visitor: visit::vt<Context>) {
}
let cx = Context { current_item: item.id, ..cx };
visit::visit_item(item, cx, visitor);
visit::visit_item(item, (cx, visitor));
}
// Yields the appropriate function to check the kind of closed over
@ -224,8 +224,8 @@ fn check_fn(
body: &blk,
sp: span,
fn_id: node_id,
cx: Context,
v: visit::vt<Context>) {
(cx, v): (Context,
visit::vt<Context>)) {
// Check kinds on free variables:
do with_appropriate_checker(cx, fn_id) |chk| {
@ -234,10 +234,10 @@ fn check_fn(
}
}
visit::visit_fn(fk, decl, body, sp, fn_id, cx, v);
visit::visit_fn(fk, decl, body, sp, fn_id, (cx, v));
}
pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
debug!("kind::check_expr(%s)", expr_to_str(e, cx.tcx.sess.intr()));
// Handle any kind bounds on type parameters
@ -303,10 +303,10 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
}
_ => {}
}
visit::visit_expr(e, cx, v);
visit::visit_expr(e, (cx, v));
}
fn check_ty(aty: @Ty, cx: Context, v: visit::vt<Context>) {
fn check_ty(aty: @Ty, (cx, v): (Context, visit::vt<Context>)) {
match aty.node {
ty_path(_, id) => {
let r = cx.tcx.node_type_substs.find(&id);
@ -321,7 +321,7 @@ fn check_ty(aty: @Ty, cx: Context, v: visit::vt<Context>) {
}
_ => {}
}
visit::visit_ty(aty, cx, v);
visit::visit_ty(aty, (cx, v));
}
pub fn check_bounds(cx: Context,

View File

@ -389,7 +389,7 @@ impl LanguageItemCollector {
pub fn collect_local_language_items(&mut self) {
let this: *mut LanguageItemCollector = &mut *self;
visit_crate(self.crate, (), mk_simple_visitor(@SimpleVisitor {
visit_crate(self.crate, ((), mk_simple_visitor(@SimpleVisitor {
visit_item: |item| {
for item.attrs.each |attribute| {
unsafe {
@ -401,7 +401,7 @@ impl LanguageItemCollector {
}
},
.. *default_simple_visitor()
}));
})));
}
pub fn collect_external_language_items(&mut self) {

View File

@ -474,12 +474,12 @@ impl Context {
match n {
Item(it) => {
for self.visitors.each |&(orig, stopping)| {
(orig.visit_item)(it, self, stopping);
(orig.visit_item)(it, (self, stopping));
}
}
Crate(c) => {
for self.visitors.each |&(_, stopping)| {
visit::visit_crate(c, self, stopping);
visit::visit_crate(c, (self, stopping));
}
}
// Can't use visit::visit_method_helper because the
@ -489,7 +489,7 @@ impl Context {
let fk = visit::fk_method(copy m.ident, &m.generics, m);
for self.visitors.each |&(orig, stopping)| {
(orig.visit_fn)(&fk, &m.decl, &m.body, m.span, m.id,
self, stopping);
(self, stopping));
}
}
}
@ -535,23 +535,23 @@ pub fn each_lint(sess: session::Session,
// lint visitor.
fn item_stopping_visitor<E: Copy>(outer: visit::vt<E>) -> visit::vt<E> {
visit::mk_vt(@visit::Visitor {
visit_item: |_i, _e, _v| { },
visit_fn: |fk, fd, b, s, id, e, v| {
visit_item: |_i, (_e, _v)| { },
visit_fn: |fk, fd, b, s, id, (e, v)| {
match *fk {
visit::fk_method(*) => {}
_ => (outer.visit_fn)(fk, fd, b, s, id, e, v)
_ => (outer.visit_fn)(fk, fd, b, s, id, (e, v))
}
},
.. **(ty_stopping_visitor(outer))})
}
fn ty_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> {
visit::mk_vt(@visit::Visitor {visit_ty: |_t, _e, _v| { },.. **v})
visit::mk_vt(@visit::Visitor {visit_ty: |_t, (_e, _v)| { },.. **v})
}
fn lint_while_true() -> visit::vt<@mut Context> {
visit::mk_vt(@visit::Visitor {
visit_expr: |e, cx: @mut Context, vt| {
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
match e.node {
ast::expr_while(cond, _) => {
match cond.node {
@ -567,7 +567,7 @@ fn lint_while_true() -> visit::vt<@mut Context> {
}
_ => ()
}
visit::visit_expr(e, cx, vt);
visit::visit_expr(e, (cx, vt));
},
.. *visit::default_visitor()
})
@ -673,7 +673,7 @@ fn lint_type_limits() -> visit::vt<@mut Context> {
}
visit::mk_vt(@visit::Visitor {
visit_expr: |e, cx: @mut Context, vt| {
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
match e.node {
ast::expr_binary(_, ref binop, @ref l, @ref r) => {
if is_comparison(*binop)
@ -684,7 +684,7 @@ fn lint_type_limits() -> visit::vt<@mut Context> {
}
_ => ()
}
visit::visit_expr(e, cx, vt);
visit::visit_expr(e, (cx, vt));
},
.. *visit::default_visitor()
@ -809,10 +809,10 @@ fn check_item_heap(cx: &Context, it: @ast::item) {
fn lint_heap() -> visit::vt<@mut Context> {
visit::mk_vt(@visit::Visitor {
visit_expr: |e, cx: @mut Context, vt| {
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
let ty = ty::expr_ty(cx.tcx, e);
check_type(cx, e.span, ty);
visit::visit_expr(e, cx, vt);
visit::visit_expr(e, (cx, vt));
},
.. *visit::default_visitor()
})
@ -820,7 +820,7 @@ fn lint_heap() -> visit::vt<@mut Context> {
fn lint_path_statement() -> visit::vt<@mut Context> {
visit::mk_vt(@visit::Visitor {
visit_stmt: |s, cx: @mut Context, vt| {
visit_stmt: |s, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
match s.node {
ast::stmt_semi(
@ast::expr { node: ast::expr_path(_), _ },
@ -831,7 +831,7 @@ fn lint_path_statement() -> visit::vt<@mut Context> {
}
_ => ()
}
visit::visit_stmt(s, cx, vt);
visit::visit_stmt(s, (cx, vt));
},
.. *visit::default_visitor()
})
@ -871,7 +871,7 @@ fn check_item_non_camel_case_types(cx: &Context, it: @ast::item) {
fn lint_unused_unsafe() -> visit::vt<@mut Context> {
visit::mk_vt(@visit::Visitor {
visit_expr: |e, cx: @mut Context, vt| {
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
match e.node {
ast::expr_block(ref blk) if blk.node.rules == ast::unsafe_blk => {
if !cx.tcx.used_unsafe.contains(&blk.node.id) {
@ -881,7 +881,7 @@ fn lint_unused_unsafe() -> visit::vt<@mut Context> {
}
_ => ()
}
visit::visit_expr(e, cx, vt);
visit::visit_expr(e, (cx, vt));
},
.. *visit::default_visitor()
})
@ -914,30 +914,30 @@ fn lint_unused_mut() -> visit::vt<@mut Context> {
}
visit::mk_vt(@visit::Visitor {
visit_local: |l, cx: @mut Context, vt| {
visit_local: |l, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
if l.node.is_mutbl {
check_pat(cx, l.node.pat);
}
visit::visit_local(l, cx, vt);
visit::visit_local(l, (cx, vt));
},
visit_fn: |a, fd, b, c, d, cx, vt| {
visit_fn: |a, fd, b, c, d, (cx, vt)| {
visit_fn_decl(cx, fd);
visit::visit_fn(a, fd, b, c, d, cx, vt);
visit::visit_fn(a, fd, b, c, d, (cx, vt));
},
visit_ty_method: |tm, cx, vt| {
visit_ty_method: |tm, (cx, vt)| {
visit_fn_decl(cx, &tm.decl);
visit::visit_ty_method(tm, cx, vt);
visit::visit_ty_method(tm, (cx, vt));
},
visit_struct_method: |sm, cx, vt| {
visit_struct_method: |sm, (cx, vt)| {
visit_fn_decl(cx, &sm.decl);
visit::visit_struct_method(sm, cx, vt);
visit::visit_struct_method(sm, (cx, vt));
},
visit_trait_method: |tm, cx, vt| {
visit_trait_method: |tm, (cx, vt)| {
match *tm {
ast::required(ref tm) => visit_fn_decl(cx, &tm.decl),
ast::provided(m) => visit_fn_decl(cx, &m.decl)
}
visit::visit_trait_method(tm, cx, vt);
visit::visit_trait_method(tm, (cx, vt));
},
.. *visit::default_visitor()
})
@ -987,9 +987,9 @@ fn lint_unnecessary_allocations() -> visit::vt<@mut Context> {
}
visit::mk_vt(@visit::Visitor {
visit_expr: |e, cx: @mut Context, vt| {
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
check(cx, e);
visit::visit_expr(e, cx, vt);
visit::visit_expr(e, (cx, vt));
},
.. *visit::default_visitor()
})
@ -1011,23 +1011,23 @@ fn lint_missing_doc() -> visit::vt<@mut Context> {
}
visit::mk_vt(@visit::Visitor {
visit_struct_method: |m, cx, vt| {
visit_struct_method: |m, (cx, vt)| {
if m.vis == ast::public {
check_attrs(cx, m.attrs, m.span,
"missing documentation for a method");
}
visit::visit_struct_method(m, cx, vt);
visit::visit_struct_method(m, (cx, vt));
},
visit_ty_method: |m, cx, vt| {
visit_ty_method: |m, (cx, vt)| {
// All ty_method objects are linted about because they're part of a
// trait (no visibility)
check_attrs(cx, m.attrs, m.span,
"missing documentation for a method");
visit::visit_ty_method(m, cx, vt);
visit::visit_ty_method(m, (cx, vt));
},
visit_fn: |fk, d, b, sp, id, cx, vt| {
visit_fn: |fk, d, b, sp, id, (cx, vt)| {
// Only warn about explicitly public methods. Soon implicit
// public-ness will hopefully be going away.
match *fk {
@ -1042,10 +1042,10 @@ fn lint_missing_doc() -> visit::vt<@mut Context> {
_ => {}
}
visit::visit_fn(fk, d, b, sp, id, cx, vt);
visit::visit_fn(fk, d, b, sp, id, (cx, vt));
},
visit_item: |it, cx, vt| {
visit_item: |it, (cx, vt)| {
match it.node {
// Go ahead and match the fields here instead of using
// visit_struct_field while we have access to the enclosing
@ -1077,7 +1077,7 @@ fn lint_missing_doc() -> visit::vt<@mut Context> {
_ => {}
};
visit::visit_item(it, cx, vt);
visit::visit_item(it, (cx, vt));
},
.. *visit::default_visitor()
@ -1120,8 +1120,8 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
do cx.with_lint_attrs(crate.node.attrs) {
cx.process(Crate(crate));
visit::visit_crate(crate, cx, visit::mk_vt(@visit::Visitor {
visit_item: |it, cx: @mut Context, vt| {
visit::visit_crate(crate, (cx, visit::mk_vt(@visit::Visitor {
visit_item: |it, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
do cx.with_lint_attrs(it.attrs) {
match it.node {
ast::item_impl(_, Some(*), _, _) => {
@ -1135,25 +1135,25 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
check_item_heap(cx, it);
cx.process(Item(it));
visit::visit_item(it, cx, vt);
visit::visit_item(it, (cx, vt));
cx.in_trait_impl = false;
}
},
visit_fn: |fk, decl, body, span, id, cx, vt| {
visit_fn: |fk, decl, body, span, id, (cx, vt)| {
match *fk {
visit::fk_method(_, _, m) => {
do cx.with_lint_attrs(m.attrs) {
cx.process(Method(m));
visit::visit_fn(fk, decl, body, span, id, cx, vt);
visit::visit_fn(fk, decl, body, span, id, (cx, vt));
}
}
_ => {
visit::visit_fn(fk, decl, body, span, id, cx, vt);
visit::visit_fn(fk, decl, body, span, id, (cx, vt));
}
}
},
.. *visit::default_visitor()
}));
})));
}
// If we missed any lints added to the session, then there's a bug somewhere

View File

@ -163,7 +163,7 @@ pub fn check_crate(tcx: ty::ctxt,
let initial_maps = @mut IrMaps(tcx,
method_map,
capture_map);
visit::visit_crate(crate, initial_maps, visitor);
visit::visit_crate(crate, (initial_maps, visitor));
tcx.sess.abort_if_errors();
}
@ -342,8 +342,8 @@ fn visit_fn(fk: &visit::fn_kind,
body: &blk,
sp: span,
id: node_id,
this: @mut IrMaps,
v: vt<@mut IrMaps>) {
(this, v): (@mut IrMaps,
vt<@mut IrMaps>)) {
debug!("visit_fn: id=%d", id);
let _i = ::util::common::indenter();
@ -381,7 +381,7 @@ fn visit_fn(fk: &visit::fn_kind,
// gather up the various local variables, significant expressions,
// and so forth:
visit::visit_fn(fk, decl, body, sp, id, fn_maps, v);
visit::visit_fn(fk, decl, body, sp, id, (fn_maps, v));
// Special nodes and variables:
// - exit_ln represents the end of the fn, either by return or fail
@ -405,12 +405,12 @@ fn visit_fn(fk: &visit::fn_kind,
visit_arm: check_arm,
.. *visit::default_visitor()
});
(check_vt.visit_block)(body, lsets, check_vt);
(check_vt.visit_block)(body, (lsets, check_vt));
lsets.check_ret(id, sp, fk, entry_ln);
lsets.warn_about_unused_args(decl, entry_ln);
}
fn visit_local(local: @local, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
fn visit_local(local: @local, (this, vt): (@mut IrMaps, vt<@mut IrMaps>)) {
let def_map = this.tcx.def_map;
do pat_util::pat_bindings(def_map, local.node.pat) |_bm, p_id, sp, path| {
debug!("adding local variable %d", p_id);
@ -427,10 +427,10 @@ fn visit_local(local: @local, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
kind: kind
}));
}
visit::visit_local(local, this, vt);
visit::visit_local(local, (this, vt));
}
fn visit_arm(arm: &arm, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
fn visit_arm(arm: &arm, (this, vt): (@mut IrMaps, vt<@mut IrMaps>)) {
let def_map = this.tcx.def_map;
for arm.pats.each |pat| {
do pat_util::pat_bindings(def_map, *pat) |bm, p_id, sp, path| {
@ -446,10 +446,10 @@ fn visit_arm(arm: &arm, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
}));
}
}
visit::visit_arm(arm, this, vt);
visit::visit_arm(arm, (this, vt));
}
fn visit_expr(expr: @expr, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
fn visit_expr(expr: @expr, (this, vt): (@mut IrMaps, vt<@mut IrMaps>)) {
match expr.node {
// live nodes required for uses or definitions of variables:
expr_path(_) | expr_self => {
@ -458,7 +458,7 @@ fn visit_expr(expr: @expr, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
if moves::moved_variable_node_id_from_def(def).is_some() {
this.add_live_node_for_node(expr.id, ExprNode(expr.span));
}
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
expr_fn_block(*) => {
// Interesting control flow (for loops can contain labeled
@ -491,17 +491,17 @@ fn visit_expr(expr: @expr, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
}
this.set_captures(expr.id, call_caps);
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
// live nodes required for interesting control flow:
expr_if(*) | expr_match(*) | expr_while(*) | expr_loop(*) => {
this.add_live_node_for_node(expr.id, ExprNode(expr.span));
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
expr_binary(_, op, _, _) if ast_util::lazy_binop(op) => {
this.add_live_node_for_node(expr.id, ExprNode(expr.span));
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
// otherwise, live nodes are not required:
@ -513,7 +513,7 @@ fn visit_expr(expr: @expr, this: @mut IrMaps, vt: vt<@mut IrMaps>) {
expr_assign(*) | expr_assign_op(*) | expr_mac(*) |
expr_struct(*) | expr_repeat(*) | expr_paren(*) |
expr_inline_asm(*) => {
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
}
}
@ -1406,7 +1406,7 @@ impl Liveness {
// _______________________________________________________________________
// Checking for error conditions
fn check_local(local: @local, this: @Liveness, vt: vt<@Liveness>) {
fn check_local(local: @local, (this, vt): (@Liveness, vt<@Liveness>)) {
match local.node.init {
Some(_) => {
this.warn_about_unused_or_dead_vars_in_pat(local.node.pat);
@ -1432,34 +1432,34 @@ fn check_local(local: @local, this: @Liveness, vt: vt<@Liveness>) {
}
}
visit::visit_local(local, this, vt);
visit::visit_local(local, (this, vt));
}
fn check_arm(arm: &arm, this: @Liveness, vt: vt<@Liveness>) {
fn check_arm(arm: &arm, (this, vt): (@Liveness, vt<@Liveness>)) {
do this.arm_pats_bindings(arm.pats) |ln, var, sp, id| {
this.warn_about_unused(sp, id, ln, var);
}
visit::visit_arm(arm, this, vt);
visit::visit_arm(arm, (this, vt));
}
fn check_expr(expr: @expr, this: @Liveness, vt: vt<@Liveness>) {
fn check_expr(expr: @expr, (this, vt): (@Liveness, vt<@Liveness>)) {
match expr.node {
expr_assign(l, r) => {
this.check_lvalue(l, vt);
(vt.visit_expr)(r, this, vt);
(vt.visit_expr)(r, (this, vt));
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
expr_assign_op(_, _, l, _) => {
this.check_lvalue(l, vt);
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
expr_inline_asm(ref ia) => {
for ia.inputs.each |&(_, in)| {
(vt.visit_expr)(in, this, vt);
(vt.visit_expr)(in, (this, vt));
}
// Output operands must be lvalues
@ -1470,10 +1470,10 @@ fn check_expr(expr: @expr, this: @Liveness, vt: vt<@Liveness>) {
}
_ => {}
}
(vt.visit_expr)(out, this, vt);
(vt.visit_expr)(out, (this, vt));
}
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
// no correctness conditions related to liveness
@ -1485,14 +1485,14 @@ fn check_expr(expr: @expr, this: @Liveness, vt: vt<@Liveness>) {
expr_again(*) | expr_lit(_) | expr_block(*) |
expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) |
expr_paren(*) | expr_fn_block(*) | expr_path(*) | expr_self(*) => {
visit::visit_expr(expr, this, vt);
visit::visit_expr(expr, (this, vt));
}
}
}
fn check_fn(_fk: &visit::fn_kind, _decl: &fn_decl,
_body: &blk, _sp: span, _id: node_id,
_self: @Liveness, _v: vt<@Liveness>) {
(_self, _v): (@Liveness, vt<@Liveness>)) {
// do not check contents of nested fns
}
@ -1556,7 +1556,7 @@ impl Liveness {
_ => {
// For other kinds of lvalues, no checks are required,
// and any embedded expressions are actually rvalues
visit::visit_expr(expr, self, vt);
visit::visit_expr(expr, (self, vt));
}
}
}

View File

@ -206,7 +206,7 @@ pub fn compute_moves(tcx: ty::ctxt,
moved_variables_set: @mut HashSet::new()
}
};
visit::visit_crate(crate, visit_cx, visitor);
visit::visit_crate(crate, (visit_cx, visitor));
return visit_cx.move_maps;
}
@ -225,8 +225,8 @@ pub fn moved_variable_node_id_from_def(def: def) -> Option<node_id> {
// Expressions
fn compute_modes_for_expr(expr: @expr,
cx: VisitContext,
v: vt<VisitContext>)
(cx, v): (VisitContext,
vt<VisitContext>))
{
cx.consume_expr(expr, v);
}
@ -265,7 +265,7 @@ impl VisitContext {
debug!("consume_block(blk.id=%?)", blk.node.id);
for blk.node.stmts.each |stmt| {
(visitor.visit_stmt)(*stmt, *self, visitor);
(visitor.visit_stmt)(*stmt, (*self, visitor));
}
for blk.node.expr.iter().advance |tail_expr| {

View File

@ -38,8 +38,8 @@ use syntax::codemap::span;
use syntax::parse::token;
use syntax::visit;
pub fn check_crate(tcx: ty::ctxt,
method_map: &method_map,
pub fn check_crate<'mm>(tcx: ty::ctxt,
method_map: &'mm method_map,
crate: @ast::crate) {
let privileged_items = @mut ~[];
@ -357,24 +357,24 @@ pub fn check_crate(tcx: ty::ctxt,
};
let visitor = visit::mk_vt(@visit::Visitor {
visit_mod: |the_module, span, node_id, method_map, visitor| {
visit_mod: |the_module, span, node_id, (method_map, visitor)| {
let n_added = add_privileged_items(the_module.items);
visit::visit_mod(the_module, span, node_id, method_map, visitor);
visit::visit_mod(the_module, span, node_id, (method_map, visitor));
for n_added.times {
ignore(privileged_items.pop());
}
},
visit_item: |item, method_map, visitor| {
visit_item: |item, (method_map, visitor)| {
// Do not check privacy inside items with the resolve_unexported
// attribute. This is used for the test runner.
if !attr::contains_name(attr::attr_metas(/*bad*/copy item.attrs),
"!resolve_unexported") {
visit::visit_item(item, method_map, visitor);
visit::visit_item(item, (method_map, visitor));
}
},
visit_block: |block, method_map, visitor| {
visit_block: |block, (method_map, visitor)| {
// Gather up all the privileged items.
let mut n_added = 0;
for block.node.stmts.each |stmt| {
@ -391,13 +391,13 @@ pub fn check_crate(tcx: ty::ctxt,
}
}
visit::visit_block(block, method_map, visitor);
visit::visit_block(block, (method_map, visitor));
for n_added.times {
ignore(privileged_items.pop());
}
},
visit_expr: |expr, method_map: &method_map, visitor| {
visit_expr: |expr, (method_map, visitor): (&'mm method_map, visit::vt<&'mm method_map>)| {
match expr.node {
expr_field(base, ident, _) => {
// Method calls are now a special syntactic form,
@ -506,9 +506,9 @@ pub fn check_crate(tcx: ty::ctxt,
_ => {}
}
visit::visit_expr(expr, method_map, visitor);
visit::visit_expr(expr, (method_map, visitor));
},
visit_pat: |pattern, method_map, visitor| {
visit_pat: |pattern, (method_map, visitor)| {
match pattern.node {
pat_struct(_, ref fields, _) => {
match ty::get(ty::pat_ty(tcx, pattern)).sty {
@ -558,9 +558,9 @@ pub fn check_crate(tcx: ty::ctxt,
_ => {}
}
visit::visit_pat(pattern, method_map, visitor);
visit::visit_pat(pattern, (method_map, visitor));
},
.. *visit::default_visitor()
});
visit::visit_crate(crate, method_map, visitor);
visit::visit_crate(crate, (method_map, visitor));
}

View File

@ -335,7 +335,7 @@ pub fn parent_to_expr(cx: Context, child_id: ast::node_id, sp: span) {
}
}
pub fn resolve_block(blk: &ast::blk, cx: Context, visitor: visit::vt<Context>) {
pub fn resolve_block(blk: &ast::blk, (cx, visitor): (Context, visit::vt<Context>)) {
// Record the parent of this block.
parent_to_expr(cx, blk.node.id, blk.span);
@ -343,35 +343,35 @@ pub fn resolve_block(blk: &ast::blk, cx: Context, visitor: visit::vt<Context>) {
let new_cx = Context {var_parent: Some(blk.node.id),
parent: Some(blk.node.id),
..cx};
visit::visit_block(blk, new_cx, visitor);
visit::visit_block(blk, (new_cx, visitor));
}
pub fn resolve_arm(arm: &ast::arm, cx: Context, visitor: visit::vt<Context>) {
visit::visit_arm(arm, cx, visitor);
pub fn resolve_arm(arm: &ast::arm, (cx, visitor): (Context, visit::vt<Context>)) {
visit::visit_arm(arm, (cx, visitor));
}
pub fn resolve_pat(pat: @ast::pat, cx: Context, visitor: visit::vt<Context>) {
pub fn resolve_pat(pat: @ast::pat, (cx, visitor): (Context, visit::vt<Context>)) {
assert_eq!(cx.var_parent, cx.parent);
parent_to_expr(cx, pat.id, pat.span);
visit::visit_pat(pat, cx, visitor);
visit::visit_pat(pat, (cx, visitor));
}
pub fn resolve_stmt(stmt: @ast::stmt, cx: Context, visitor: visit::vt<Context>) {
pub fn resolve_stmt(stmt: @ast::stmt, (cx, visitor): (Context, visit::vt<Context>)) {
match stmt.node {
ast::stmt_decl(*) => {
visit::visit_stmt(stmt, cx, visitor);
visit::visit_stmt(stmt, (cx, visitor));
}
ast::stmt_expr(_, stmt_id) |
ast::stmt_semi(_, stmt_id) => {
parent_to_expr(cx, stmt_id, stmt.span);
let expr_cx = Context {parent: Some(stmt_id), ..cx};
visit::visit_stmt(stmt, expr_cx, visitor);
visit::visit_stmt(stmt, (expr_cx, visitor));
}
ast::stmt_mac(*) => cx.sess.bug("unexpanded macro")
}
}
pub fn resolve_expr(expr: @ast::expr, cx: Context, visitor: visit::vt<Context>) {
pub fn resolve_expr(expr: @ast::expr, (cx, visitor): (Context, visit::vt<Context>)) {
parent_to_expr(cx, expr.id, expr.span);
let mut new_cx = cx;
@ -407,21 +407,21 @@ pub fn resolve_expr(expr: @ast::expr, cx: Context, visitor: visit::vt<Context>)
};
visit::visit_expr(expr, new_cx, visitor);
visit::visit_expr(expr, (new_cx, visitor));
}
pub fn resolve_local(local: @ast::local,
cx: Context,
visitor: visit::vt<Context>) {
(cx, visitor) : (Context,
visit::vt<Context>)) {
assert_eq!(cx.var_parent, cx.parent);
parent_to_expr(cx, local.node.id, local.span);
visit::visit_local(local, cx, visitor);
visit::visit_local(local, (cx, visitor));
}
pub fn resolve_item(item: @ast::item, cx: Context, visitor: visit::vt<Context>) {
pub fn resolve_item(item: @ast::item, (cx, visitor): (Context, visit::vt<Context>)) {
// Items create a new outer block scope as far as we're concerned.
let new_cx = Context {var_parent: None, parent: None, ..cx};
visit::visit_item(item, new_cx, visitor);
visit::visit_item(item, (new_cx, visitor));
}
pub fn resolve_fn(fk: &visit::fn_kind,
@ -429,8 +429,8 @@ pub fn resolve_fn(fk: &visit::fn_kind,
body: &ast::blk,
sp: span,
id: ast::node_id,
cx: Context,
visitor: visit::vt<Context>) {
(cx, visitor): (Context,
visit::vt<Context>)) {
debug!("region::resolve_fn(id=%?, \
span=%?, \
body.node.id=%?, \
@ -450,7 +450,7 @@ pub fn resolve_fn(fk: &visit::fn_kind,
}
_ => {}
}
visit::visit_fn_decl(decl, decl_cx, visitor);
visit::visit_fn_decl(decl, (decl_cx, visitor));
// The body of the fn itself is either a root scope (top-level fn)
// or it continues with the inherited scope (closures).
@ -464,7 +464,7 @@ pub fn resolve_fn(fk: &visit::fn_kind,
cx
}
};
(visitor.visit_block)(body, body_cx, visitor);
(visitor.visit_block)(body, (body_cx, visitor));
}
pub fn resolve_crate(sess: Session,
@ -492,7 +492,7 @@ pub fn resolve_crate(sess: Session,
visit_local: resolve_local,
.. *visit::default_visitor()
});
visit::visit_crate(crate, cx, visitor);
visit::visit_crate(crate, (cx, visitor));
return region_maps;
}
@ -717,10 +717,10 @@ impl DetermineRpCtxt {
}
pub fn determine_rp_in_item(item: @ast::item,
cx: @mut DetermineRpCtxt,
visitor: visit::vt<@mut DetermineRpCtxt>) {
(cx, visitor): (@mut DetermineRpCtxt,
visit::vt<@mut DetermineRpCtxt>)) {
do cx.with(item.id, true) {
visit::visit_item(item, cx, visitor);
visit::visit_item(item, (cx, visitor));
}
}
@ -729,32 +729,32 @@ pub fn determine_rp_in_fn(fk: &visit::fn_kind,
body: &ast::blk,
_: span,
_: ast::node_id,
cx: @mut DetermineRpCtxt,
visitor: visit::vt<@mut DetermineRpCtxt>) {
(cx, visitor): (@mut DetermineRpCtxt,
visit::vt<@mut DetermineRpCtxt>)) {
do cx.with(cx.item_id, false) {
do cx.with_ambient_variance(rv_contravariant) {
for decl.inputs.each |a| {
(visitor.visit_ty)(a.ty, cx, visitor);
(visitor.visit_ty)(a.ty, (cx, visitor));
}
}
(visitor.visit_ty)(decl.output, cx, visitor);
(visitor.visit_ty)(decl.output, (cx, visitor));
let generics = visit::generics_of_fn(fk);
(visitor.visit_generics)(&generics, cx, visitor);
(visitor.visit_block)(body, cx, visitor);
(visitor.visit_generics)(&generics, (cx, visitor));
(visitor.visit_block)(body, (cx, visitor));
}
}
pub fn determine_rp_in_ty_method(ty_m: &ast::ty_method,
cx: @mut DetermineRpCtxt,
visitor: visit::vt<@mut DetermineRpCtxt>) {
(cx, visitor): (@mut DetermineRpCtxt,
visit::vt<@mut DetermineRpCtxt>)) {
do cx.with(cx.item_id, false) {
visit::visit_ty_method(ty_m, cx, visitor);
visit::visit_ty_method(ty_m, (cx, visitor));
}
}
pub fn determine_rp_in_ty(ty: @ast::Ty,
cx: @mut DetermineRpCtxt,
visitor: visit::vt<@mut DetermineRpCtxt>) {
(cx, visitor): (@mut DetermineRpCtxt,
visit::vt<@mut DetermineRpCtxt>)) {
// we are only interested in types that will require an item to
// be region-parameterized. if cx.item_id is zero, then this type
// is not a member of a type defn nor is it a constitutent of an
@ -838,14 +838,14 @@ pub fn determine_rp_in_ty(ty: @ast::Ty,
match ty.node {
ast::ty_box(mt) | ast::ty_uniq(mt) | ast::ty_vec(mt) |
ast::ty_rptr(_, mt) | ast::ty_ptr(mt) => {
visit_mt(mt, cx, visitor);
visit_mt(mt, (cx, visitor));
}
ast::ty_path(path, _) => {
// type parameters are---for now, anyway---always invariant
do cx.with_ambient_variance(rv_invariant) {
for path.types.each |tp| {
(visitor.visit_ty)(*tp, cx, visitor);
(visitor.visit_ty)(*tp, (cx, visitor));
}
}
}
@ -858,37 +858,37 @@ pub fn determine_rp_in_ty(ty: @ast::Ty,
// parameters are contravariant
do cx.with_ambient_variance(rv_contravariant) {
for decl.inputs.each |a| {
(visitor.visit_ty)(a.ty, cx, visitor);
(visitor.visit_ty)(a.ty, (cx, visitor));
}
}
(visitor.visit_ty)(decl.output, cx, visitor);
(visitor.visit_ty)(decl.output, (cx, visitor));
}
}
_ => {
visit::visit_ty(ty, cx, visitor);
visit::visit_ty(ty, (cx, visitor));
}
}
fn visit_mt(mt: ast::mt,
cx: @mut DetermineRpCtxt,
visitor: visit::vt<@mut DetermineRpCtxt>) {
(cx, visitor): (@mut DetermineRpCtxt,
visit::vt<@mut DetermineRpCtxt>)) {
// mutability is invariant
if mt.mutbl == ast::m_mutbl {
do cx.with_ambient_variance(rv_invariant) {
(visitor.visit_ty)(mt.ty, cx, visitor);
(visitor.visit_ty)(mt.ty, (cx, visitor));
}
} else {
(visitor.visit_ty)(mt.ty, cx, visitor);
(visitor.visit_ty)(mt.ty, (cx, visitor));
}
}
}
pub fn determine_rp_in_struct_field(
cm: @ast::struct_field,
cx: @mut DetermineRpCtxt,
visitor: visit::vt<@mut DetermineRpCtxt>) {
visit::visit_struct_field(cm, cx, visitor);
(cx, visitor): (@mut DetermineRpCtxt,
visit::vt<@mut DetermineRpCtxt>)) {
visit::visit_struct_field(cm, (cx, visitor));
}
pub fn determine_rp_in_crate(sess: Session,
@ -917,7 +917,7 @@ pub fn determine_rp_in_crate(sess: Session,
visit_struct_field: determine_rp_in_struct_field,
.. *visit::default_visitor()
});
visit::visit_crate(crate, cx, visitor);
visit::visit_crate(crate, (cx, visitor));
// Propagate indirect dependencies
//

View File

@ -905,27 +905,27 @@ impl Resolver {
pub fn build_reduced_graph(@mut self) {
let initial_parent =
ModuleReducedGraphParent(self.graph_root.get_module());
visit_crate(self.crate, initial_parent, mk_vt(@Visitor {
visit_item: |item, context, visitor|
self.build_reduced_graph_for_item(item, context, visitor),
visit_crate(self.crate, (initial_parent, mk_vt(@Visitor {
visit_item: |item, (context, visitor)|
self.build_reduced_graph_for_item(item, (context, visitor)),
visit_foreign_item: |foreign_item, context, visitor|
visit_foreign_item: |foreign_item, (context, visitor)|
self.build_reduced_graph_for_foreign_item(foreign_item,
context,
visitor),
(context,
visitor)),
visit_view_item: |view_item, context, visitor|
visit_view_item: |view_item, (context, visitor)|
self.build_reduced_graph_for_view_item(view_item,
context,
visitor),
(context,
visitor)),
visit_block: |block, context, visitor|
visit_block: |block, (context, visitor)|
self.build_reduced_graph_for_block(block,
context,
visitor),
(context,
visitor)),
.. *default_visitor()
}));
})));
}
/// Returns the current module tracked by the reduced graph parent.
@ -1094,8 +1094,8 @@ impl Resolver {
/// Constructs the reduced graph for one item.
pub fn build_reduced_graph_for_item(@mut self,
item: @item,
parent: ReducedGraphParent,
visitor: vt<ReducedGraphParent>) {
(parent, visitor): (ReducedGraphParent,
vt<ReducedGraphParent>)) {
let ident = item.ident;
let sp = item.span;
let privacy = visibility_to_privacy(item.vis);
@ -1116,7 +1116,7 @@ impl Resolver {
let new_parent =
ModuleReducedGraphParent(name_bindings.get_module());
visit_mod(module_, sp, item.id, new_parent, visitor);
visit_mod(module_, sp, item.id, (new_parent, visitor));
}
item_foreign_mod(ref fm) => {
@ -1143,7 +1143,7 @@ impl Resolver {
anonymous => parent
};
visit_item(item, new_parent, visitor);
visit_item(item, (new_parent, visitor));
}
// These items live in the value namespace.
@ -1160,7 +1160,7 @@ impl Resolver {
let def = def_fn(local_def(item.id), purity);
name_bindings.define_value(privacy, def, sp);
visit_item(item, new_parent, visitor);
visit_item(item, (new_parent, visitor));
}
// These items live in the type namespace.
@ -1180,13 +1180,13 @@ impl Resolver {
(privacy, def_ty(local_def(item.id)), sp);
for (*enum_definition).variants.each |variant| {
self.build_reduced_graph_for_variant(variant,
self.build_reduced_graph_for_variant(
variant,
local_def(item.id),
// inherited => privacy of the enum item
variant_visibility_to_privacy(variant.node.vis,
privacy == Public),
new_parent,
visitor);
(new_parent, visitor));
}
}
@ -1213,7 +1213,7 @@ impl Resolver {
// Record the def ID of this struct.
self.structs.insert(local_def(item.id));
visit_item(item, new_parent, visitor);
visit_item(item, (new_parent, visitor));
}
item_impl(_, trait_ref_opt, ty, ref methods) => {
@ -1307,7 +1307,7 @@ impl Resolver {
_ => {}
}
visit_item(item, parent, visitor);
visit_item(item, (parent, visitor));
}
item_trait(_, _, ref methods) => {
@ -1397,7 +1397,7 @@ impl Resolver {
}
name_bindings.define_type(privacy, def_trait(def_id), sp);
visit_item(item, new_parent, visitor);
visit_item(item, (new_parent, visitor));
}
item_mac(*) => {
@ -1412,8 +1412,9 @@ impl Resolver {
variant: &variant,
item_id: def_id,
parent_privacy: Privacy,
parent: ReducedGraphParent,
_visitor: vt<ReducedGraphParent>) {
(parent, _visitor):
(ReducedGraphParent,
vt<ReducedGraphParent>)) {
let ident = variant.node.name;
let (child, _) = self.add_child(ident, parent, ForbidDuplicateValues,
variant.span);
@ -1446,8 +1447,9 @@ impl Resolver {
/// of imports and use directives.
pub fn build_reduced_graph_for_view_item(@mut self,
view_item: @view_item,
parent: ReducedGraphParent,
_: vt<ReducedGraphParent>) {
(parent, _):
(ReducedGraphParent,
vt<ReducedGraphParent>)) {
let privacy = visibility_to_privacy(view_item.vis);
match view_item.node {
view_item_use(ref view_paths) => {
@ -1542,9 +1544,9 @@ impl Resolver {
/// Constructs the reduced graph for one foreign item.
pub fn build_reduced_graph_for_foreign_item(@mut self,
foreign_item: @foreign_item,
parent: ReducedGraphParent,
visitor:
vt<ReducedGraphParent>) {
(parent, visitor):
(ReducedGraphParent,
vt<ReducedGraphParent>)) {
let name = foreign_item.ident;
let (name_bindings, new_parent) =
self.add_child(name, parent, ForbidDuplicateValues,
@ -1559,22 +1561,23 @@ impl Resolver {
HasTypeParameters(
generics, foreign_item.id, 0, NormalRibKind))
{
visit_foreign_item(foreign_item, new_parent, visitor);
visit_foreign_item(foreign_item, (new_parent, visitor));
}
}
foreign_item_const(*) => {
let def = def_const(local_def(foreign_item.id));
name_bindings.define_value(Public, def, foreign_item.span);
visit_foreign_item(foreign_item, new_parent, visitor);
visit_foreign_item(foreign_item, (new_parent, visitor));
}
}
}
pub fn build_reduced_graph_for_block(@mut self,
block: &blk,
parent: ReducedGraphParent,
visitor: vt<ReducedGraphParent>) {
(parent, visitor):
(ReducedGraphParent,
vt<ReducedGraphParent>)) {
let new_parent;
if self.block_needs_anonymous_module(block) {
let block_id = block.node.id;
@ -1594,7 +1597,7 @@ impl Resolver {
new_parent = parent;
}
visit_block(block, new_parent, visitor);
visit_block(block, (new_parent, visitor));
}
pub fn handle_external_def(@mut self,
@ -3481,21 +3484,21 @@ impl Resolver {
pub fn resolve_crate(@mut self) {
debug!("(resolving crate) starting");
visit_crate(self.crate, (), mk_vt(@Visitor {
visit_item: |item, _context, visitor|
visit_crate(self.crate, ((), mk_vt(@Visitor {
visit_item: |item, (_context, visitor)|
self.resolve_item(item, visitor),
visit_arm: |arm, _context, visitor|
visit_arm: |arm, (_context, visitor)|
self.resolve_arm(arm, visitor),
visit_block: |block, _context, visitor|
visit_block: |block, (_context, visitor)|
self.resolve_block(block, visitor),
visit_expr: |expr, _context, visitor|
visit_expr: |expr, (_context, visitor)|
self.resolve_expr(expr, visitor),
visit_local: |local, _context, visitor|
visit_local: |local, (_context, visitor)|
self.resolve_local(local, visitor),
visit_ty: |ty, _context, visitor|
visit_ty: |ty, (_context, visitor)|
self.resolve_type(ty, visitor),
.. *default_visitor()
}));
})));
}
pub fn resolve_item(@mut self, item: @item, visitor: ResolveVisitor) {
@ -3531,7 +3534,7 @@ impl Resolver {
do self.with_type_parameter_rib(
HasTypeParameters(
generics, item.id, 0, NormalRibKind)) {
visit_item(item, (), visitor);
visit_item(item, ((), visitor));
}
}
@ -3541,7 +3544,7 @@ impl Resolver {
NormalRibKind))
|| {
visit_item(item, (), visitor);
visit_item(item, ((), visitor));
}
}
@ -3657,12 +3660,12 @@ impl Resolver {
HasTypeParameters(
generics, foreign_item.id, 0,
NormalRibKind),
|| visit_foreign_item(*foreign_item, (),
visitor));
|| visit_foreign_item(*foreign_item,
((), visitor)));
}
foreign_item_const(_) => {
visit_foreign_item(*foreign_item, (),
visitor);
visit_foreign_item(*foreign_item,
((), visitor));
}
}
}
@ -3684,7 +3687,7 @@ impl Resolver {
item_const(*) => {
self.with_constant_rib(|| {
visit_item(item, (), visitor);
visit_item(item, ((), visitor));
});
}
@ -3993,7 +3996,7 @@ impl Resolver {
visitor: ResolveVisitor) {
// Write the implementations in scope into the module metadata.
debug!("(resolving module) resolving module ID %d", id);
visit_mod(module_, span, id, (), visitor);
visit_mod(module_, span, id, ((), visitor));
}
pub fn resolve_local(@mut self, local: @local, visitor: ResolveVisitor) {
@ -4080,7 +4083,7 @@ impl Resolver {
// pat_idents are variants
self.check_consistent_bindings(arm);
visit_expr_opt(arm.guard, (), visitor);
visit_expr_opt(arm.guard, ((), visitor));
self.resolve_block(&arm.body, visitor);
self.value_ribs.pop();
@ -4102,7 +4105,7 @@ impl Resolver {
}
// Descend into the block.
visit_block(block, (), visitor);
visit_block(block, ((), visitor));
// Move back up.
self.current_module = orig_module;
@ -4181,12 +4184,12 @@ impl Resolver {
for c.bounds.each |bound| {
self.resolve_type_parameter_bound(bound, visitor);
}
visit_ty(ty, (), visitor);
visit_ty(ty, ((), visitor));
}
_ => {
// Just resolve embedded types.
visit_ty(ty, (), visitor);
visit_ty(ty, ((), visitor));
}
}
}
@ -4949,7 +4952,7 @@ impl Resolver {
}
}
visit_expr(expr, (), visitor);
visit_expr(expr, ((), visitor));
}
expr_fn_block(ref fn_decl, ref block) => {
@ -4981,7 +4984,7 @@ impl Resolver {
}
}
visit_expr(expr, (), visitor);
visit_expr(expr, ((), visitor));
}
expr_loop(_, Some(label)) => {
@ -4993,7 +4996,7 @@ impl Resolver {
rib.bindings.insert(label, def_like);
}
visit_expr(expr, (), visitor);
visit_expr(expr, ((), visitor));
}
}
@ -5029,7 +5032,7 @@ impl Resolver {
}
_ => {
visit_expr(expr, (), visitor);
visit_expr(expr, ((), visitor));
}
}
}
@ -5266,7 +5269,7 @@ impl Resolver {
visit_view_item: |vi| self.check_for_item_unused_imports(vi),
.. *default_simple_visitor()
});
visit_crate(self.crate, (), vt);
visit_crate(self.crate, ((), vt));
}
pub fn check_for_item_unused_imports(&mut self, vi: @view_item) {

View File

@ -2629,11 +2629,11 @@ pub fn trans_constant(ccx: @CrateContext, it: @ast::item) {
pub fn trans_constants(ccx: @CrateContext, crate: &ast::crate) {
visit::visit_crate(
crate, (),
crate, ((),
visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_item: |a| trans_constant(ccx, a),
..*visit::default_simple_visitor()
}));
})));
}
pub fn vp2i(cx: block, v: ValueRef) -> ValueRef {

View File

@ -434,18 +434,18 @@ pub fn trans_lang_call_with_type_params(bcx: block,
pub fn body_contains_ret(body: &ast::blk) -> bool {
let cx = @mut false;
visit::visit_block(body, cx, visit::mk_vt(@visit::Visitor {
visit_item: |_i, _cx, _v| { },
visit_expr: |e: @ast::expr, cx: @mut bool, v| {
visit::visit_block(body, (cx, visit::mk_vt(@visit::Visitor {
visit_item: |_i, (_cx, _v)| { },
visit_expr: |e: @ast::expr, (cx, v): (@mut bool, visit::vt<@mut bool>)| {
if !*cx {
match e.node {
ast::expr_ret(_) => *cx = true,
_ => visit::visit_expr(e, cx, v),
_ => visit::visit_expr(e, (cx, v)),
}
}
},
..*visit::default_visitor()
}));
})));
*cx
}

View File

@ -143,9 +143,9 @@ fn traverse_public_item(cx: @mut ctx, item: @item) {
}
}
item_ty(t, _) => {
traverse_ty(t, cx,
visit::mk_vt(@visit::Visitor {visit_ty: traverse_ty,
..*visit::default_visitor()}))
traverse_ty(t, (cx,
visit::mk_vt(@visit::Visitor {visit_ty: traverse_ty,
..*visit::default_visitor()})))
}
item_const(*) |
item_enum(*) | item_trait(*) => (),
@ -153,7 +153,7 @@ fn traverse_public_item(cx: @mut ctx, item: @item) {
}
}
fn traverse_ty<'a>(ty: @Ty, cx: @mut ctx<'a>, v: visit::vt<@mut ctx<'a>>) {
fn traverse_ty<'a>(ty: @Ty, (cx, v): (@mut ctx<'a>, visit::vt<@mut ctx<'a>>)) {
{
let cx = &mut *cx; // FIXME(#6269) reborrow @mut to &mut
if cx.rmap.contains(&ty.id) { return; }
@ -170,16 +170,16 @@ fn traverse_ty<'a>(ty: @Ty, cx: @mut ctx<'a>, v: visit::vt<@mut ctx<'a>>) {
None => { /* do nothing -- but should we fail here? */ }
}
for p.types.each |t| {
(v.visit_ty)(*t, cx, v);
(v.visit_ty)(*t, (cx, v));
}
}
_ => visit::visit_ty(ty, cx, v)
_ => visit::visit_ty(ty, (cx, v))
}
}
fn traverse_inline_body(cx: @mut ctx, body: &blk) {
fn traverse_expr<'a>(e: @expr, cx: @mut ctx<'a>,
v: visit::vt<@mut ctx<'a>>) {
fn traverse_expr<'a>(e: @expr, (cx, v): (@mut ctx<'a>,
visit::vt<@mut ctx<'a>>)) {
match e.node {
expr_path(_) => {
match cx.tcx.def_map.find(&e.id) {
@ -210,19 +210,19 @@ fn traverse_inline_body(cx: @mut ctx, body: &blk) {
}
_ => ()
}
visit::visit_expr(e, cx, v);
visit::visit_expr(e, (cx, v));
}
// Don't ignore nested items: for example if a generic fn contains a
// generic impl (as in deque::create), we need to monomorphize the
// impl as well
fn traverse_item(i: @item, cx: @mut ctx, _v: visit::vt<@mut ctx>) {
fn traverse_item(i: @item, (cx, _v): (@mut ctx, visit::vt<@mut ctx>)) {
traverse_public_item(cx, i);
}
visit::visit_block(body, cx, visit::mk_vt(@visit::Visitor {
visit::visit_block(body, (cx, visit::mk_vt(@visit::Visitor {
visit_expr: traverse_expr,
visit_item: traverse_item,
..*visit::default_visitor()
}));
})));
}
fn traverse_all_resources_and_impls(cx: @mut ctx, crate_mod: &_mod) {
@ -230,11 +230,11 @@ fn traverse_all_resources_and_impls(cx: @mut ctx, crate_mod: &_mod) {
crate_mod,
codemap::dummy_sp(),
0,
cx,
(cx,
visit::mk_vt(@visit::Visitor {
visit_expr: |_e, _cx, _v| { },
visit_item: |i, cx, v| {
visit::visit_item(i, cx, v);
visit_expr: |_e, (_cx, _v)| { },
visit_item: |i, (cx, v)| {
visit::visit_item(i, (cx, v));
match i.node {
item_impl(*) => {
traverse_public_item(cx, i);
@ -243,5 +243,5 @@ fn traverse_all_resources_and_impls(cx: @mut ctx, crate_mod: &_mod) {
}
},
..*visit::default_visitor()
}));
})));
}

View File

@ -382,26 +382,26 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
pub fn handle_body(cx: Context, body: &blk) {
let v = visit::mk_vt(@visit::Visitor {
visit_expr: |e, cx, v| {
visit::visit_expr(e, cx, v);
visit_expr: |e, (cx, v)| {
visit::visit_expr(e, (cx, v));
mark_for_expr(cx, e);
},
visit_local: |l, cx, v| {
visit::visit_local(l, cx, v);
visit_local: |l, (cx, v)| {
visit::visit_local(l, (cx, v));
node_type_needs(cx, use_repr, l.node.id);
},
visit_pat: |p, cx, v| {
visit::visit_pat(p, cx, v);
visit_pat: |p, (cx, v)| {
visit::visit_pat(p, (cx, v));
node_type_needs(cx, use_repr, p.id);
},
visit_block: |b, cx, v| {
visit::visit_block(b, cx, v);
visit_block: |b, (cx, v)| {
visit::visit_block(b, (cx, v));
for b.node.expr.iter().advance |e| {
node_type_needs(cx, use_repr, e.id);
}
},
visit_item: |_i, _cx, _v| { },
visit_item: |_i, (_cx, _v)| { },
..*visit::default_visitor()
});
(v.visit_block)(body, cx, v);
(v.visit_block)(body, (cx, v));
}

View File

@ -290,7 +290,7 @@ pub fn check_item_types(ccx: @mut CrateCtxt, crate: @ast::crate) {
visit_item: |a| check_item(ccx, a),
.. *visit::default_simple_visitor()
});
visit::visit_crate(crate, (), visit);
visit::visit_crate(crate, ((), visit));
}
pub fn check_bare_fn(ccx: @mut CrateCtxt,
@ -469,8 +469,8 @@ pub fn check_fn(ccx: @mut CrateCtxt,
}
// Add explicitly-declared locals.
let visit_local: @fn(@ast::local, e: (), visit::vt<()>) =
|local, e, v| {
let visit_local: @fn(@ast::local, ((), visit::vt<()>)) =
|local, (e, v)| {
let o_ty = match local.node.ty.node {
ast::ty_infer => None,
_ => Some(fcx.to_ty(local.node.ty))
@ -480,11 +480,11 @@ pub fn check_fn(ccx: @mut CrateCtxt,
fcx.pat_to_str(local.node.pat),
fcx.infcx().ty_to_str(
fcx.inh.locals.get_copy(&local.node.id)));
visit::visit_local(local, e, v);
visit::visit_local(local, (e, v));
};
// Add pattern bindings.
let visit_pat: @fn(@ast::pat, e: (), visit::vt<()>) = |p, e, v| {
let visit_pat: @fn(@ast::pat, ((), visit::vt<()>)) = |p, (e, v)| {
match p.node {
ast::pat_ident(_, path, _)
if pat_util::pat_is_binding(fcx.ccx.tcx.def_map, p) => {
@ -496,24 +496,24 @@ pub fn check_fn(ccx: @mut CrateCtxt,
}
_ => {}
}
visit::visit_pat(p, e, v);
visit::visit_pat(p, (e, v));
};
let visit_block: @fn(&ast::blk, e: (), visit::vt<()>) = |b, e, v| {
let visit_block: @fn(&ast::blk, ((), visit::vt<()>)) = |b, (e, v)| {
// non-obvious: the `blk` variable maps to region lb, so
// we have to keep this up-to-date. This
// is... unfortunate. It'd be nice to not need this.
do fcx.with_region_lb(b.node.id) {
visit::visit_block(b, e, v);
visit::visit_block(b, (e, v));
}
};
// Don't descend into fns and items
fn visit_fn(_fk: &visit::fn_kind, _decl: &ast::fn_decl,
_body: &ast::blk, _sp: span,
_id: ast::node_id, _t: (), _v: visit::vt<()>) {
_id: ast::node_id, (_t,_v): ((), visit::vt<()>)) {
}
fn visit_item(_i: @ast::item, _e: (), _v: visit::vt<()>) { }
fn visit_item(_i: @ast::item, (_e,_v): ((), visit::vt<()>)) { }
let visit = visit::mk_vt(
@visit::Visitor {visit_local: visit_local,
@ -523,7 +523,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
visit_block: visit_block,
..*visit::default_visitor()});
(visit.visit_block)(body, (), visit);
(visit.visit_block)(body, ((), visit));
}
}

View File

@ -140,7 +140,7 @@ pub fn regionck_expr(fcx: @mut FnCtxt, e: @ast::expr) {
if fcx.err_count_since_creation() == 0 {
// regionck assumes typeck succeeded
let v = regionck_visitor();
(v.visit_expr)(e, rcx, v);
(v.visit_expr)(e, (rcx, v));
}
fcx.infcx().resolve_regions();
}
@ -150,7 +150,7 @@ pub fn regionck_fn(fcx: @mut FnCtxt, blk: &ast::blk) {
if fcx.err_count_since_creation() == 0 {
// regionck assumes typeck succeeded
let v = regionck_visitor();
(v.visit_block)(blk, rcx, v);
(v.visit_block)(blk, (rcx, v));
}
fcx.infcx().resolve_regions();
}
@ -174,28 +174,28 @@ fn regionck_visitor() -> rvt {
.. *visit::default_visitor()})
}
fn visit_item(_item: @ast::item, _rcx: @mut Rcx, _v: rvt) {
fn visit_item(_item: @ast::item, (_rcx, _v): (@mut Rcx, rvt)) {
// Ignore items
}
fn visit_block(b: &ast::blk, rcx: @mut Rcx, v: rvt) {
fn visit_block(b: &ast::blk, (rcx, v): (@mut Rcx, rvt)) {
rcx.fcx.tcx().region_maps.record_cleanup_scope(b.node.id);
visit::visit_block(b, rcx, v);
visit::visit_block(b, (rcx, v));
}
fn visit_arm(arm: &ast::arm, rcx: @mut Rcx, v: rvt) {
fn visit_arm(arm: &ast::arm, (rcx, v): (@mut Rcx, rvt)) {
// see above
for arm.pats.each |&p| {
constrain_bindings_in_pat(p, rcx);
}
visit::visit_arm(arm, rcx, v);
visit::visit_arm(arm, (rcx, v));
}
fn visit_local(l: @ast::local, rcx: @mut Rcx, v: rvt) {
fn visit_local(l: @ast::local, (rcx, v): (@mut Rcx, rvt)) {
// see above
constrain_bindings_in_pat(l.node.pat, rcx);
visit::visit_local(l, rcx, v);
visit::visit_local(l, (rcx, v));
}
fn constrain_bindings_in_pat(pat: @ast::pat, rcx: @mut Rcx) {
@ -230,7 +230,7 @@ fn constrain_bindings_in_pat(pat: @ast::pat, rcx: @mut Rcx) {
}
}
fn visit_expr(expr: @ast::expr, rcx: @mut Rcx, v: rvt) {
fn visit_expr(expr: @ast::expr, (rcx, v): (@mut Rcx, rvt)) {
debug!("regionck::visit_expr(e=%s)", rcx.fcx.expr_to_str(expr));
let has_method_map = rcx.fcx.inh.method_map.contains_key(&expr.id);
@ -404,7 +404,7 @@ fn visit_expr(expr: @ast::expr, rcx: @mut Rcx, v: rvt) {
_ => ()
}
visit::visit_expr(expr, rcx, v);
visit::visit_expr(expr, (rcx, v));
}
fn constrain_callee(rcx: @mut Rcx,

View File

@ -651,18 +651,18 @@ pub fn early_resolve_expr(ex: @ast::expr,
}
fn resolve_expr(ex: @ast::expr,
fcx: @mut FnCtxt,
v: visit::vt<@mut FnCtxt>) {
(fcx, v): (@mut FnCtxt,
visit::vt<@mut FnCtxt>)) {
early_resolve_expr(ex, fcx, false);
visit::visit_expr(ex, fcx, v);
visit::visit_expr(ex, (fcx, v));
}
// Detect points where a trait-bounded type parameter is
// instantiated, resolve the impls for the parameters.
pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::blk) {
visit::visit_block(bl, fcx, visit::mk_vt(@visit::Visitor {
visit::visit_block(bl, (fcx, visit::mk_vt(@visit::Visitor {
visit_expr: resolve_expr,
visit_item: |_,_,_| {},
visit_item: |_,_| {},
.. *visit::default_visitor()
}));
})));
}

View File

@ -210,13 +210,13 @@ struct WbCtxt {
type wb_vt = visit::vt<@mut WbCtxt>;
fn visit_stmt(s: @ast::stmt, wbcx: @mut WbCtxt, v: wb_vt) {
fn visit_stmt(s: @ast::stmt, (wbcx, v): (@mut WbCtxt, wb_vt)) {
if !wbcx.success { return; }
resolve_type_vars_for_node(wbcx, s.span, ty::stmt_node_id(s));
visit::visit_stmt(s, wbcx, v);
visit::visit_stmt(s, (wbcx, v));
}
fn visit_expr(e: @ast::expr, wbcx: @mut WbCtxt, v: wb_vt) {
fn visit_expr(e: @ast::expr, (wbcx, v): (@mut WbCtxt, wb_vt)) {
if !wbcx.success {
return;
}
@ -261,19 +261,19 @@ fn visit_expr(e: @ast::expr, wbcx: @mut WbCtxt, v: wb_vt) {
_ => ()
}
visit::visit_expr(e, wbcx, v);
visit::visit_expr(e, (wbcx, v));
}
fn visit_block(b: &ast::blk, wbcx: @mut WbCtxt, v: wb_vt) {
fn visit_block(b: &ast::blk, (wbcx, v): (@mut WbCtxt, wb_vt)) {
if !wbcx.success {
return;
}
resolve_type_vars_for_node(wbcx, b.span, b.node.id);
visit::visit_block(b, wbcx, v);
visit::visit_block(b, (wbcx, v));
}
fn visit_pat(p: @ast::pat, wbcx: @mut WbCtxt, v: wb_vt) {
fn visit_pat(p: @ast::pat, (wbcx, v): (@mut WbCtxt, wb_vt)) {
if !wbcx.success {
return;
}
@ -284,10 +284,10 @@ fn visit_pat(p: @ast::pat, wbcx: @mut WbCtxt, v: wb_vt) {
wbcx.fcx.infcx().ty_to_str(
ty::node_id_to_type(wbcx.fcx.ccx.tcx,
p.id)));
visit::visit_pat(p, wbcx, v);
visit::visit_pat(p, (wbcx, v));
}
fn visit_local(l: @ast::local, wbcx: @mut WbCtxt, v: wb_vt) {
fn visit_local(l: @ast::local, (wbcx, v): (@mut WbCtxt, wb_vt)) {
if !wbcx.success { return; }
let var_ty = wbcx.fcx.local_ty(l.span, l.node.id);
match resolve_type(wbcx.fcx.infcx(), var_ty, resolve_all | force_all) {
@ -307,9 +307,9 @@ fn visit_local(l: @ast::local, wbcx: @mut WbCtxt, v: wb_vt) {
wbcx.success = false;
}
}
visit::visit_local(l, wbcx, v);
visit::visit_local(l, (wbcx, v));
}
fn visit_item(_item: @ast::item, _wbcx: @mut WbCtxt, _v: wb_vt) {
fn visit_item(_item: @ast::item, (_wbcx, _v): (@mut WbCtxt, wb_vt)) {
// Ignore items
}
@ -326,7 +326,7 @@ fn mk_visitor() -> visit::vt<@mut WbCtxt> {
pub fn resolve_type_vars_in_expr(fcx: @mut FnCtxt, e: @ast::expr) -> bool {
let wbcx = @mut WbCtxt { fcx: fcx, success: true };
let visit = mk_visitor();
(visit.visit_expr)(e, wbcx, visit);
(visit.visit_expr)(e, (wbcx, visit));
return wbcx.success;
}
@ -336,7 +336,7 @@ pub fn resolve_type_vars_in_fn(fcx: @mut FnCtxt,
self_info: Option<SelfInfo>) -> bool {
let wbcx = @mut WbCtxt { fcx: fcx, success: true };
let visit = mk_visitor();
(visit.visit_block)(blk, wbcx, visit);
(visit.visit_block)(blk, (wbcx, visit));
for self_info.iter().advance |self_info| {
resolve_type_vars_for_node(wbcx,
self_info.span,

View File

@ -204,7 +204,7 @@ impl CoherenceChecker {
// Check implementations and traits. This populates the tables
// containing the inherent methods and extension methods. It also
// builds up the trait inheritance table.
visit_crate(crate, (), mk_simple_visitor(@SimpleVisitor {
visit_crate(crate, ((), mk_simple_visitor(@SimpleVisitor {
visit_item: |item| {
// debug!("(checking coherence) item '%s'",
// self.crate_context.tcx.sess.str_of(item.ident));
@ -220,7 +220,7 @@ impl CoherenceChecker {
};
},
.. *default_simple_visitor()
}));
})));
// Check that there are no overlapping trait instances
self.check_implementation_coherence();
@ -659,12 +659,12 @@ impl CoherenceChecker {
// Privileged scope checking
pub fn check_privileged_scopes(self, crate: @crate) {
visit_crate(crate, (), mk_vt(@Visitor {
visit_item: |item, _context, visitor| {
visit_crate(crate, ((), mk_vt(@Visitor {
visit_item: |item, (_context, visitor)| {
match item.node {
item_mod(ref module_) => {
// Then visit the module items.
visit_mod(module_, item.span, item.id, (), visitor);
visit_mod(module_, item.span, item.id, ((), visitor));
}
item_impl(_, None, ast_ty, _) => {
if !self.ast_type_is_defined_in_local_crate(ast_ty) {
@ -697,15 +697,15 @@ impl CoherenceChecker {
}
}
visit_item(item, (), visitor);
visit_item(item, ((), visitor));
}
_ => {
visit_item(item, (), visitor);
visit_item(item, ((), visitor));
}
}
},
.. *default_visitor()
}));
})));
}
pub fn trait_ref_to_trait_def_id(&self, trait_ref: @trait_ref) -> def_id {

View File

@ -113,12 +113,12 @@ pub fn collect_item_types(ccx: @mut CrateCtxt, crate: @ast::crate) {
}
visit::visit_crate(
crate, (),
crate, ((),
visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_item: |a| convert(ccx, a),
visit_foreign_item: |a|convert_foreign(ccx, a),
.. *visit::default_simple_visitor()
}));
})));
}
impl CrateCtxt {

View File

@ -66,21 +66,21 @@ pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
pub fn loop_query(b: &ast::blk, p: @fn(&ast::expr_) -> bool) -> bool {
let rs = @mut false;
let visit_expr: @fn(@ast::expr,
flag: @mut bool,
v: visit::vt<@mut bool>) = |e, flag, v| {
(@mut bool,
visit::vt<@mut bool>)) = |e, (flag, v)| {
*flag |= p(&e.node);
match e.node {
// Skip inner loops, since a break in the inner loop isn't a
// break inside the outer loop
ast::expr_loop(*) | ast::expr_while(*)
| ast::expr_loop_body(*) => {}
_ => visit::visit_expr(e, flag, v)
_ => visit::visit_expr(e, (flag, v))
}
};
let v = visit::mk_vt(@visit::Visitor {
visit_expr: visit_expr,
.. *visit::default_visitor()});
visit::visit_block(b, rs, v);
visit::visit_block(b, (rs, v));
return *rs;
}
@ -89,15 +89,15 @@ pub fn loop_query(b: &ast::blk, p: @fn(&ast::expr_) -> bool) -> bool {
pub fn block_query(b: &ast::blk, p: @fn(@ast::expr) -> bool) -> bool {
let rs = @mut false;
let visit_expr: @fn(@ast::expr,
flag: @mut bool,
v: visit::vt<@mut bool>) = |e, flag, v| {
(@mut bool,
visit::vt<@mut bool>)) = |e, (flag, v)| {
*flag |= p(e);
visit::visit_expr(e, flag, v)
visit::visit_expr(e, (flag, v))
};
let v = visit::mk_vt(@visit::Visitor{
visit_expr: visit_expr,
.. *visit::default_visitor()});
visit::visit_block(b, rs, v);
visit::visit_block(b, (rs, v));
return *rs;
}

View File

@ -133,7 +133,7 @@ pub fn map_crate(diag: @span_handler, c: @crate) -> map {
path: ~[],
diag: diag,
};
visit::visit_crate(c, cx, mk_ast_map_visitor());
visit::visit_crate(c, (cx, mk_ast_map_visitor()));
cx.map
}
@ -183,21 +183,21 @@ pub fn map_fn(
body: &blk,
sp: codemap::span,
id: node_id,
cx: @mut Ctx,
v: visit::vt<@mut Ctx>
(cx,v): (@mut Ctx,
visit::vt<@mut Ctx>)
) {
for decl.inputs.each |a| {
cx.map.insert(a.id, node_arg);
}
visit::visit_fn(fk, decl, body, sp, id, cx, v);
visit::visit_fn(fk, decl, body, sp, id, (cx, v));
}
pub fn map_block(b: &blk, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
pub fn map_block(b: &blk, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
cx.map.insert(b.node.id, node_block(/* FIXME (#2543) */ copy *b));
visit::visit_block(b, cx, v);
visit::visit_block(b, (cx, v));
}
pub fn map_pat(pat: @pat, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
pub fn map_pat(pat: @pat, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
match pat.node {
pat_ident(_, path, _) => {
// Note: this is at least *potentially* a pattern...
@ -206,7 +206,7 @@ pub fn map_pat(pat: @pat, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
_ => ()
}
visit::visit_pat(pat, cx, v);
visit::visit_pat(pat, (cx, v));
}
pub fn map_method(impl_did: def_id, impl_path: @path,
@ -215,7 +215,7 @@ pub fn map_method(impl_did: def_id, impl_path: @path,
cx.map.insert(m.self_id, node_local(special_idents::self_));
}
pub fn map_item(i: @item, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
pub fn map_item(i: @item, (cx, v): (@mut Ctx, visit::vt<@mut Ctx>)) {
let item_path = @/* FIXME (#2543) */ copy cx.path;
cx.map.insert(i.id, node_item(i, item_path));
match i.node {
@ -262,8 +262,8 @@ pub fn map_item(i: @item, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
struct_def,
node_item(i, item_path),
i.ident,
cx,
v
(cx,
v)
);
}
item_trait(_, ref traits, ref methods) => {
@ -288,7 +288,7 @@ pub fn map_item(i: @item, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
}
_ => cx.path.push(path_name(i.ident))
}
visit::visit_item(i, cx, v);
visit::visit_item(i, (cx, v));
cx.path.pop();
}
@ -296,8 +296,8 @@ pub fn map_struct_def(
struct_def: @ast::struct_def,
parent_node: ast_node,
ident: ast::ident,
cx: @mut Ctx,
_v: visit::vt<@mut Ctx>
(cx, _v): (@mut Ctx,
visit::vt<@mut Ctx>)
) {
let p = extend(cx, ident);
// If this is a tuple-like struct, register the constructor.
@ -315,7 +315,7 @@ pub fn map_struct_def(
}
}
pub fn map_expr(ex: @expr, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
pub fn map_expr(ex: @expr, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
cx.map.insert(ex.id, node_expr(ex));
// Expressions which are or might be calls:
{
@ -324,12 +324,12 @@ pub fn map_expr(ex: @expr, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
cx.map.insert(*callee_id, node_callee_scope(ex));
}
}
visit::visit_expr(ex, cx, v);
visit::visit_expr(ex, (cx, v));
}
pub fn map_stmt(stmt: @stmt, cx: @mut Ctx, v: visit::vt<@mut Ctx>) {
pub fn map_stmt(stmt: @stmt, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
cx.map.insert(stmt_id(stmt), node_stmt(stmt));
visit::visit_stmt(stmt, cx, v);
visit::visit_stmt(stmt, (cx, v));
}
pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {

View File

@ -323,9 +323,9 @@ impl inlined_item_utils for inlined_item {
fn accept<E: Copy>(&self, e: E, v: visit::vt<E>) {
match *self {
ii_item(i) => (v.visit_item)(i, e, v),
ii_foreign(i) => (v.visit_foreign_item)(i, e, v),
ii_method(_, m) => visit::visit_method_helper(m, e, v),
ii_item(i) => (v.visit_item)(i, (e, v)),
ii_foreign(i) => (v.visit_foreign_item)(i, (e, v)),
ii_method(_, m) => visit::visit_method_helper(m, (e, v)),
}
}
}
@ -403,12 +403,12 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> {
}
};
visit::mk_vt(@visit::Visitor {
visit_mod: |m, sp, id, t, vt| {
visit_mod: |m, sp, id, (t, vt)| {
vfn(id, t);
visit::visit_mod(m, sp, id, t, vt);
visit::visit_mod(m, sp, id, (t, vt));
},
visit_view_item: |vi, t, vt| {
visit_view_item: |vi, (t, vt)| {
match vi.node {
view_item_extern_mod(_, _, id) => vfn(id, t),
view_item_use(ref vps) => {
@ -426,42 +426,42 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> {
}
}
}
visit::visit_view_item(vi, t, vt);
visit::visit_view_item(vi, (t, vt));
},
visit_foreign_item: |ni, t, vt| {
visit_foreign_item: |ni, (t, vt)| {
vfn(ni.id, t);
visit::visit_foreign_item(ni, t, vt);
visit::visit_foreign_item(ni, (t, vt));
},
visit_item: |i, t, vt| {
visit_item: |i, (t, vt)| {
vfn(i.id, t);
match i.node {
item_enum(ref enum_definition, _) =>
for (*enum_definition).variants.each |v| { vfn(v.node.id, t); },
_ => ()
}
visit::visit_item(i, t, vt);
visit::visit_item(i, (t, vt));
},
visit_local: |l, t, vt| {
visit_local: |l, (t, vt)| {
vfn(l.node.id, t);
visit::visit_local(l, t, vt);
visit::visit_local(l, (t, vt));
},
visit_block: |b, t, vt| {
visit_block: |b, (t, vt)| {
vfn(b.node.id, t);
visit::visit_block(b, t, vt);
visit::visit_block(b, (t, vt));
},
visit_stmt: |s, t, vt| {
visit_stmt: |s, (t, vt)| {
vfn(ast_util::stmt_id(s), t);
visit::visit_stmt(s, t, vt);
visit::visit_stmt(s, (t, vt));
},
visit_pat: |p, t, vt| {
visit_pat: |p, (t, vt)| {
vfn(p.id, t);
visit::visit_pat(p, t, vt);
visit::visit_pat(p, (t, vt));
},
visit_expr: |e, t, vt| {
visit_expr: |e, (t, vt)| {
{
let r = e.get_callee_id();
for r.iter().advance |callee_id| {
@ -469,23 +469,23 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> {
}
}
vfn(e.id, t);
visit::visit_expr(e, t, vt);
visit::visit_expr(e, (t, vt));
},
visit_ty: |ty, t, vt| {
visit_ty: |ty, (t, vt)| {
match ty.node {
ty_path(_, id) => vfn(id, t),
_ => { /* fall through */ }
}
visit::visit_ty(ty, t, vt);
visit::visit_ty(ty, (t, vt));
},
visit_generics: |generics, t, vt| {
visit_generics: |generics, (t, vt)| {
visit_generics(generics, t);
visit::visit_generics(generics, t, vt);
visit::visit_generics(generics, (t, vt));
},
visit_fn: |fk, d, a, b, id, t, vt| {
visit_fn: |fk, d, a, b, id, (t, vt)| {
vfn(id, t);
match *fk {
@ -504,12 +504,12 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> {
for d.inputs.each |arg| {
vfn(arg.id, t)
}
visit::visit_fn(fk, d, a, b, id, t, vt);
visit::visit_fn(fk, d, a, b, id, (t, vt));
},
visit_struct_field: |f, t, vt| {
visit_struct_field: |f, (t, vt)| {
vfn(f.node.id, t);
visit::visit_struct_field(f, t, vt);
visit::visit_struct_field(f, (t, vt));
},
.. *visit::default_visitor()
@ -577,7 +577,7 @@ impl EachViewItem for ast::crate {
let vtor: visit::vt<()> = visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_view_item: |vi| { *broke = f(vi); }, ..*visit::default_simple_visitor()
});
visit::visit_crate(self, (), vtor);
visit::visit_crate(self, ((), vtor));
true
}
}

View File

@ -372,7 +372,8 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
pub fn new_name_finder() -> @Visitor<@mut ~[ast::ident]> {
let default_visitor = visit::default_visitor();
@Visitor{
visit_pat : |p:@ast::pat,ident_accum:@mut ~[ast::ident],v:visit::vt<@mut ~[ast::ident]>| {
visit_pat : |p:@ast::pat,
(ident_accum, v): (@mut ~[ast::ident], visit::vt<@mut ~[ast::ident]>)| {
match *p {
// we found a pat_ident!
ast::pat{id:_, node: ast::pat_ident(_,path,ref inner), span:_} => {
@ -385,11 +386,11 @@ pub fn new_name_finder() -> @Visitor<@mut ~[ast::ident]> {
}
// visit optional subpattern of pat_ident:
for inner.iter().advance |subpat: &@ast::pat| {
(v.visit_pat)(*subpat, ident_accum, v)
(v.visit_pat)(*subpat, (ident_accum, v))
}
}
// use the default traversal for non-pat_idents
_ => visit::visit_pat(p,ident_accum,v)
_ => visit::visit_pat(p,(ident_accum,v))
}
},
.. *default_visitor
@ -889,7 +890,7 @@ mod test {
let pat = string_to_pat(@~"(a,Foo{x:c @ (b,9),y:Bar(4,d)})");
let pat_idents = new_name_finder();
let idents = @mut ~[];
((*pat_idents).visit_pat)(pat,idents, mk_vt(pat_idents));
((*pat_idents).visit_pat)(pat, (idents, mk_vt(pat_idents)));
assert_eq!(idents,@mut strs_to_idents(~["a","c","b","d"]));
}
}

View File

@ -74,85 +74,84 @@ pub fn generics_of_fn(fk: &fn_kind) -> Generics {
}
pub struct Visitor<E> {
visit_mod: @fn(&_mod, span, node_id, E, vt<E>),
visit_view_item: @fn(@view_item, E, vt<E>),
visit_foreign_item: @fn(@foreign_item, E, vt<E>),
visit_item: @fn(@item, E, vt<E>),
visit_local: @fn(@local, E, vt<E>),
visit_block: @fn(&blk, E, vt<E>),
visit_stmt: @fn(@stmt, E, vt<E>),
visit_arm: @fn(&arm, E, vt<E>),
visit_pat: @fn(@pat, E, vt<E>),
visit_decl: @fn(@decl, E, vt<E>),
visit_expr: @fn(@expr, E, vt<E>),
visit_expr_post: @fn(@expr, E, vt<E>),
visit_ty: @fn(@Ty, E, vt<E>),
visit_generics: @fn(&Generics, E, vt<E>),
visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id, E, vt<E>),
visit_ty_method: @fn(&ty_method, E, vt<E>),
visit_trait_method: @fn(&trait_method, E, vt<E>),
visit_struct_def: @fn(@struct_def, ident, &Generics, node_id, E, vt<E>),
visit_struct_field: @fn(@struct_field, E, vt<E>),
visit_struct_method: @fn(@method, E, vt<E>)
visit_mod: @fn(&_mod, span, node_id, (E, vt<E>)),
visit_view_item: @fn(@view_item, (E, vt<E>)),
visit_foreign_item: @fn(@foreign_item, (E, vt<E>)),
visit_item: @fn(@item, (E, vt<E>)),
visit_local: @fn(@local, (E, vt<E>)),
visit_block: @fn(&blk, (E, vt<E>)),
visit_stmt: @fn(@stmt, (E, vt<E>)),
visit_arm: @fn(&arm, (E, vt<E>)),
visit_pat: @fn(@pat, (E, vt<E>)),
visit_decl: @fn(@decl, (E, vt<E>)),
visit_expr: @fn(@expr, (E, vt<E>)),
visit_expr_post: @fn(@expr, (E, vt<E>)),
visit_ty: @fn(@Ty, (E, vt<E>)),
visit_generics: @fn(&Generics, (E, vt<E>)),
visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id, (E, vt<E>)),
visit_ty_method: @fn(&ty_method, (E, vt<E>)),
visit_trait_method: @fn(&trait_method, (E, vt<E>)),
visit_struct_def: @fn(@struct_def, ident, &Generics, node_id, (E, vt<E>)),
visit_struct_field: @fn(@struct_field, (E, vt<E>)),
visit_struct_method: @fn(@method, (E, vt<E>))
}
pub type visitor<E> = @Visitor<E>;
pub fn default_visitor<E: Copy>() -> visitor<E> {
return @Visitor {
visit_mod: |a,b,c,d,e|visit_mod::<E>(a, b, c, d, e),
visit_view_item: |a,b,c|visit_view_item::<E>(a, b, c),
visit_foreign_item: |a,b,c|visit_foreign_item::<E>(a, b, c),
visit_item: |a,b,c|visit_item::<E>(a, b, c),
visit_local: |a,b,c|visit_local::<E>(a, b, c),
visit_block: |a,b,c|visit_block::<E>(a, b, c),
visit_stmt: |a,b,c|visit_stmt::<E>(a, b, c),
visit_arm: |a,b,c|visit_arm::<E>(a, b, c),
visit_pat: |a,b,c|visit_pat::<E>(a, b, c),
visit_decl: |a,b,c|visit_decl::<E>(a, b, c),
visit_expr: |a,b,c|visit_expr::<E>(a, b, c),
visit_expr_post: |_a,_b,_c| (),
visit_ty: |a,b,c|skip_ty::<E>(a, b, c),
visit_generics: |a,b,c|visit_generics::<E>(a, b, c),
visit_fn: |a,b,c,d,e,f,g|visit_fn::<E>(a, b, c, d, e, f, g),
visit_ty_method: |a,b,c|visit_ty_method::<E>(a, b, c),
visit_trait_method: |a,b,c|visit_trait_method::<E>(a, b, c),
visit_struct_def: |a,b,c,d,e,f|visit_struct_def::<E>(a, b, c,
d, e, f),
visit_struct_field: |a,b,c|visit_struct_field::<E>(a, b, c),
visit_struct_method: |a,b,c|visit_struct_method::<E>(a, b, c)
visit_mod: |a,b,c,d|visit_mod::<E>(a, b, c, d),
visit_view_item: |a,b|visit_view_item::<E>(a, b),
visit_foreign_item: |a,b|visit_foreign_item::<E>(a, b),
visit_item: |a,b|visit_item::<E>(a, b),
visit_local: |a,b|visit_local::<E>(a, b),
visit_block: |a,b|visit_block::<E>(a, b),
visit_stmt: |a,b|visit_stmt::<E>(a, b),
visit_arm: |a,b|visit_arm::<E>(a, b),
visit_pat: |a,b|visit_pat::<E>(a, b),
visit_decl: |a,b|visit_decl::<E>(a, b),
visit_expr: |a,b|visit_expr::<E>(a, b),
visit_expr_post: |_a,_b| (),
visit_ty: |a,b|skip_ty::<E>(a, b),
visit_generics: |a,b|visit_generics::<E>(a, b),
visit_fn: |a,b,c,d,e,f|visit_fn::<E>(a, b, c, d, e, f),
visit_ty_method: |a,b|visit_ty_method::<E>(a, b),
visit_trait_method: |a,b|visit_trait_method::<E>(a, b),
visit_struct_def: |a,b,c,d,e|visit_struct_def::<E>(a, b, c, d, e),
visit_struct_field: |a,b|visit_struct_field::<E>(a, b),
visit_struct_method: |a,b|visit_struct_method::<E>(a, b)
};
}
pub fn visit_crate<E: Copy>(c: &crate, e: E, v: vt<E>) {
(v.visit_mod)(&c.node.module, c.span, crate_node_id, e, v);
pub fn visit_crate<E: Copy>(c: &crate, (e, v): (E, vt<E>)) {
(v.visit_mod)(&c.node.module, c.span, crate_node_id, (e, v));
}
pub fn visit_mod<E: Copy>(m: &_mod, _sp: span, _id: node_id, e: E, v: vt<E>) {
for m.view_items.each |vi| { (v.visit_view_item)(*vi, e, v); }
for m.items.each |i| { (v.visit_item)(*i, e, v); }
pub fn visit_mod<E: Copy>(m: &_mod, _sp: span, _id: node_id, (e, v): (E, vt<E>)) {
for m.view_items.each |vi| { (v.visit_view_item)(*vi, (e, v)); }
for m.items.each |i| { (v.visit_item)(*i, (e, v)); }
}
pub fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { }
pub fn visit_view_item<E>(_vi: @view_item, (_e, _v): (E, vt<E>)) { }
pub fn visit_local<E: Copy>(loc: @local, e: E, v: vt<E>) {
(v.visit_pat)(loc.node.pat, e, v);
(v.visit_ty)(loc.node.ty, e, v);
pub fn visit_local<E: Copy>(loc: @local, (e, v): (E, vt<E>)) {
(v.visit_pat)(loc.node.pat, (e, v));
(v.visit_ty)(loc.node.ty, (e, v));
match loc.node.init {
None => (),
Some(ex) => (v.visit_expr)(ex, e, v)
Some(ex) => (v.visit_expr)(ex, (e, v))
}
}
fn visit_trait_ref<E: Copy>(tref: @ast::trait_ref, e: E, v: vt<E>) {
visit_path(tref.path, e, v);
fn visit_trait_ref<E: Copy>(tref: @ast::trait_ref, (e, v): (E, vt<E>)) {
visit_path(tref.path, (e, v));
}
pub fn visit_item<E: Copy>(i: @item, e: E, v: vt<E>) {
pub fn visit_item<E: Copy>(i: @item, (e, v): (E, vt<E>)) {
match i.node {
item_const(t, ex) => {
(v.visit_ty)(t, e, v);
(v.visit_expr)(ex, e, v);
(v.visit_ty)(t, (e, v));
(v.visit_expr)(ex, (e, v));
}
item_fn(ref decl, purity, abi, ref generics, ref body) => {
(v.visit_fn)(
@ -166,193 +165,191 @@ pub fn visit_item<E: Copy>(i: @item, e: E, v: vt<E>) {
body,
i.span,
i.id,
e,
v
(e,
v)
);
}
item_mod(ref m) => (v.visit_mod)(m, i.span, i.id, e, v),
item_mod(ref m) => (v.visit_mod)(m, i.span, i.id, (e, v)),
item_foreign_mod(ref nm) => {
for nm.view_items.each |vi| { (v.visit_view_item)(*vi, e, v); }
for nm.items.each |ni| { (v.visit_foreign_item)(*ni, e, v); }
for nm.view_items.each |vi| { (v.visit_view_item)(*vi, (e, v)); }
for nm.items.each |ni| { (v.visit_foreign_item)(*ni, (e, v)); }
}
item_ty(t, ref tps) => {
(v.visit_ty)(t, e, v);
(v.visit_generics)(tps, e, v);
(v.visit_ty)(t, (e, v));
(v.visit_generics)(tps, (e, v));
}
item_enum(ref enum_definition, ref tps) => {
(v.visit_generics)(tps, e, v);
(v.visit_generics)(tps, (e, v));
visit_enum_def(
enum_definition,
tps,
e,
v
(e, v)
);
}
item_impl(ref tps, ref traits, ty, ref methods) => {
(v.visit_generics)(tps, e, v);
(v.visit_generics)(tps, (e, v));
for traits.iter().advance |&p| {
visit_trait_ref(p, e, v);
visit_trait_ref(p, (e, v));
}
(v.visit_ty)(ty, e, v);
(v.visit_ty)(ty, (e, v));
for methods.each |m| {
visit_method_helper(*m, e, v)
visit_method_helper(*m, (e, v))
}
}
item_struct(struct_def, ref generics) => {
(v.visit_generics)(generics, e, v);
(v.visit_struct_def)(struct_def, i.ident, generics, i.id, e, v);
(v.visit_generics)(generics, (e, v));
(v.visit_struct_def)(struct_def, i.ident, generics, i.id, (e, v));
}
item_trait(ref generics, ref traits, ref methods) => {
(v.visit_generics)(generics, e, v);
for traits.each |p| { visit_path(p.path, e, v); }
(v.visit_generics)(generics, (e, v));
for traits.each |p| { visit_path(p.path, (e, v)); }
for methods.each |m| {
(v.visit_trait_method)(m, e, v);
(v.visit_trait_method)(m, (e, v));
}
}
item_mac(ref m) => visit_mac(m, e, v)
item_mac(ref m) => visit_mac(m, (e, v))
}
}
pub fn visit_enum_def<E: Copy>(enum_definition: &ast::enum_def,
tps: &Generics,
e: E,
v: vt<E>) {
(e, v): (E, vt<E>)) {
for enum_definition.variants.each |vr| {
match vr.node.kind {
tuple_variant_kind(ref variant_args) => {
for variant_args.each |va| { (v.visit_ty)(va.ty, e, v); }
for variant_args.each |va| { (v.visit_ty)(va.ty, (e, v)); }
}
struct_variant_kind(struct_def) => {
(v.visit_struct_def)(struct_def, vr.node.name, tps,
vr.node.id, e, v);
vr.node.id, (e, v));
}
}
// Visit the disr expr if it exists
for vr.node.disr_expr.iter().advance |ex| { (v.visit_expr)(*ex, e, v) }
for vr.node.disr_expr.iter().advance |ex| { (v.visit_expr)(*ex, (e, v)) }
}
}
pub fn skip_ty<E>(_t: @Ty, _e: E, _v: vt<E>) {}
pub fn skip_ty<E>(_t: @Ty, (_e,_v): (E, vt<E>)) {}
pub fn visit_ty<E: Copy>(t: @Ty, e: E, v: vt<E>) {
pub fn visit_ty<E: Copy>(t: @Ty, (e, v): (E, vt<E>)) {
match t.node {
ty_box(mt) | ty_uniq(mt) |
ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => {
(v.visit_ty)(mt.ty, e, v);
(v.visit_ty)(mt.ty, (e, v));
},
ty_tup(ref ts) => {
for ts.each |tt| {
(v.visit_ty)(*tt, e, v);
(v.visit_ty)(*tt, (e, v));
}
},
ty_closure(ref f) => {
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
(v.visit_ty)(f.decl.output, e, v);
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, (e, v)); }
(v.visit_ty)(f.decl.output, (e, v));
},
ty_bare_fn(ref f) => {
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
(v.visit_ty)(f.decl.output, e, v);
for f.decl.inputs.each |a| { (v.visit_ty)(a.ty, (e, v)); }
(v.visit_ty)(f.decl.output, (e, v));
},
ty_path(p, _) => visit_path(p, e, v),
ty_path(p, _) => visit_path(p, (e, v)),
ty_fixed_length_vec(ref mt, ex) => {
(v.visit_ty)(mt.ty, e, v);
(v.visit_expr)(ex, e, v);
(v.visit_ty)(mt.ty, (e, v));
(v.visit_expr)(ex, (e, v));
},
ty_nil | ty_bot | ty_mac(_) | ty_infer => ()
}
}
pub fn visit_path<E: Copy>(p: @Path, e: E, v: vt<E>) {
for p.types.each |tp| { (v.visit_ty)(*tp, e, v); }
pub fn visit_path<E: Copy>(p: @Path, (e, v): (E, vt<E>)) {
for p.types.each |tp| { (v.visit_ty)(*tp, (e, v)); }
}
pub fn visit_pat<E: Copy>(p: @pat, e: E, v: vt<E>) {
pub fn visit_pat<E: Copy>(p: @pat, (e, v): (E, vt<E>)) {
match p.node {
pat_enum(path, ref children) => {
visit_path(path, e, v);
visit_path(path, (e, v));
for children.iter().advance |children| {
for children.iter().advance |child| { (v.visit_pat)(*child, e, v); }
for children.iter().advance |child| { (v.visit_pat)(*child, (e, v)); }
}
}
pat_struct(path, ref fields, _) => {
visit_path(path, e, v);
visit_path(path, (e, v));
for fields.each |f| {
(v.visit_pat)(f.pat, e, v);
(v.visit_pat)(f.pat, (e, v));
}
}
pat_tup(ref elts) => {
for elts.each |elt| {
(v.visit_pat)(*elt, e, v)
(v.visit_pat)(*elt, (e, v))
}
},
pat_box(inner) | pat_uniq(inner) | pat_region(inner) => {
(v.visit_pat)(inner, e, v)
(v.visit_pat)(inner, (e, v))
},
pat_ident(_, path, ref inner) => {
visit_path(path, e, v);
for inner.iter().advance |subpat| { (v.visit_pat)(*subpat, e, v) }
visit_path(path, (e, v));
for inner.iter().advance |subpat| { (v.visit_pat)(*subpat, (e, v)) }
}
pat_lit(ex) => (v.visit_expr)(ex, e, v),
pat_lit(ex) => (v.visit_expr)(ex, (e, v)),
pat_range(e1, e2) => {
(v.visit_expr)(e1, e, v);
(v.visit_expr)(e2, e, v);
(v.visit_expr)(e1, (e, v));
(v.visit_expr)(e2, (e, v));
}
pat_wild => (),
pat_vec(ref before, ref slice, ref after) => {
for before.each |elt| {
(v.visit_pat)(*elt, e, v);
(v.visit_pat)(*elt, (e, v));
}
for slice.iter().advance |elt| {
(v.visit_pat)(*elt, e, v);
(v.visit_pat)(*elt, (e, v));
}
for after.each |tail| {
(v.visit_pat)(*tail, e, v);
(v.visit_pat)(*tail, (e, v));
}
}
}
}
pub fn visit_foreign_item<E: Copy>(ni: @foreign_item, e: E, v: vt<E>) {
pub fn visit_foreign_item<E: Copy>(ni: @foreign_item, (e, v): (E, vt<E>)) {
match ni.node {
foreign_item_fn(ref fd, _, ref generics) => {
visit_fn_decl(fd, e, v);
(v.visit_generics)(generics, e, v);
visit_fn_decl(fd, (e, v));
(v.visit_generics)(generics, (e, v));
}
foreign_item_const(t) => {
(v.visit_ty)(t, e, v);
(v.visit_ty)(t, (e, v));
}
}
}
pub fn visit_ty_param_bounds<E: Copy>(bounds: @OptVec<TyParamBound>,
e: E, v: vt<E>) {
(e, v): (E, vt<E>)) {
for bounds.each |bound| {
match *bound {
TraitTyParamBound(ty) => visit_trait_ref(ty, e, v),
TraitTyParamBound(ty) => visit_trait_ref(ty, (e, v)),
RegionTyParamBound => {}
}
}
}
pub fn visit_generics<E: Copy>(generics: &Generics, e: E, v: vt<E>) {
pub fn visit_generics<E: Copy>(generics: &Generics, (e, v): (E, vt<E>)) {
for generics.ty_params.each |tp| {
visit_ty_param_bounds(tp.bounds, e, v);
visit_ty_param_bounds(tp.bounds, (e, v));
}
}
pub fn visit_fn_decl<E: Copy>(fd: &fn_decl, e: E, v: vt<E>) {
pub fn visit_fn_decl<E: Copy>(fd: &fn_decl, (e, v): (E, vt<E>)) {
for fd.inputs.each |a| {
(v.visit_pat)(a.pat, e, v);
(v.visit_ty)(a.ty, e, v);
(v.visit_pat)(a.pat, (e, v));
(v.visit_ty)(a.ty, (e, v));
}
(v.visit_ty)(fd.output, e, v);
(v.visit_ty)(fd.output, (e, v));
}
// Note: there is no visit_method() method in the visitor, instead override
// visit_fn() and check for fk_method(). I named this visit_method_helper()
// because it is not a default impl of any method, though I doubt that really
// clarifies anything. - Niko
pub fn visit_method_helper<E: Copy>(m: &method, e: E, v: vt<E>) {
pub fn visit_method_helper<E: Copy>(m: &method, (e, v): (E, vt<E>)) {
(v.visit_fn)(
&fk_method(
/* FIXME (#2543) */ copy m.ident,
@ -363,29 +360,28 @@ pub fn visit_method_helper<E: Copy>(m: &method, e: E, v: vt<E>) {
&m.body,
m.span,
m.id,
e,
v
(e, v)
);
}
pub fn visit_fn<E: Copy>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span,
_id: node_id, e: E, v: vt<E>) {
visit_fn_decl(decl, e, v);
_id: node_id, (e, v): (E, vt<E>)) {
visit_fn_decl(decl, (e, v));
let generics = generics_of_fn(fk);
(v.visit_generics)(&generics, e, v);
(v.visit_block)(body, e, v);
(v.visit_generics)(&generics, (e, v));
(v.visit_block)(body, (e, v));
}
pub fn visit_ty_method<E: Copy>(m: &ty_method, e: E, v: vt<E>) {
for m.decl.inputs.each |a| { (v.visit_ty)(a.ty, e, v); }
(v.visit_generics)(&m.generics, e, v);
(v.visit_ty)(m.decl.output, e, v);
pub fn visit_ty_method<E: Copy>(m: &ty_method, (e, v): (E, vt<E>)) {
for m.decl.inputs.each |a| { (v.visit_ty)(a.ty, (e, v)); }
(v.visit_generics)(&m.generics, (e, v));
(v.visit_ty)(m.decl.output, (e, v));
}
pub fn visit_trait_method<E: Copy>(m: &trait_method, e: E, v: vt<E>) {
pub fn visit_trait_method<E: Copy>(m: &trait_method, (e, v): (E, vt<E>)) {
match *m {
required(ref ty_m) => (v.visit_ty_method)(ty_m, e, v),
provided(m) => visit_method_helper(m, e, v)
required(ref ty_m) => (v.visit_ty_method)(ty_m, (e, v)),
provided(m) => visit_method_helper(m, (e, v))
}
}
@ -394,109 +390,108 @@ pub fn visit_struct_def<E: Copy>(
_nm: ast::ident,
_generics: &Generics,
_id: node_id,
e: E,
v: vt<E>
(e, v): (E, vt<E>)
) {
for sd.fields.each |f| {
(v.visit_struct_field)(*f, e, v);
(v.visit_struct_field)(*f, (e, v));
}
}
pub fn visit_struct_field<E: Copy>(sf: @struct_field, e: E, v: vt<E>) {
(v.visit_ty)(sf.node.ty, e, v);
pub fn visit_struct_field<E: Copy>(sf: @struct_field, (e, v): (E, vt<E>)) {
(v.visit_ty)(sf.node.ty, (e, v));
}
pub fn visit_struct_method<E: Copy>(m: @method, e: E, v: vt<E>) {
visit_method_helper(m, e, v);
pub fn visit_struct_method<E: Copy>(m: @method, (e, v): (E, vt<E>)) {
visit_method_helper(m, (e, v));
}
pub fn visit_block<E: Copy>(b: &blk, e: E, v: vt<E>) {
pub fn visit_block<E: Copy>(b: &blk, (e, v): (E, vt<E>)) {
for b.node.view_items.each |vi| {
(v.visit_view_item)(*vi, e, v);
(v.visit_view_item)(*vi, (e, v));
}
for b.node.stmts.each |s| {
(v.visit_stmt)(*s, e, v);
(v.visit_stmt)(*s, (e, v));
}
visit_expr_opt(b.node.expr, e, v);
visit_expr_opt(b.node.expr, (e, v));
}
pub fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) {
pub fn visit_stmt<E>(s: @stmt, (e, v): (E, vt<E>)) {
match s.node {
stmt_decl(d, _) => (v.visit_decl)(d, e, v),
stmt_expr(ex, _) => (v.visit_expr)(ex, e, v),
stmt_semi(ex, _) => (v.visit_expr)(ex, e, v),
stmt_mac(ref mac, _) => visit_mac(mac, e, v)
stmt_decl(d, _) => (v.visit_decl)(d, (e, v)),
stmt_expr(ex, _) => (v.visit_expr)(ex, (e, v)),
stmt_semi(ex, _) => (v.visit_expr)(ex, (e, v)),
stmt_mac(ref mac, _) => visit_mac(mac, (e, v))
}
}
pub fn visit_decl<E: Copy>(d: @decl, e: E, v: vt<E>) {
pub fn visit_decl<E: Copy>(d: @decl, (e, v): (E, vt<E>)) {
match d.node {
decl_local(ref loc) => (v.visit_local)(*loc, e, v),
decl_item(it) => (v.visit_item)(it, e, v)
decl_local(ref loc) => (v.visit_local)(*loc, (e, v)),
decl_item(it) => (v.visit_item)(it, (e, v))
}
}
pub fn visit_expr_opt<E>(eo: Option<@expr>, e: E, v: vt<E>) {
match eo { None => (), Some(ex) => (v.visit_expr)(ex, e, v) }
pub fn visit_expr_opt<E>(eo: Option<@expr>, (e, v): (E, vt<E>)) {
match eo { None => (), Some(ex) => (v.visit_expr)(ex, (e, v)) }
}
pub fn visit_exprs<E: Copy>(exprs: &[@expr], e: E, v: vt<E>) {
for exprs.each |ex| { (v.visit_expr)(*ex, e, v); }
pub fn visit_exprs<E: Copy>(exprs: &[@expr], (e, v): (E, vt<E>)) {
for exprs.each |ex| { (v.visit_expr)(*ex, (e, v)); }
}
pub fn visit_mac<E>(_m: &mac, _e: E, _v: vt<E>) {
pub fn visit_mac<E>(_m: &mac, (_e, _v): (E, vt<E>)) {
/* no user-serviceable parts inside */
}
pub fn visit_expr<E: Copy>(ex: @expr, e: E, v: vt<E>) {
pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) {
match ex.node {
expr_vstore(x, _) => (v.visit_expr)(x, e, v),
expr_vec(ref es, _) => visit_exprs(*es, e, v),
expr_vstore(x, _) => (v.visit_expr)(x, (e, v)),
expr_vec(ref es, _) => visit_exprs(*es, (e, v)),
expr_repeat(element, count, _) => {
(v.visit_expr)(element, e, v);
(v.visit_expr)(count, e, v);
(v.visit_expr)(element, (e, v));
(v.visit_expr)(count, (e, v));
}
expr_struct(p, ref flds, base) => {
visit_path(p, e, v);
for flds.each |f| { (v.visit_expr)(f.node.expr, e, v); }
visit_expr_opt(base, e, v);
visit_path(p, (e, v));
for flds.each |f| { (v.visit_expr)(f.node.expr, (e, v)); }
visit_expr_opt(base, (e, v));
}
expr_tup(ref elts) => {
for elts.each |el| { (v.visit_expr)(*el, e, v) }
for elts.each |el| { (v.visit_expr)(*el, (e, v)) }
}
expr_call(callee, ref args, _) => {
visit_exprs(*args, e, v);
(v.visit_expr)(callee, e, v);
visit_exprs(*args, (e, v));
(v.visit_expr)(callee, (e, v));
}
expr_method_call(_, callee, _, ref tys, ref args, _) => {
visit_exprs(*args, e, v);
for tys.each |tp| { (v.visit_ty)(*tp, e, v); }
(v.visit_expr)(callee, e, v);
visit_exprs(*args, (e, v));
for tys.each |tp| { (v.visit_ty)(*tp, (e, v)); }
(v.visit_expr)(callee, (e, v));
}
expr_binary(_, _, a, b) => {
(v.visit_expr)(a, e, v);
(v.visit_expr)(b, e, v);
(v.visit_expr)(a, (e, v));
(v.visit_expr)(b, (e, v));
}
expr_addr_of(_, x) | expr_unary(_, _, x) |
expr_loop_body(x) | expr_do_body(x) => (v.visit_expr)(x, e, v),
expr_loop_body(x) | expr_do_body(x) => (v.visit_expr)(x, (e, v)),
expr_lit(_) => (),
expr_cast(x, t) => {
(v.visit_expr)(x, e, v);
(v.visit_ty)(t, e, v);
(v.visit_expr)(x, (e, v));
(v.visit_ty)(t, (e, v));
}
expr_if(x, ref b, eo) => {
(v.visit_expr)(x, e, v);
(v.visit_block)(b, e, v);
visit_expr_opt(eo, e, v);
(v.visit_expr)(x, (e, v));
(v.visit_block)(b, (e, v));
visit_expr_opt(eo, (e, v));
}
expr_while(x, ref b) => {
(v.visit_expr)(x, e, v);
(v.visit_block)(b, e, v);
(v.visit_expr)(x, (e, v));
(v.visit_block)(b, (e, v));
}
expr_loop(ref b, _) => (v.visit_block)(b, e, v),
expr_loop(ref b, _) => (v.visit_block)(b, (e, v)),
expr_match(x, ref arms) => {
(v.visit_expr)(x, e, v);
for arms.each |a| { (v.visit_arm)(a, e, v); }
(v.visit_expr)(x, (e, v));
for arms.each |a| { (v.visit_arm)(a, (e, v)); }
}
expr_fn_block(ref decl, ref body) => {
(v.visit_fn)(
@ -505,55 +500,54 @@ pub fn visit_expr<E: Copy>(ex: @expr, e: E, v: vt<E>) {
body,
ex.span,
ex.id,
e,
v
(e, v)
);
}
expr_block(ref b) => (v.visit_block)(b, e, v),
expr_block(ref b) => (v.visit_block)(b, (e, v)),
expr_assign(a, b) => {
(v.visit_expr)(b, e, v);
(v.visit_expr)(a, e, v);
(v.visit_expr)(b, (e, v));
(v.visit_expr)(a, (e, v));
}
expr_copy(a) => (v.visit_expr)(a, e, v),
expr_copy(a) => (v.visit_expr)(a, (e, v)),
expr_assign_op(_, _, a, b) => {
(v.visit_expr)(b, e, v);
(v.visit_expr)(a, e, v);
(v.visit_expr)(b, (e, v));
(v.visit_expr)(a, (e, v));
}
expr_field(x, _, ref tys) => {
(v.visit_expr)(x, e, v);
for tys.each |tp| { (v.visit_ty)(*tp, e, v); }
(v.visit_expr)(x, (e, v));
for tys.each |tp| { (v.visit_ty)(*tp, (e, v)); }
}
expr_index(_, a, b) => {
(v.visit_expr)(a, e, v);
(v.visit_expr)(b, e, v);
(v.visit_expr)(a, (e, v));
(v.visit_expr)(b, (e, v));
}
expr_path(p) => visit_path(p, e, v),
expr_path(p) => visit_path(p, (e, v)),
expr_self => (),
expr_break(_) => (),
expr_again(_) => (),
expr_ret(eo) => visit_expr_opt(eo, e, v),
expr_ret(eo) => visit_expr_opt(eo, (e, v)),
expr_log(lv, x) => {
(v.visit_expr)(lv, e, v);
(v.visit_expr)(x, e, v);
(v.visit_expr)(lv, (e, v));
(v.visit_expr)(x, (e, v));
}
expr_mac(ref mac) => visit_mac(mac, e, v),
expr_paren(x) => (v.visit_expr)(x, e, v),
expr_mac(ref mac) => visit_mac(mac, (e, v)),
expr_paren(x) => (v.visit_expr)(x, (e, v)),
expr_inline_asm(ref a) => {
for a.inputs.each |&(_, in)| {
(v.visit_expr)(in, e, v);
(v.visit_expr)(in, (e, v));
}
for a.outputs.each |&(_, out)| {
(v.visit_expr)(out, e, v);
(v.visit_expr)(out, (e, v));
}
}
}
(v.visit_expr_post)(ex, e, v);
(v.visit_expr_post)(ex, (e, v));
}
pub fn visit_arm<E: Copy>(a: &arm, e: E, v: vt<E>) {
for a.pats.iter().advance |p| { (v.visit_pat)(*p, e, v); }
visit_expr_opt(a.guard, e, v);
(v.visit_block)(&a.body, e, v);
pub fn visit_arm<E: Copy>(a: &arm, (e, v): (E, vt<E>)) {
for a.pats.iter().advance |p| { (v.visit_pat)(*p, (e, v)); }
visit_expr_opt(a.guard, (e, v));
(v.visit_block)(&a.body, (e, v));
}
// Simpler, non-context passing interface. Always walks the whole tree, simply
@ -617,70 +611,67 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
m: &_mod,
sp: span,
id: node_id,
e: (),
v: vt<()>
(e, v): ((), vt<()>)
) {
f(m, sp, id);
visit_mod(m, sp, id, e, v);
visit_mod(m, sp, id, (e, v));
}
fn v_view_item(f: @fn(@view_item), vi: @view_item, e: (), v: vt<()>) {
fn v_view_item(f: @fn(@view_item), vi: @view_item, (e, v): ((), vt<()>)) {
f(vi);
visit_view_item(vi, e, v);
visit_view_item(vi, (e, v));
}
fn v_foreign_item(f: @fn(@foreign_item), ni: @foreign_item, e: (),
v: vt<()>) {
fn v_foreign_item(f: @fn(@foreign_item), ni: @foreign_item, (e, v): ((), vt<()>)) {
f(ni);
visit_foreign_item(ni, e, v);
visit_foreign_item(ni, (e, v));
}
fn v_item(f: @fn(@item), i: @item, e: (), v: vt<()>) {
fn v_item(f: @fn(@item), i: @item, (e, v): ((), vt<()>)) {
f(i);
visit_item(i, e, v);
visit_item(i, (e, v));
}
fn v_local(f: @fn(@local), l: @local, e: (), v: vt<()>) {
fn v_local(f: @fn(@local), l: @local, (e, v): ((), vt<()>)) {
f(l);
visit_local(l, e, v);
visit_local(l, (e, v));
}
fn v_block(f: @fn(&ast::blk), bl: &ast::blk, e: (), v: vt<()>) {
fn v_block(f: @fn(&ast::blk), bl: &ast::blk, (e, v): ((), vt<()>)) {
f(bl);
visit_block(bl, e, v);
visit_block(bl, (e, v));
}
fn v_stmt(f: @fn(@stmt), st: @stmt, e: (), v: vt<()>) {
fn v_stmt(f: @fn(@stmt), st: @stmt, (e, v): ((), vt<()>)) {
f(st);
visit_stmt(st, e, v);
visit_stmt(st, (e, v));
}
fn v_arm(f: @fn(&arm), a: &arm, e: (), v: vt<()>) {
fn v_arm(f: @fn(&arm), a: &arm, (e, v): ((), vt<()>)) {
f(a);
visit_arm(a, e, v);
visit_arm(a, (e, v));
}
fn v_pat(f: @fn(@pat), p: @pat, e: (), v: vt<()>) {
fn v_pat(f: @fn(@pat), p: @pat, (e, v): ((), vt<()>)) {
f(p);
visit_pat(p, e, v);
visit_pat(p, (e, v));
}
fn v_decl(f: @fn(@decl), d: @decl, e: (), v: vt<()>) {
fn v_decl(f: @fn(@decl), d: @decl, (e, v): ((), vt<()>)) {
f(d);
visit_decl(d, e, v);
visit_decl(d, (e, v));
}
fn v_expr(f: @fn(@expr), ex: @expr, e: (), v: vt<()>) {
fn v_expr(f: @fn(@expr), ex: @expr, (e, v): ((), vt<()>)) {
f(ex);
visit_expr(ex, e, v);
visit_expr(ex, (e, v));
}
fn v_expr_post(f: @fn(@expr), ex: @expr, _e: (), _v: vt<()>) {
fn v_expr_post(f: @fn(@expr), ex: @expr, (_e, _v): ((), vt<()>)) {
f(ex);
}
fn v_ty(f: @fn(@Ty), ty: @Ty, e: (), v: vt<()>) {
fn v_ty(f: @fn(@Ty), ty: @Ty, (e, v): ((), vt<()>)) {
f(ty);
visit_ty(ty, e, v);
visit_ty(ty, (e, v));
}
fn v_ty_method(f: @fn(&ty_method), ty: &ty_method, e: (), v: vt<()>) {
fn v_ty_method(f: @fn(&ty_method), ty: &ty_method, (e, v): ((), vt<()>)) {
f(ty);
visit_ty_method(ty, e, v);
visit_ty_method(ty, (e, v));
}
fn v_trait_method(f: @fn(&trait_method),
m: &trait_method,
e: (),
v: vt<()>) {
(e, v): ((), vt<()>)) {
f(m);
visit_trait_method(m, e, v);
visit_trait_method(m, (e, v));
}
fn v_struct_def(
f: @fn(@struct_def, ident, &Generics, node_id),
@ -688,20 +679,18 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
nm: ident,
generics: &Generics,
id: node_id,
e: (),
v: vt<()>
(e, v): ((), vt<()>)
) {
f(sd, nm, generics, id);
visit_struct_def(sd, nm, generics, id, e, v);
visit_struct_def(sd, nm, generics, id, (e, v));
}
fn v_generics(
f: @fn(&Generics),
ps: &Generics,
e: (),
v: vt<()>
(e, v): ((), vt<()>)
) {
f(ps);
visit_generics(ps, e, v);
visit_generics(ps, (e, v));
}
fn v_fn(
f: @fn(&fn_kind, &fn_decl, &blk, span, node_id),
@ -710,52 +699,49 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
body: &blk,
sp: span,
id: node_id,
e: (),
v: vt<()>
(e, v): ((), vt<()>)
) {
f(fk, decl, body, sp, id);
visit_fn(fk, decl, body, sp, id, e, v);
visit_fn(fk, decl, body, sp, id, (e, v));
}
let visit_ty: @fn(@Ty, x: (), vt<()>) =
|a,b,c| v_ty(v.visit_ty, a, b, c);
fn v_struct_field(f: @fn(@struct_field), sf: @struct_field, e: (),
v: vt<()>) {
let visit_ty: @fn(@Ty, ((), vt<()>)) =
|a,b| v_ty(v.visit_ty, a, b);
fn v_struct_field(f: @fn(@struct_field), sf: @struct_field, (e, v): ((), vt<()>)) {
f(sf);
visit_struct_field(sf, e, v);
visit_struct_field(sf, (e, v));
}
fn v_struct_method(f: @fn(@method), m: @method, e: (), v: vt<()>) {
fn v_struct_method(f: @fn(@method), m: @method, (e, v): ((), vt<()>)) {
f(m);
visit_struct_method(m, e, v);
visit_struct_method(m, (e, v));
}
return mk_vt(@Visitor {
visit_mod: |a,b,c,d,e|v_mod(v.visit_mod, a, b, c, d, e),
visit_view_item: |a,b,c| v_view_item(v.visit_view_item, a, b, c),
visit_mod: |a,b,c,d|v_mod(v.visit_mod, a, b, c, d),
visit_view_item: |a,b| v_view_item(v.visit_view_item, a, b),
visit_foreign_item:
|a,b,c|v_foreign_item(v.visit_foreign_item, a, b, c),
visit_item: |a,b,c|v_item(v.visit_item, a, b, c),
visit_local: |a,b,c|v_local(v.visit_local, a, b, c),
visit_block: |a,b,c|v_block(v.visit_block, a, b, c),
visit_stmt: |a,b,c|v_stmt(v.visit_stmt, a, b, c),
visit_arm: |a,b,c|v_arm(v.visit_arm, a, b, c),
visit_pat: |a,b,c|v_pat(v.visit_pat, a, b, c),
visit_decl: |a,b,c|v_decl(v.visit_decl, a, b, c),
visit_expr: |a,b,c|v_expr(v.visit_expr, a, b, c),
visit_expr_post: |a,b,c| v_expr_post(v.visit_expr_post,
a, b, c),
|a,b|v_foreign_item(v.visit_foreign_item, a, b),
visit_item: |a,b|v_item(v.visit_item, a, b),
visit_local: |a,b|v_local(v.visit_local, a, b),
visit_block: |a,b|v_block(v.visit_block, a, b),
visit_stmt: |a,b|v_stmt(v.visit_stmt, a, b),
visit_arm: |a,b|v_arm(v.visit_arm, a, b),
visit_pat: |a,b|v_pat(v.visit_pat, a, b),
visit_decl: |a,b|v_decl(v.visit_decl, a, b),
visit_expr: |a,b|v_expr(v.visit_expr, a, b),
visit_expr_post: |a,b| v_expr_post(v.visit_expr_post, a, b),
visit_ty: visit_ty,
visit_generics: |a,b,c|
v_generics(v.visit_generics, a, b, c),
visit_fn: |a,b,c,d,e,f,g|
v_fn(v.visit_fn, a, b, c, d, e, f, g),
visit_ty_method: |a,b,c|
v_ty_method(v.visit_ty_method, a, b, c),
visit_trait_method: |a,b,c|
v_trait_method(v.visit_trait_method, a, b, c),
visit_struct_def: |a,b,c,d,e,f|
v_struct_def(v.visit_struct_def, a, b, c, d, e, f),
visit_struct_field: |a,b,c|
v_struct_field(v.visit_struct_field, a, b, c),
visit_struct_method: |a,b,c|
v_struct_method(v.visit_struct_method, a, b, c)
visit_generics: |a,b|
v_generics(v.visit_generics, a, b),
visit_fn: |a,b,c,d,e,f|
v_fn(v.visit_fn, a, b, c, d, e, f),
visit_ty_method: |a,b|
v_ty_method(v.visit_ty_method, a, b),
visit_trait_method: |a,b|
v_trait_method(v.visit_trait_method, a, b),
visit_struct_def: |a,b,c,d,e|
v_struct_def(v.visit_struct_def, a, b, c, d, e),
visit_struct_field: |a,b|
v_struct_field(v.visit_struct_field, a, b),
visit_struct_method: |a,b|
v_struct_method(v.visit_struct_method, a, b)
});
}