18
18
*/
19
19
20
20
use driver:: session:: Session ;
21
- use std:: cell:: RefCell ;
22
21
use std:: vec_ng:: Vec ;
23
22
use util:: nodemap:: NodeMap ;
24
23
use syntax:: ast;
@@ -42,7 +41,7 @@ fn lifetime_show(lt_name: &ast::Name) -> token::InternedString {
42
41
43
42
struct LifetimeContext < ' a > {
44
43
sess : & ' a Session ,
45
- named_region_map : @ RefCell < NamedRegionMap > ,
44
+ named_region_map : NamedRegionMap ,
46
45
}
47
46
48
47
enum ScopeChain < ' a > {
@@ -60,10 +59,10 @@ enum ScopeChain<'a> {
60
59
61
60
type Scope < ' a > = & ' a ScopeChain < ' a > ;
62
61
63
- pub fn krate ( sess : & Session , krate : & ast:: Crate ) -> @ RefCell < NamedRegionMap > {
62
+ pub fn krate ( sess : & Session , krate : & ast:: Crate ) -> NamedRegionMap {
64
63
let mut ctxt = LifetimeContext {
65
64
sess : sess,
66
- named_region_map : @ RefCell :: new ( NodeMap :: new ( ) )
65
+ named_region_map : NodeMap :: new ( )
67
66
} ;
68
67
visit:: walk_crate ( & mut ctxt, krate, & RootScope ) ;
69
68
sess. abort_if_errors ( ) ;
@@ -236,7 +235,7 @@ impl<'a> LifetimeContext<'a> {
236
235
debug ! ( "popping fn scope id={} due to fn item/method" , n) ;
237
236
}
238
237
239
- fn resolve_lifetime_ref ( & self ,
238
+ fn resolve_lifetime_ref ( & mut self ,
240
239
lifetime_ref : & ast:: Lifetime ,
241
240
scope : Scope ) {
242
241
// Walk up the scope chain, tracking the number of fn scopes
@@ -292,7 +291,7 @@ impl<'a> LifetimeContext<'a> {
292
291
self . unresolved_lifetime_ref ( lifetime_ref) ;
293
292
}
294
293
295
- fn resolve_free_lifetime_ref ( & self ,
294
+ fn resolve_free_lifetime_ref ( & mut self ,
296
295
scope_id : ast:: NodeId ,
297
296
lifetime_ref : & ast:: Lifetime ,
298
297
scope : Scope ) {
@@ -373,7 +372,7 @@ impl<'a> LifetimeContext<'a> {
373
372
}
374
373
}
375
374
376
- fn insert_lifetime ( & self ,
375
+ fn insert_lifetime ( & mut self ,
377
376
lifetime_ref : & ast:: Lifetime ,
378
377
def : ast:: DefRegion ) {
379
378
if lifetime_ref. id == ast:: DUMMY_NODE_ID {
@@ -386,8 +385,7 @@ impl<'a> LifetimeContext<'a> {
386
385
lifetime_to_str( lifetime_ref) ,
387
386
lifetime_ref. id,
388
387
def) ;
389
- let mut named_region_map = self . named_region_map . borrow_mut ( ) ;
390
- named_region_map. get ( ) . insert ( lifetime_ref. id , def) ;
388
+ self . named_region_map . insert ( lifetime_ref. id , def) ;
391
389
}
392
390
}
393
391
0 commit comments