@@ -6,6 +6,7 @@ import ast::path_to_str;
6
6
import ast:: respan;
7
7
import ast:: spanned;
8
8
import syntax:: walk;
9
+ import syntax:: visit;
9
10
import metadata:: csearch;
10
11
import driver:: session;
11
12
import util:: common;
@@ -1211,49 +1212,51 @@ fn gather_locals(&@crate_ctxt ccx, &ast::_fn f,
1211
1212
f. decl. inputs. ( i) . ident, some[ ty:: t] ( arg. ty) ) ;
1212
1213
i += 1 u;
1213
1214
}
1214
- // Add explicitly-declared locals.
1215
1215
1216
- fn visit_local_pre( @crate_ctxt ccx, @ty:: unify:: var_bindings vb,
1217
- hashmap[ ast:: node_id, int] locals,
1218
- hashmap[ ast:: node_id, ast:: ident] local_names,
1219
- @mutable int nvi, & @ast:: local local) {
1216
+ // Add explicitly-declared locals.
1217
+ fn visit_local( @crate_ctxt ccx, @ty:: unify:: var_bindings vb,
1218
+ hashmap[ ast:: node_id, int] locals,
1219
+ hashmap[ ast:: node_id, ast:: ident] local_names,
1220
+ @mutable int nvi, & @ast:: local local,
1221
+ & ( ) e, & visit:: vt[ ( ) ] v) {
1220
1222
alt ( local. node. ty) {
1221
1223
case ( none) {
1222
1224
// Auto slot.
1223
-
1224
1225
assign( ccx. tcx, vb, locals, local_names, nvi, local. node. id,
1225
1226
local. node. ident, none[ ty:: t] ) ;
1226
1227
}
1227
1228
case ( some( ?ast_ty) ) {
1228
1229
// Explicitly typed slot.
1229
-
1230
1230
auto local_ty = ast_ty_to_ty_crate( ccx, ast_ty) ;
1231
1231
assign( ccx. tcx, vb, locals, local_names, nvi, local. node. id,
1232
1232
local. node. ident, some[ ty:: t] ( local_ty) ) ;
1233
1233
}
1234
1234
}
1235
+ visit:: visit_local( local, e, v) ;
1235
1236
}
1236
- // Add pattern bindings.
1237
1237
1238
- fn visit_pat_pre( @crate_ctxt ccx, @ty:: unify:: var_bindings vb,
1239
- hashmap[ ast:: node_id, int] locals,
1240
- hashmap[ ast:: node_id, ast:: ident] local_names,
1241
- @mutable int nvi, & @ast:: pat p) {
1238
+ // Add pattern bindings.
1239
+ fn visit_pat( @crate_ctxt ccx, @ty:: unify:: var_bindings vb,
1240
+ hashmap[ ast:: node_id, int] locals,
1241
+ hashmap[ ast:: node_id, ast:: ident] local_names,
1242
+ @mutable int nvi, & @ast:: pat p,
1243
+ & ( ) e, & visit:: vt[ ( ) ] v) {
1242
1244
alt ( p. node) {
1243
1245
case ( ast:: pat_bind( ?ident) ) {
1244
1246
assign( ccx. tcx, vb, locals, local_names, nvi,
1245
1247
p. id, ident, none[ ty:: t] ) ;
1246
1248
}
1247
1249
case ( _) { /* no-op * / }
1248
1250
}
1251
+ visit:: visit_pat( p, e, v) ;
1249
1252
}
1250
1253
auto visit =
1251
- rec( visit_local_pre =bind visit_local_pre ( ccx, vb, locals, local_names,
1252
- nvi , _) ,
1253
- visit_pat_pre =bind visit_pat_pre ( ccx, vb, locals, local_names,
1254
- nvi , _)
1255
- with walk :: default_visitor( ) ) ;
1256
- walk :: walk_block ( visit , f. body) ;
1254
+ @ rec( visit_local =bind visit_local ( ccx, vb, locals, local_names,
1255
+ nvi , _ , _ , _) ,
1256
+ visit_pat =bind visit_pat ( ccx, vb, locals, local_names,
1257
+ nvi , _ , _ , _)
1258
+ with * visit :: default_visitor( ) ) ;
1259
+ visit :: visit_block ( f. body, ( ) , visit :: mk_vt ( visit ) ) ;
1257
1260
ret rec( var_bindings=vb,
1258
1261
locals=locals,
1259
1262
local_names=local_names,
0 commit comments