@@ -107,14 +107,14 @@ pub struct RegionVarBindings {
107
107
108
108
// This contains the results of inference. It begins as an empty
109
109
// option and only acquires a value after inference is complete.
110
- values : Option < ~[ VarValue ] > ,
110
+ values : RefCell < Option < ~[ VarValue ] > > ,
111
111
}
112
112
113
113
pub fn RegionVarBindings ( tcx : ty:: ctxt ) -> RegionVarBindings {
114
114
RegionVarBindings {
115
115
tcx : tcx,
116
116
var_origins : ~[ ] ,
117
- values : None ,
117
+ values : RefCell :: new ( None ) ,
118
118
constraints : RefCell :: new ( HashMap :: new ( ) ) ,
119
119
lubs : RefCell :: new ( HashMap :: new ( ) ) ,
120
120
glbs : RefCell :: new ( HashMap :: new ( ) ) ,
@@ -236,11 +236,16 @@ impl RegionVarBindings {
236
236
ReLateBound ( binder_id, BrFresh ( sc) )
237
237
}
238
238
239
+ fn values_are_none ( & self ) -> bool {
240
+ let values = self . values . borrow ( ) ;
241
+ values. get ( ) . is_none ( )
242
+ }
243
+
239
244
pub fn add_constraint ( & mut self ,
240
245
constraint : Constraint ,
241
246
origin : SubregionOrigin ) {
242
247
// cannot add constraints once regions are resolved
243
- assert ! ( self . values . is_none ( ) ) ;
248
+ assert ! ( self . values_are_none ( ) ) ;
244
249
245
250
debug ! ( "RegionVarBindings: add_constraint({:?})" , constraint) ;
246
251
@@ -260,7 +265,7 @@ impl RegionVarBindings {
260
265
sub : Region ,
261
266
sup : Region ) {
262
267
// cannot add constraints once regions are resolved
263
- assert ! ( self . values . is_none ( ) ) ;
268
+ assert ! ( self . values_are_none ( ) ) ;
264
269
265
270
debug ! ( "RegionVarBindings: make_subregion({:?}, {:?})" , sub, sup) ;
266
271
match ( sub, sup) {
@@ -295,7 +300,7 @@ impl RegionVarBindings {
295
300
b : Region )
296
301
-> Region {
297
302
// cannot add constraints once regions are resolved
298
- assert ! ( self . values . is_none ( ) ) ;
303
+ assert ! ( self . values_are_none ( ) ) ;
299
304
300
305
debug ! ( "RegionVarBindings: lub_regions({:?}, {:?})" , a, b) ;
301
306
match ( a, b) {
@@ -318,7 +323,7 @@ impl RegionVarBindings {
318
323
b : Region )
319
324
-> Region {
320
325
// cannot add constraints once regions are resolved
321
- assert ! ( self . values . is_none ( ) ) ;
326
+ assert ! ( self . values_are_none ( ) ) ;
322
327
323
328
debug ! ( "RegionVarBindings: glb_regions({:?}, {:?})" , a, b) ;
324
329
match ( a, b) {
@@ -337,7 +342,8 @@ impl RegionVarBindings {
337
342
}
338
343
339
344
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 ( ) {
341
347
None => self . tcx . sess . span_bug (
342
348
self . var_origins [ rid. to_uint ( ) ] . span ( ) ,
343
349
format ! ( "Attempt to resolve region variable before values have \
@@ -514,7 +520,8 @@ impl RegionVarBindings {
514
520
debug ! ( "RegionVarBindings: resolve_regions()" ) ;
515
521
let mut errors = opt_vec:: Empty ;
516
522
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) ;
518
525
errors
519
526
}
520
527
}
0 commit comments