Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rust
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: nikomatsakis/rust
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: issue-XXX-use-visitor-objects
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 1 commit
  • 30 files changed
  • 1 contributor

Commits on Aug 23, 2013

  1. wip

    nikomatsakis committed Aug 23, 2013
    Copy the full SHA
    92c2646 View commit details
7 changes: 4 additions & 3 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ use syntax::diagnostic::span_handler;
use syntax::parse::token::special_idents;
use syntax::ast_util;
use syntax::visit;
use syntax::visit::Visitor;
use syntax::parse::token;
use syntax;
use writer = extra::ebml::writer;
@@ -1229,15 +1230,15 @@ struct EncodeVisitor {
impl visit::Visitor<()> for EncodeVisitor {
fn visit_expr(&mut self, ex:@expr, _:()) { my_visit_expr(ex); }
fn visit_item(&mut self, i:@item, _:()) {
visit::walk_item(self, i, ());
visit::walk_item(&mut *self as &mut Visitor<()>, i, ()); // FIXME
my_visit_item(i,
self.items,
&self.ebml_w_for_visit_item,
self.ecx_ptr,
self.index);
}
fn visit_foreign_item(&mut self, ni:@foreign_item, _:()) {
visit::walk_foreign_item(self, ni, ());
visit::walk_foreign_item(&mut *self as &mut Visitor<()>, ni, ()); // FIXME
my_visit_foreign_item(ni,
self.items,
&self.ebml_w_for_visit_foreign_item,
@@ -1272,7 +1273,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
ebml_w_for_visit_foreign_item: (*ebml_w).clone(),
};

visit::walk_crate(&mut visitor, crate, ());
visit::walk_crate(&mut visitor as &mut Visitor<()>, crate, ());

ebml_w.end_tag();
return /*bad*/(*index).clone();
10 changes: 5 additions & 5 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
@@ -661,7 +661,7 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
}
}

visit::walk_fn(visitor, fk, decl, body, sp, id, this);
visit::walk_fn(visitor as &mut Visitor<CheckLoanCtxt<'a>>, fk, decl, body, sp, id, this);

fn check_captured_variables(this: CheckLoanCtxt,
closure_id: ast::NodeId,
@@ -707,13 +707,13 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
fn check_loans_in_local<'a>(vt: &mut CheckLoanVisitor,
local: @ast::Local,
this: CheckLoanCtxt<'a>) {
visit::walk_local(vt, local, this);
visit::walk_local(vt as &mut Visitor<CheckLoanCtxt<'a>>, local, this);
}

fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor,
expr: @ast::expr,
this: CheckLoanCtxt<'a>) {
visit::walk_expr(vt, expr, this);
visit::walk_expr(vt as &mut Visitor<CheckLoanCtxt<'a>>, expr, this);

debug!("check_loans_in_expr(expr=%s)",
expr.repr(this.tcx()));
@@ -770,13 +770,13 @@ fn check_loans_in_pat<'a>(vt: &mut CheckLoanVisitor,
{
this.check_for_conflicting_loans(pat.id);
this.check_move_out_from_id(pat.id, pat.span);
visit::walk_pat(vt, pat, this);
visit::walk_pat(vt as &mut Visitor<CheckLoanCtxt<'a>>, pat, this);
}

fn check_loans_in_block<'a>(vt: &mut CheckLoanVisitor,
blk: &ast::Block,
this: CheckLoanCtxt<'a>)
{
visit::walk_block(vt, blk, this);
visit::walk_block(vt as &mut Visitor<CheckLoanCtxt<'a>>, blk, this);
this.check_for_conflicting_loans(blk.id);
}
24 changes: 12 additions & 12 deletions src/librustc/middle/borrowck/gather_loans/mod.rs
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ fn add_pat_to_id_range(v: &mut GatherLoanVisitor,
// `gather_pat()` method below. Eventually these two should be
// brought together.
this.id_range.add(p.id);
visit::walk_pat(v, p, this);
visit::walk_pat(v as &mut Visitor<@mut GatherLoanCtxt>, p, this);
}

fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
@@ -145,7 +145,7 @@ fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
// Visit closures as part of the containing item.
&visit::fk_anon(*) | &visit::fk_fn_block(*) => {
this.push_repeating_id(body.id);
visit::walk_fn(v, fk, decl, body, sp, id, this);
visit::walk_fn(v as &mut Visitor<@mut GatherLoanCtxt>, fk, decl, body, sp, id, this);
this.pop_repeating_id(body.id);
this.gather_fn_arg_patterns(decl, body);
}
@@ -156,7 +156,7 @@ fn gather_loans_in_block(v: &mut GatherLoanVisitor,
blk: &ast::Block,
this: @mut GatherLoanCtxt) {
this.id_range.add(blk.id);
visit::walk_block(v, blk, this);
visit::walk_block(v as &mut Visitor<@mut GatherLoanCtxt>, blk, this);
}

fn gather_loans_in_local(v: &mut GatherLoanVisitor,
@@ -192,7 +192,7 @@ fn gather_loans_in_local(v: &mut GatherLoanVisitor,
}
}

visit::walk_local(v, local, this);
visit::walk_local(v as &mut Visitor<@mut GatherLoanCtxt>, local, this);
}


@@ -238,7 +238,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
// 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::walk_expr(v, ex, this);
visit::walk_expr(v as &mut Visitor<@mut GatherLoanCtxt>, ex, this);
}

ast::expr_assign(l, _) | ast::expr_assign_op(_, _, l, _) => {
@@ -255,7 +255,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
// with moves etc, just ignore.
}
}
visit::walk_expr(v, ex, this);
visit::walk_expr(v as &mut Visitor<@mut GatherLoanCtxt>, ex, this);
}

ast::expr_match(ex_v, ref arms) => {
@@ -265,7 +265,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
this.gather_pat(cmt, *pat, Some((arm.body.id, ex.id)));
}
}
visit::walk_expr(v, ex, this);
visit::walk_expr(v as &mut Visitor<@mut GatherLoanCtxt>, ex, this);
}

