Skip to content

Commit df66441

Browse files
committed
Port typeck/check/vtable.rs from oldvisit to <V:Visitor> trait API.
1 parent da88f69 commit df66441

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/librustc/middle/typeck/check/vtable.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ use syntax::ast;
2929
use syntax::ast_util;
3030
use syntax::codemap::span;
3131
use syntax::print::pprust::expr_to_str;
32-
use syntax::oldvisit;
32+
use syntax::visit;
33+
use syntax::visit::Visitor;
3334

3435
// vtable resolution looks for places where trait bounds are
3536
// substituted in and figures out which vtable is used. There is some
@@ -712,11 +713,11 @@ pub fn early_resolve_expr(ex: @ast::expr,
712713
}
713714
}
714715

715-
fn resolve_expr(ex: @ast::expr,
716-
(fcx, v): (@mut FnCtxt,
717-
oldvisit::vt<@mut FnCtxt>)) {
716+
fn resolve_expr(v: &mut VtableResolveVisitor,
717+
ex: @ast::expr,
718+
fcx: @mut FnCtxt) {
718719
early_resolve_expr(ex, fcx, false);
719-
oldvisit::visit_expr(ex, (fcx, v));
720+
visit::walk_expr(v, ex, fcx);
720721
}
721722

722723
pub fn resolve_impl(ccx: @mut CrateCtxt, impl_item: @ast::item) {
@@ -763,12 +764,20 @@ pub fn resolve_impl(ccx: @mut CrateCtxt, impl_item: @ast::item) {
763764
}
764765
}
765766

767+
struct VtableResolveVisitor;
768+
769+
impl visit::Visitor<@mut FnCtxt> for VtableResolveVisitor {
770+
fn visit_expr(&mut self, ex:@ast::expr, e:@mut FnCtxt) {
771+
resolve_expr(self, ex, e);
772+
}
773+
fn visit_item(&mut self, _:@ast::item, _:@mut FnCtxt) {
774+
// no-op
775+
}
776+
}
777+
766778
// Detect points where a trait-bounded type parameter is
767779
// instantiated, resolve the impls for the parameters.
768780
pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::Block) {
769-
oldvisit::visit_block(bl, (fcx, oldvisit::mk_vt(@oldvisit::Visitor {
770-
visit_expr: resolve_expr,
771-
visit_item: |_,_| {},
772-
.. *oldvisit::default_visitor()
773-
})));
781+
let mut visitor = VtableResolveVisitor;
782+
visit::walk_block(&mut visitor, bl, fcx);
774783
}

0 commit comments

Comments
 (0)