@@ -226,7 +226,9 @@ struct env {
226226 idstack : @mut ~[ NodeId ]
227227}
228228
229- struct CheckItemRecursionVisitor ;
229+ struct CheckItemRecursionVisitor {
230+ env : env ,
231+ }
230232
231233// Make sure a const item doesn't recursively refer to itself
232234// FIXME: Should use the dependency graph when it's available (#1356)
@@ -242,34 +244,34 @@ pub fn check_item_recursion(sess: Session,
242244 idstack : @mut ~[ ]
243245 } ;
244246
245- let mut visitor = CheckItemRecursionVisitor ;
246- visitor. visit_item ( it, env ) ;
247+ let mut visitor = CheckItemRecursionVisitor { env : env } ;
248+ visitor. visit_item ( it, ( ) ) ;
247249}
248250
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" ) ;
253255 }
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 ( ) ;
257259 }
258260
259- fn visit_expr ( & mut self , e : @Expr , env : env ) {
261+ fn visit_expr ( & mut self , e : @Expr , _ : ( ) ) {
260262 match e. node {
261- ExprPath ( * ) => match env. def_map . find ( & e. id ) {
263+ ExprPath ( * ) => match self . env . def_map . find ( & e. id ) {
262264 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 ) {
264266 ast_map:: node_item( it, _) => {
265- self . visit_item ( it, env ) ;
267+ self . visit_item ( it, ( ) ) ;
266268 }
267269 _ => fail ! ( "const not bound to an item" )
268270 } ,
269271 _ => ( )
270272 } ,
271273 _ => ( )
272274 }
273- visit:: walk_expr ( self , e, env ) ;
275+ visit:: walk_expr ( self , e, ( ) ) ;
274276 }
275277}
0 commit comments