ast::expr_index(_, _, arg) |
@@ -279,7 +279,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
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::walk_expr(v, ex, this);
visit::walk_expr(v as &mut Visitor<@mut GatherLoanCtxt>, ex, this);
}

// see explanation attached to the `root_ub` field:
@@ -298,17 +298,17 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
// see explanation attached to the `root_ub` field:
ast::expr_loop(ref body, _) => {
this.push_repeating_id(body.id);
visit::walk_expr(v, ex, this);
visit::walk_expr(v as &mut Visitor<@mut GatherLoanCtxt>, ex, this);
this.pop_repeating_id(body.id);
}

ast::expr_fn_block(*) => {
gather_moves::gather_captures(this.bccx, this.move_data, ex);
visit::walk_expr(v, ex, this);
visit::walk_expr(v as &mut Visitor<@mut GatherLoanCtxt>, ex, this);
}

_ => {
visit::walk_expr(v, ex, this);
visit::walk_expr(v as &mut Visitor<@mut GatherLoanCtxt>, ex, this);
}
}
}
@@ -799,5 +799,5 @@ fn add_stmt_to_map(v: &mut GatherLoanVisitor,
}
_ => ()
}
visit::walk_stmt(v, stmt, this);
visit::walk_stmt(v as &mut Visitor<@mut GatherLoanCtxt>, stmt, this);
}
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ pub fn check_crate(
};

let mut v = BorrowckVisitor;
visit::walk_crate(&mut v, crate, bccx);
visit::walk_crate(&mut v as &mut Visitor<@BorrowckCtxt>, crate, bccx);

if tcx.sess.borrowck_stats() {
io::println("--- borrowck stats ---");
@@ -166,7 +166,7 @@ fn borrowck_fn(v: &mut BorrowckVisitor,
}
}

visit::walk_fn(v, fk, decl, body, sp, id, this);
visit::walk_fn(v as &mut Visitor<@BorrowckCtxt>, fk, decl, body, sp, id, this);
}

// ----------------------------------------------------------------------
12 changes: 6 additions & 6 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ pub fn check_crate(sess: Session,
method_map: method_map,
tcx: tcx,
};
visit::walk_crate(&mut v, crate, false);
visit::walk_crate(&mut v as &mut Visitor<bool>, crate, false);
sess.abort_if_errors();
}

@@ -77,7 +77,7 @@ pub fn check_item(v: &mut CheckCrateVisitor,
}
}
}
_ => visit::walk_item(v, it, false)
_ => visit::walk_item(v as &mut Visitor<bool>, it, false)
}
}

@@ -101,7 +101,7 @@ pub fn check_pat(v: &mut CheckCrateVisitor, p: @pat, _is_const: bool) {
if !is_str(a) { v.visit_expr(a, true); }
if !is_str(b) { v.visit_expr(b, true); }
}
_ => visit::walk_pat(v, p, false)
_ => visit::walk_pat(v as &mut Visitor<bool>, p, false)
}
}

@@ -216,7 +216,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
}
_ => ()
}
visit::walk_expr(v, e, is_const);
visit::walk_expr(v as &mut Visitor<bool>, e, is_const);
}

#[deriving(Clone)]
@@ -254,7 +254,7 @@ impl Visitor<env> for CheckItemRecursionVisitor {
env.sess.span_fatal(env.root_it.span, "recursive constant");
}
env.idstack.push(it.id);
visit::walk_item(self, it, env);
visit::walk_item(self as &mut Visitor<env>, it, env);
env.idstack.pop();
}

@@ -272,6 +272,6 @@ impl Visitor<env> for CheckItemRecursionVisitor {
},
_ => ()
}
visit::walk_expr(self, e, env);
visit::walk_expr(self as &mut Visitor<env>, e, env);
}
}
9 changes: 5 additions & 4 deletions src/librustc/middle/check_loop.rs
Original file line number Diff line number Diff line change
@@ -26,14 +26,15 @@ struct CheckLoopVisitor {
}

