Skip to content

Commit f759fe1

Browse files
committed
librustc: De-@mut cleanup_scopes in the region maps
1 parent 0c3950d commit f759fe1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/librustc/middle/region.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The region maps encode information about region relationships.
5353
pub struct RegionMaps {
5454
priv scope_map: RefCell<HashMap<ast::NodeId, ast::NodeId>>,
5555
priv free_region_map: RefCell<HashMap<FreeRegion, ~[FreeRegion]>>,
56-
priv cleanup_scopes: HashSet<ast::NodeId>
56+
priv cleanup_scopes: RefCell<HashSet<ast::NodeId>>,
5757
}
5858

5959
#[deriving(Clone)]
@@ -105,7 +105,8 @@ impl RegionMaps {
105105
//! not know which operators are overloaded until that point,
106106
//! and only overloaded operators result in cleanup scopes.
107107
108-
self.cleanup_scopes.insert(scope_id);
108+
let mut cleanup_scopes = self.cleanup_scopes.borrow_mut();
109+
cleanup_scopes.get().insert(scope_id);
109110
}
110111

111112
pub fn opt_encl_scope(&self, id: ast::NodeId) -> Option<ast::NodeId> {
@@ -126,14 +127,16 @@ impl RegionMaps {
126127
}
127128

128129
pub fn is_cleanup_scope(&self, scope_id: ast::NodeId) -> bool {
129-
self.cleanup_scopes.contains(&scope_id)
130+
let cleanup_scopes = self.cleanup_scopes.borrow();
131+
cleanup_scopes.get().contains(&scope_id)
130132
}
131133

132134
pub fn cleanup_scope(&self, expr_id: ast::NodeId) -> ast::NodeId {
133135
//! Returns the scope when temps in expr will be cleaned up
134136
135137
let mut id = self.encl_scope(expr_id);
136-
while !self.cleanup_scopes.contains(&id) {
138+
let cleanup_scopes = self.cleanup_scopes.borrow();
139+
while !cleanup_scopes.get().contains(&id) {
137140
id = self.encl_scope(id);
138141
}
139142
return id;
@@ -507,7 +510,7 @@ pub fn resolve_crate(sess: Session,
507510
let region_maps = @mut RegionMaps {
508511
scope_map: RefCell::new(HashMap::new()),
509512
free_region_map: RefCell::new(HashMap::new()),
510-
cleanup_scopes: HashSet::new(),
513+
cleanup_scopes: RefCell::new(HashSet::new()),
511514
};
512515
let cx = Context {parent: None,
513516
var_parent: None};

0 commit comments

Comments
 (0)