@@ -197,13 +197,13 @@ pub type map = @RefCell<HashMap<NodeId, ast_node>>;
197
197
198
198
pub struct Ctx {
199
199
map : map ,
200
- path : path ,
200
+ path : RefCell < path > ,
201
201
diag : @SpanHandler ,
202
202
}
203
203
204
204
impl Ctx {
205
205
fn extend ( & self , elt : path_elt ) -> @path {
206
- @vec:: append ( self . path. clone ( ) , [ elt ] )
206
+ @vec:: append ( self . path. get ( ) , [ elt ] )
207
207
}
208
208
209
209
fn map_method ( & mut self ,
@@ -275,12 +275,18 @@ impl Ctx {
275
275
map. get ( ) . insert ( a. id , node_arg ( a. pat ) ) ;
276
276
}
277
277
match * fk {
278
- visit:: fk_method( name, _, _) => { self . path . push ( path_name ( name) ) }
278
+ visit:: fk_method( name, _, _) => {
279
+ let mut path = self . path . borrow_mut ( ) ;
280
+ path. get ( ) . push ( path_name ( name) )
281
+ }
279
282
_ => { }
280
283
}
281
284
visit:: walk_fn ( self , fk, decl, body, sp, id, ( ) ) ;
282
285
match * fk {
283
- visit:: fk_method( ..) => { self . path . pop ( ) ; }
286
+ visit:: fk_method( ..) => {
287
+ let mut path = self . path . borrow_mut ( ) ;
288
+ path. get ( ) . pop ( ) ;
289
+ }
284
290
_ => { }
285
291
}
286
292
}
@@ -320,7 +326,7 @@ impl Ctx {
320
326
impl Visitor < ( ) > for Ctx {
321
327
fn visit_item ( & mut self , i: @item, _: ( ) ) {
322
328
// clone is FIXME #2543
323
- let item_path = @self . path . clone ( ) ;
329
+ let item_path = @self . path . get ( ) ;
324
330
{
325
331
let mut map = self . map . borrow_mut ( ) ;
326
332
map. get ( ) . insert ( i. id , node_item ( i, item_path) ) ;
@@ -338,7 +344,8 @@ impl Visitor<()> for Ctx {
338
344
self . map_method ( impl_did, extended, * m, false )
339
345
}
340
346
341
- self . path . push ( elt) ;
347
+ let mut path = self . path . borrow_mut ( ) ;
348
+ path. get ( ) . push ( elt) ;
342
349
}
343
350
item_enum( ref enum_definition, _) => {
344
351
for & v in enum_definition. variants . iter ( ) {
@@ -366,7 +373,7 @@ impl Visitor<()> for Ctx {
366
373
// Anonymous extern
367
374
// mods go in the
368
375
// parent scope.
369
- @self . path . clone ( )
376
+ @self . path . get ( )
370
377
) ) ;
371
378
}
372
379
}
@@ -401,13 +408,19 @@ impl Visitor<()> for Ctx {
401
408
402
409
match i. node {
403
410
item_mod( _) | item_foreign_mod( _) => {
404
- self . path . push ( path_mod ( i. ident ) ) ;
411
+ let mut path = self . path . borrow_mut ( ) ;
412
+ path. get ( ) . push ( path_mod ( i. ident ) ) ;
405
413
}
406
414
item_impl( ..) => { } // this was guessed above.
407
- _ => self . path . push ( path_name ( i. ident ) )
415
+ _ => {
416
+ let mut path = self . path . borrow_mut ( ) ;
417
+ path. get ( ) . push ( path_name ( i. ident ) )
418
+ }
408
419
}
409
420
visit:: walk_item ( self , i, ( ) ) ;
410
- self . path . pop ( ) ;
421
+
422
+ let mut path = self . path . borrow_mut ( ) ;
423
+ path. get ( ) . pop ( ) ;
411
424
}
412
425
413
426
fn visit_pat ( & mut self , pat : & Pat , _: ( ) ) {
@@ -445,7 +458,7 @@ impl Visitor<()> for Ctx {
445
458
pub fn map_crate ( diag : @SpanHandler , c : & Crate ) -> map {
446
459
let cx = @mut Ctx {
447
460
map : @RefCell :: new ( HashMap :: new ( ) ) ,
448
- path : ~[ ] ,
461
+ path : RefCell :: new ( ~[ ] ) ,
449
462
diag : diag,
450
463
} ;
451
464
visit:: walk_crate ( cx, c, ( ) ) ;
@@ -464,7 +477,7 @@ pub fn map_decoded_item(diag: @SpanHandler,
464
477
// starting from 0.
465
478
let cx = @mut Ctx {
466
479
map : map,
467
- path : path. clone ( ) ,
480
+ path : RefCell :: new ( path. clone ( ) ) ,
468
481
diag : diag,
469
482
} ;
470
483
0 commit comments