pub fn check_crate(tcx: ty::ctxt, crate: &Crate) {
visit::walk_crate(&mut CheckLoopVisitor { tcx: tcx },
let mut ctxt = CheckLoopVisitor { tcx: tcx };
visit::walk_crate(&mut ctxt as &mut Visitor<Context>,
crate,
Context { in_loop: false, can_ret: true });
}

impl Visitor<Context> for CheckLoopVisitor {
fn visit_item(&mut self, i:@item, _cx:Context) {
visit::walk_item(self, i, Context {
visit::walk_item(self as &mut Visitor<Context>, i, Context {
in_loop: false,
can_ret: true
});
@@ -66,9 +67,9 @@ impl Visitor<Context> for CheckLoopVisitor {
if !cx.can_ret {
self.tcx.sess.span_err(e.span, "`return` in block function");
}
visit::walk_expr_opt(self, oe, cx);
visit::walk_expr_opt(self as &mut Visitor<Context>, oe, cx);
}
_ => visit::walk_expr(self, e, cx)
_ => visit::walk_expr(self as &mut Visitor<Context>, e, cx)
}

}
8 changes: 4 additions & 4 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ pub fn check_crate(tcx: ty::ctxt,
moves_map: moves_map};
let mut v = CheckMatchVisitor { cx: cx };

visit::walk_crate(&mut v, crate, ());
visit::walk_crate(&mut v as &mut Visitor<()>, crate, ());

tcx.sess.abort_if_errors();
}
@@ -68,7 +68,7 @@ pub fn check_expr(v: &mut CheckMatchVisitor,
cx: @MatchCheckCtxt,
ex: @expr,
s: ()) {
visit::walk_expr(v, ex, s);
visit::walk_expr(v as &mut Visitor<()>, ex, s);
match ex.node {
expr_match(scrut, ref arms) => {
// First, check legality of move bindings.
@@ -806,7 +806,7 @@ pub fn check_local(v: &mut CheckMatchVisitor,
cx: &MatchCheckCtxt,
loc: @Local,
s: ()) {
visit::walk_local(v, loc, s);
visit::walk_local(v as &mut Visitor<()>, loc, s);
if is_refutable(cx, loc.pat) {
cx.tcx.sess.span_err(loc.pat.span,
"refutable pattern in local binding");
@@ -824,7 +824,7 @@ pub fn check_fn(v: &mut CheckMatchVisitor,
sp: span,
id: NodeId,
s: ()) {
visit::walk_fn(v, kind, decl, body, sp, id, s);
visit::walk_fn(v as &mut Visitor<()>, kind, decl, body, sp, id, s);
for input in decl.inputs.iter() {
if is_refutable(cx, input.pat) {
cx.tcx.sess.span_err(input.pat.span,
2 changes: 1 addition & 1 deletion src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ impl Visitor<()> for ConstEvalVisitor {
pub fn process_crate(crate: &ast::Crate,
tcx: ty::ctxt) {
let mut v = ConstEvalVisitor { tcx: tcx };
visit::walk_crate(&mut v, crate, ());
visit::walk_crate(&mut v as &mut Visitor<()>, crate, ());
tcx.sess.abort_if_errors();
}

8 changes: 4 additions & 4 deletions src/librustc/middle/effect.rs
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ impl Visitor<()> for EffectCheckVisitor {
self.context.unsafe_context = SafeContext
}

visit::walk_fn(self,
visit::walk_fn(&mut *self as &mut Visitor<()>,
fn_kind,
fn_decl,
block,
@@ -107,7 +107,7 @@ impl Visitor<()> for EffectCheckVisitor {
self.context.unsafe_context = UnsafeBlock(block.id)
}

visit::walk_block(self, block, ());
visit::walk_block(&mut *self as &mut Visitor<()>, block, ());

self.context.unsafe_context = old_unsafe_context
}
@@ -158,7 +158,7 @@ impl Visitor<()> for EffectCheckVisitor {
_ => {}
}

visit::walk_expr(self, expr, ());
visit::walk_expr(self as &mut Visitor<()>, expr, ());
}
}

@@ -175,5 +175,5 @@ pub fn check_crate(tcx: ty::ctxt,
context: context,
};

visit::walk_crate(&mut visitor, crate, ());
visit::walk_crate(&mut visitor as &mut Visitor<()>, crate, ());
}
4 changes: 2 additions & 2 deletions src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map)

let mut v = EntryVisitor;

visit::walk_crate(&mut v, crate, ctxt);
visit::walk_crate(&mut v as &mut Visitor<@mut EntryContext>, crate, ctxt);

configure_main(ctxt);
}
@@ -125,7 +125,7 @@ fn find_item(item: @item, ctxt: @mut EntryContext, visitor: &mut EntryVisitor) {
_ => ()
}

visit::walk_item(visitor, item, ctxt);
visit::walk_item(visitor as &mut Visitor<@mut EntryContext>, item, ctxt);
}

fn configure_main(ctxt: @mut EntryContext) {
Loading