@@ -226,7 +226,9 @@ struct env {
226
226
idstack : @mut ~[ NodeId ]
227
227
}
228
228
229
- struct CheckItemRecursionVisitor ;
229
+ struct CheckItemRecursionVisitor {
230
+ env : env ,
231
+ }
230
232
231
233
// Make sure a const item doesn't recursively refer to itself
232
234
// FIXME: Should use the dependency graph when it's available (#1356)
@@ -242,34 +244,34 @@ pub fn check_item_recursion(sess: Session,
242
244
idstack : @mut ~[ ]
243
245
} ;
244
246
245
- let mut visitor = CheckItemRecursionVisitor ;
246
- visitor. visit_item ( it, env ) ;
247
+ let mut visitor = CheckItemRecursionVisitor { env : env } ;
248
+ visitor. visit_item ( it, ( ) ) ;
247
249
}
248
250
249
- impl Visitor < env > for CheckItemRecursionVisitor {
250
- fn visit_item ( & mut self , it: @item, env : env ) {
251
- if env. idstack . iter ( ) . any ( |x| x == & ( it. id ) ) {
252
- env. sess . span_fatal ( env. root_it . span , "recursive constant" ) ;
251
+ impl Visitor < ( ) > for CheckItemRecursionVisitor {
252
+ fn visit_item ( & mut self , it : @item, _ : ( ) ) {
253
+ if self . env . idstack . iter ( ) . any ( |x| x == & ( it. id ) ) {
254
+ self . env . sess . span_fatal ( self . env . root_it . span , "recursive constant" ) ;
253
255
}
254
- env. idstack . push ( it. id ) ;
255
- visit:: walk_item ( self , it, env ) ;
256
- env. idstack . pop ( ) ;
256
+ self . env . idstack . push ( it. id ) ;
257
+ visit:: walk_item ( self , it, ( ) ) ;
258
+ self . env . idstack . pop ( ) ;
257
259
}
258
260
259
- fn visit_expr ( & mut self , e : @Expr , env : env ) {
261
+ fn visit_expr ( & mut self , e : @Expr , _ : ( ) ) {
260
262
match e. node {
261
- ExprPath ( * ) => match env. def_map . find ( & e. id ) {
263
+ ExprPath ( * ) => match self . env . def_map . find ( & e. id ) {
262
264
Some ( & DefStatic ( def_id, _) ) if ast_util:: is_local ( def_id) =>
263
- match env. ast_map . get_copy ( & def_id. node ) {
265
+ match self . env . ast_map . get_copy ( & def_id. node ) {
264
266
ast_map:: node_item( it, _) => {
265
- self . visit_item ( it, env ) ;
267
+ self . visit_item ( it, ( ) ) ;
266
268
}
267
269
_ => fail ! ( "const not bound to an item" )
268
270
} ,
269
271
_ => ( )
270
272
} ,
271
273
_ => ( )
272
274
}
273
- visit:: walk_expr ( self , e, env ) ;
275
+ visit:: walk_expr ( self , e, ( ) ) ;
274
276
}
275
277
}
0 commit comments