Skip to content

Commit 587cc56

Browse files
committed
---
yaml --- r: 147659 b: refs/heads/try2 c: d5e3272 h: refs/heads/master i: 147657: 2addd92 147655: 23c2a4c v: v3
1 parent c38ef24 commit 587cc56

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2551344928a7ad30b2ced2b31bf6cdc2eb98554e
8+
refs/heads/try2: d5e32729c9346c47f9128c5fe4b6b0aacfe1d4f4
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)