Skip to content

Commit c5249d9

Browse files
committed
---
yaml --- r: 147577 b: refs/heads/try2 c: 1095e63 h: refs/heads/master i: 147575: e26152c v: v3
1 parent 325d6fd commit c5249d9

File tree

2 files changed

+16
-9
lines changed
  • branches/try2/src/librustc/middle/typeck/infer/region_inference

2 files changed

+16
-9
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: 38d5072018d63733170661ff1cbac4a8709c1788
8+
refs/heads/try2: 1095e635340fa2e305a15bec3058c2dad62eb490
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: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ pub struct RegionVarBindings {
107107

108108
// This contains the results of inference. It begins as an empty
109109
// option and only acquires a value after inference is complete.
110-
values: Option<~[VarValue]>,
110+
values: RefCell<Option<~[VarValue]>>,
111111
}
112112

113113
pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
114114
RegionVarBindings {
115115
tcx: tcx,
116116
var_origins: ~[],
117-
values: None,
117+
values: RefCell::new(None),
118118
constraints: RefCell::new(HashMap::new()),
119119
lubs: RefCell::new(HashMap::new()),
120120
glbs: RefCell::new(HashMap::new()),
@@ -236,11 +236,16 @@ impl RegionVarBindings {
236236
ReLateBound(binder_id, BrFresh(sc))
237237
}
238238

239+
fn values_are_none(&self) -> bool {
240+
let values = self.values.borrow();
241+
values.get().is_none()
242+
}
243+
239244
pub fn add_constraint(&mut self,
240245
constraint: Constraint,
241246
origin: SubregionOrigin) {
242247
// cannot add constraints once regions are resolved
243-
assert!(self.values.is_none());
248+
assert!(self.values_are_none());
244249

245250
debug!("RegionVarBindings: add_constraint({:?})", constraint);
246251

@@ -260,7 +265,7 @@ impl RegionVarBindings {
260265
sub: Region,
261266
sup: Region) {
262267
// cannot add constraints once regions are resolved
263-
assert!(self.values.is_none());
268+
assert!(self.values_are_none());
264269

265270
debug!("RegionVarBindings: make_subregion({:?}, {:?})", sub, sup);
266271
match (sub, sup) {
@@ -295,7 +300,7 @@ impl RegionVarBindings {
295300
b: Region)
296301
-> Region {
297302
// cannot add constraints once regions are resolved
298-
assert!(self.values.is_none());
303+
assert!(self.values_are_none());
299304

300305
debug!("RegionVarBindings: lub_regions({:?}, {:?})", a, b);
301306
match (a, b) {
@@ -318,7 +323,7 @@ impl RegionVarBindings {
318323
b: Region)
319324
-> Region {
320325
// cannot add constraints once regions are resolved
321-
assert!(self.values.is_none());
326+
assert!(self.values_are_none());
322327

323328
debug!("RegionVarBindings: glb_regions({:?}, {:?})", a, b);
324329
match (a, b) {
@@ -337,7 +342,8 @@ impl RegionVarBindings {
337342
}
338343

339344
pub fn resolve_var(&mut self, rid: RegionVid) -> ty::Region {
340-
let v = match self.values {
345+
let values = self.values.borrow();
346+
let v = match *values.get() {
341347
None => self.tcx.sess.span_bug(
342348
self.var_origins[rid.to_uint()].span(),
343349
format!("Attempt to resolve region variable before values have \
@@ -514,7 +520,8 @@ impl RegionVarBindings {
514520
debug!("RegionVarBindings: resolve_regions()");
515521
let mut errors = opt_vec::Empty;
516522
let v = self.infer_variable_values(&mut errors);
517-
self.values = Some(v);
523+
let mut values = self.values.borrow_mut();
524+
*values.get() = Some(v);
518525
errors
519526
}
520527
}

0 commit comments

Comments
 (0)