Skip to content

Commit f2b19cc

Browse files
committed
---
yaml --- r: 94707 b: refs/heads/try c: d5e3272 h: refs/heads/master i: 94705: e78c04d 94703: 0ad68cc v: v3
1 parent e2c9baa commit f2b19cc

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 2551344928a7ad30b2ced2b31bf6cdc2eb98554e
5+
refs/heads/try: d5e32729c9346c47f9128c5fe4b6b0aacfe1d4f4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/region.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use driver::session::Session;
2525
use middle::ty::{FreeRegion};
2626
use middle::ty;
2727

28+
use std::cell::RefCell;
2829
use std::hashmap::{HashMap, HashSet};
2930
use syntax::codemap::Span;
3031
use syntax::{ast, visit};
@@ -50,7 +51,7 @@ The region maps encode information about region relationships.
5051
necessarily how I think things ought to work
5152
*/
5253
pub struct RegionMaps {
53-
priv scope_map: HashMap<ast::NodeId, ast::NodeId>,
54+
priv scope_map: RefCell<HashMap<ast::NodeId, ast::NodeId>>,
5455
priv free_region_map: HashMap<FreeRegion, ~[FreeRegion]>,
5556
priv cleanup_scopes: HashSet<ast::NodeId>
5657
}
@@ -93,7 +94,8 @@ impl RegionMaps {
9394
debug!("record_parent(sub={:?}, sup={:?})", sub, sup);
9495
assert!(sub != sup);
9596

96-
self.scope_map.insert(sub, sup);
97+
let mut scope_map = self.scope_map.borrow_mut();
98+
scope_map.get().insert(sub, sup);
9799
}
98100

99101
pub fn record_cleanup_scope(&mut self, scope_id: ast::NodeId) {
@@ -108,13 +110,15 @@ impl RegionMaps {
108110
pub fn opt_encl_scope(&self, id: ast::NodeId) -> Option<ast::NodeId> {
109111
//! Returns the narrowest scope that encloses `id`, if any.
110112
111-
self.scope_map.find(&id).map(|x| *x)
113+
let scope_map = self.scope_map.borrow();
114+
scope_map.get().find(&id).map(|x| *x)
112115
}
113116

114117
pub fn encl_scope(&self, id: ast::NodeId) -> ast::NodeId {
115118
//! Returns the narrowest scope that encloses `id`, if any.
116119
117-
match self.scope_map.find(&id) {
120+
let scope_map = self.scope_map.borrow();
121+
match scope_map.get().find(&id) {
118122
Some(&r) => r,
119123
None => { fail!("No enclosing scope for id {:?}", id); }
120124
}
@@ -157,7 +161,8 @@ impl RegionMaps {
157161

158162
let mut s = subscope;
159163
while superscope != s {
160-
match self.scope_map.find(&s) {
164+
let scope_map = self.scope_map.borrow();
165+
match scope_map.get().find(&s) {
161166
None => {
162167
debug!("is_subscope_of({:?}, {:?}, s={:?})=false",
163168
subscope, superscope, s);
@@ -298,7 +303,8 @@ impl RegionMaps {
298303
let mut result = ~[scope];
299304
let mut scope = scope;
300305
loop {
301-
match this.scope_map.find(&scope) {
306+
let scope_map = this.scope_map.borrow();
307+
match scope_map.get().find(&scope) {
302308
None => return result,
303309
Some(&superscope) => {
304310
result.push(superscope);
@@ -497,7 +503,7 @@ pub fn resolve_crate(sess: Session,
497503
crate: &ast::Crate) -> @mut RegionMaps
498504
{
499505
let region_maps = @mut RegionMaps {
500-
scope_map: HashMap::new(),
506+
scope_map: RefCell::new(HashMap::new()),
501507
free_region_map: HashMap::new(),
502508
cleanup_scopes: HashSet::new(),
503509
};

0 commit comments

Comments
 (0)