@@ -26,9 +26,11 @@ use std::ops::{BitOr, BitAnd};
2626use std:: result:: { Result } ;
2727use syntax:: ast;
2828use syntax:: ast_map;
29- use syntax:: oldvisit;
3029use syntax:: codemap:: span;
3130use syntax:: parse:: token;
31+ use syntax:: visit;
32+ use syntax:: visit:: { Visitor , fn_kind} ;
33+ use syntax:: ast:: { fn_decl, Block , NodeId } ;
3234
3335macro_rules! if_ok(
3436 ( $inp: expr) => (
@@ -59,6 +61,15 @@ impl Clone for LoanDataFlowOperator {
5961
6062pub type LoanDataFlow = DataFlowContext < LoanDataFlowOperator > ;
6163
64+ struct BorrowckVisitor ;
65+
66+ impl Visitor < @BorrowckCtxt > for BorrowckVisitor {
67+ fn visit_fn ( & mut self , fk : & fn_kind , fd : & fn_decl ,
68+ b : & Block , s : span , n : NodeId , e : @BorrowckCtxt ) {
69+ borrowck_fn ( self , fk, fd, b, s, n, e) ;
70+ }
71+ }
72+
6273pub fn check_crate (
6374 tcx : ty:: ctxt ,
6475 method_map : typeck:: method_map ,
@@ -86,9 +97,8 @@ pub fn check_crate(
8697 }
8798 } ;
8899
89- let v = oldvisit:: mk_vt ( @oldvisit:: Visitor { visit_fn : borrowck_fn,
90- ..* oldvisit:: default_visitor ( ) } ) ;
91- oldvisit:: visit_crate ( crate , ( bccx, v) ) ;
100+ let mut v = BorrowckVisitor ;
101+ visit:: walk_crate ( & mut v, crate , bccx) ;
92102
93103 if tcx. sess . borrowck_stats ( ) {
94104 io:: println ( "--- borrowck stats ---" ) ;
@@ -113,21 +123,21 @@ pub fn check_crate(
113123 }
114124}
115125
116- fn borrowck_fn ( fk : & oldvisit:: fn_kind ,
126+ fn borrowck_fn ( v : & mut BorrowckVisitor ,
127+ fk : & visit:: fn_kind ,
117128 decl : & ast:: fn_decl ,
118129 body : & ast:: Block ,
119130 sp : span ,
120131 id : ast:: NodeId ,
121- ( this, v) : ( @BorrowckCtxt ,
122- oldvisit:: vt < @BorrowckCtxt > ) ) {
132+ this : @BorrowckCtxt ) {
123133 match fk {
124- & oldvisit :: fk_anon( * ) |
125- & oldvisit :: fk_fn_block( * ) => {
134+ & visit :: fk_anon( * ) |
135+ & visit :: fk_fn_block( * ) => {
126136 // Closures are checked as part of their containing fn item.
127137 }
128138
129- & oldvisit :: fk_item_fn( * ) |
130- & oldvisit :: fk_method( * ) => {
139+ & visit :: fk_item_fn( * ) |
140+ & visit :: fk_method( * ) => {
131141 debug ! ( "borrowck_fn(id=%?)" , id) ;
132142
133143 // Check the body of fn items.
@@ -156,7 +166,7 @@ fn borrowck_fn(fk: &oldvisit::fn_kind,
156166 }
157167 }
158168
159- oldvisit :: visit_fn ( fk, decl, body, sp, id, ( this, v ) ) ;
169+ visit :: walk_fn ( v , fk, decl, body, sp, id, this) ;
160170}
161171
162172// ----------------------------------------------------------------------
0 commit comments