@@ -26,9 +26,11 @@ use std::ops::{BitOr, BitAnd};
26
26
use std:: result:: { Result } ;
27
27
use syntax:: ast;
28
28
use syntax:: ast_map;
29
- use syntax:: oldvisit;
30
29
use syntax:: codemap:: span;
31
30
use syntax:: parse:: token;
31
+ use syntax:: visit;
32
+ use syntax:: visit:: { Visitor , fn_kind} ;
33
+ use syntax:: ast:: { fn_decl, Block , NodeId } ;
32
34
33
35
macro_rules! if_ok(
34
36
( $inp: expr) => (
@@ -59,6 +61,15 @@ impl Clone for LoanDataFlowOperator {
59
61
60
62
pub type LoanDataFlow = DataFlowContext < LoanDataFlowOperator > ;
61
63
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
+
62
73
pub fn check_crate (
63
74
tcx : ty:: ctxt ,
64
75
method_map : typeck:: method_map ,
@@ -86,9 +97,8 @@ pub fn check_crate(
86
97
}
87
98
} ;
88
99
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) ;
92
102
93
103
if tcx. sess . borrowck_stats ( ) {
94
104
io:: println ( "--- borrowck stats ---" ) ;
@@ -113,21 +123,21 @@ pub fn check_crate(
113
123
}
114
124
}
115
125
116
- fn borrowck_fn ( fk : & oldvisit:: fn_kind ,
126
+ fn borrowck_fn ( v : & mut BorrowckVisitor ,
127
+ fk : & visit:: fn_kind ,
117
128
decl : & ast:: fn_decl ,
118
129
body : & ast:: Block ,
119
130
sp : span ,
120
131
id : ast:: NodeId ,
121
- ( this, v) : ( @BorrowckCtxt ,
122
- oldvisit:: vt < @BorrowckCtxt > ) ) {
132
+ this : @BorrowckCtxt ) {
123
133
match fk {
124
- & oldvisit :: fk_anon( * ) |
125
- & oldvisit :: fk_fn_block( * ) => {
134
+ & visit :: fk_anon( * ) |
135
+ & visit :: fk_fn_block( * ) => {
126
136
// Closures are checked as part of their containing fn item.
127
137
}
128
138
129
- & oldvisit :: fk_item_fn( * ) |
130
- & oldvisit :: fk_method( * ) => {
139
+ & visit :: fk_item_fn( * ) |
140
+ & visit :: fk_method( * ) => {
131
141
debug ! ( "borrowck_fn(id=%?)" , id) ;
132
142
133
143
// Check the body of fn items.
@@ -156,7 +166,7 @@ fn borrowck_fn(fk: &oldvisit::fn_kind,
156
166
}
157
167
}
158
168
159
- oldvisit :: visit_fn ( fk, decl, body, sp, id, ( this, v ) ) ;
169
+ visit :: walk_fn ( v , fk, decl, body, sp, id, this) ;
160
170
}
161
171
162
172
// ----------------------------------------------------------------------
0 commit comments