Skip to content

Commit 35f174f

Browse files
committed
---
yaml --- r: 147572 b: refs/heads/try2 c: 9f4cfe2 h: refs/heads/master v: v3
1 parent 441a6c0 commit 35f174f

File tree

2 files changed

+19
-11
lines changed
  • branches/try2/src/librustc/middle/typeck/infer/region_inference

2 files changed

+19
-11
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: 3840d505168652cd4115b24613077ee9d571ff44
8+
refs/heads/try2: 9f4cfe2e786e3a2f47b504d4a83dcdc70f29fb2c
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/typeck/infer/region_inference/mod.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use middle::graph::{Direction, NodeIndex};
2424
use util::common::indenter;
2525
use util::ppaux::{Repr};
2626

27+
use std::cell::RefCell;
2728
use std::hashmap::{HashMap, HashSet};
2829
use std::uint;
2930
use std::vec;
@@ -88,7 +89,7 @@ type CombineMap = HashMap<TwoRegions, RegionVid>;
8889
pub struct RegionVarBindings {
8990
tcx: ty::ctxt,
9091
var_origins: ~[RegionVariableOrigin],
91-
constraints: HashMap<Constraint, SubregionOrigin>,
92+
constraints: RefCell<HashMap<Constraint, SubregionOrigin>>,
9293
lubs: CombineMap,
9394
glbs: CombineMap,
9495
skolemization_count: uint,
@@ -114,7 +115,7 @@ pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
114115
tcx: tcx,
115116
var_origins: ~[],
116117
values: None,
117-
constraints: HashMap::new(),
118+
constraints: RefCell::new(HashMap::new()),
118119
lubs: HashMap::new(),
119120
glbs: HashMap::new(),
120121
skolemization_count: 0,
@@ -157,7 +158,8 @@ impl RegionVarBindings {
157158
self.var_origins.pop();
158159
}
159160
AddConstraint(ref constraint) => {
160-
self.constraints.remove(constraint);
161+
let mut constraints = self.constraints.borrow_mut();
162+
constraints.get().remove(constraint);
161163
}
162164
AddCombination(Glb, ref regions) => {
163165
self.glbs.remove(regions);
@@ -228,7 +230,8 @@ impl RegionVarBindings {
228230

229231
debug!("RegionVarBindings: add_constraint({:?})", constraint);
230232

231-
if self.constraints.insert(constraint, origin) {
233+
let mut constraints = self.constraints.borrow_mut();
234+
if constraints.get().insert(constraint, origin) {
232235
if self.in_snapshot() {
233236
self.undo_log.push(AddConstraint(constraint));
234237
}
@@ -925,7 +928,8 @@ impl RegionVarBindings {
925928
&self,
926929
errors: &mut OptVec<RegionResolutionError>)
927930
{
928-
for (constraint, _) in self.constraints.iter() {
931+
let constraints = self.constraints.borrow();
932+
for (constraint, _) in constraints.get().iter() {
929933
let (sub, sup) = match *constraint {
930934
ConstrainVarSubVar(..) |
931935
ConstrainRegSubVar(..) |
@@ -943,7 +947,7 @@ impl RegionVarBindings {
943947

944948
debug!("ConcreteFailure: !(sub <= sup): sub={:?}, sup={:?}",
945949
sub, sup);
946-
let origin = self.constraints.get_copy(constraint);
950+
let origin = constraints.get().get_copy(constraint);
947951
errors.push(ConcreteFailure(origin, sub, sup));
948952
}
949953
}
@@ -1031,7 +1035,9 @@ impl RegionVarBindings {
10311035

10321036
fn construct_graph(&self) -> RegionGraph {
10331037
let num_vars = self.num_vars();
1034-
let num_edges = self.constraints.len();
1038+
1039+
let constraints = self.constraints.borrow();
1040+
let num_edges = constraints.get().len();
10351041

10361042
let mut graph = graph::Graph::with_capacity(num_vars + 1,
10371043
num_edges);
@@ -1041,7 +1047,7 @@ impl RegionVarBindings {
10411047
}
10421048
let dummy_idx = graph.add_node(());
10431049

1044-
for (constraint, _) in self.constraints.iter() {
1050+
for (constraint, _) in constraints.get().iter() {
10451051
match *constraint {
10461052
ConstrainVarSubVar(a_id, b_id) => {
10471053
graph.add_edge(NodeIndex(a_id.to_uint()),
@@ -1230,9 +1236,10 @@ impl RegionVarBindings {
12301236

12311237
ConstrainRegSubVar(region, _) |
12321238
ConstrainVarSubReg(_, region) => {
1239+
let constraints = this.constraints.borrow();
12331240
state.result.push(RegionAndOrigin {
12341241
region: region,
1235-
origin: this.constraints.get_copy(&edge.data)
1242+
origin: constraints.get().get_copy(&edge.data)
12361243
});
12371244
}
12381245

@@ -1252,7 +1259,8 @@ impl RegionVarBindings {
12521259
changed = false;
12531260
iteration += 1;
12541261
debug!("---- {} Iteration \\#{}", tag, iteration);
1255-
for (constraint, _) in self.constraints.iter() {
1262+
let constraints = self.constraints.borrow();
1263+
for (constraint, _) in constraints.get().iter() {
12561264
let edge_changed = body(constraint);
12571265
if edge_changed {
12581266
debug!("Updated due to constraint {}",

0 commit comments

Comments
 (0)