@@ -158,7 +158,7 @@ pub struct SelfInfo {
158
158
/// share the inherited fields.
159
159
pub struct Inherited {
160
160
infcx : @infer:: InferCtxt ,
161
- locals : @mut HashMap < ast:: NodeId , ty:: t > ,
161
+ locals : @RefCell < HashMap < ast:: NodeId , ty:: t > > ,
162
162
param_env : ty:: ParameterEnvironment ,
163
163
164
164
// Temporary tables:
@@ -260,7 +260,7 @@ impl Inherited {
260
260
-> Inherited {
261
261
Inherited {
262
262
infcx : infer:: new_infer_ctxt ( tcx) ,
263
- locals : @mut HashMap :: new ( ) ,
263
+ locals : @RefCell :: new ( HashMap :: new ( ) ) ,
264
264
param_env : param_env,
265
265
node_types : RefCell :: new ( HashMap :: new ( ) ) ,
266
266
node_type_substs : RefCell :: new ( HashMap :: new ( ) ) ,
@@ -351,11 +351,13 @@ impl GatherLocalsVisitor {
351
351
// infer the variable's type
352
352
let var_id = self . fcx . infcx ( ) . next_ty_var_id ( ) ;
353
353
let var_ty = ty:: mk_var ( self . fcx . tcx ( ) , var_id) ;
354
- self . fcx . inh . locals . insert ( nid, var_ty) ;
354
+ let mut locals = self . fcx . inh . locals . borrow_mut ( ) ;
355
+ locals. get ( ) . insert ( nid, var_ty) ;
355
356
}
356
357
Some ( typ) => {
357
358
// take type that the user specified
358
- self . fcx . inh . locals . insert ( nid, typ) ;
359
+ let mut locals = self . fcx . inh . locals . borrow_mut ( ) ;
360
+ locals. get ( ) . insert ( nid, typ) ;
359
361
}
360
362
}
361
363
}
@@ -369,10 +371,13 @@ impl Visitor<()> for GatherLocalsVisitor {
369
371
_ => Some ( self . fcx . to_ty ( local. ty ) )
370
372
} ;
371
373
self . assign ( local. id , o_ty) ;
372
- debug ! ( "Local variable {} is assigned type {}" ,
373
- self . fcx. pat_to_str( local. pat) ,
374
- self . fcx. infcx( ) . ty_to_str(
375
- self . fcx. inh. locals. get_copy( & local. id) ) ) ;
374
+ {
375
+ let locals = self . fcx . inh . locals . borrow ( ) ;
376
+ debug ! ( "Local variable {} is assigned type {}" ,
377
+ self . fcx. pat_to_str( local. pat) ,
378
+ self . fcx. infcx( ) . ty_to_str(
379
+ locals. get( ) . get_copy( & local. id) ) ) ;
380
+ }
376
381
visit:: walk_local ( self , local, ( ) ) ;
377
382
378
383
}
@@ -382,10 +387,13 @@ impl Visitor<()> for GatherLocalsVisitor {
382
387
ast:: PatIdent ( _, ref path, _)
383
388
if pat_util:: pat_is_binding ( self . fcx . ccx . tcx . def_map , p) => {
384
389
self . assign ( p. id , None ) ;
385
- debug ! ( "Pattern binding {} is assigned to {}" ,
386
- self . tcx. sess. str_of( path. segments[ 0 ] . identifier) ,
387
- self . fcx. infcx( ) . ty_to_str(
388
- self . fcx. inh. locals. get_copy( & p. id) ) ) ;
390
+ {
391
+ let locals = self . fcx . inh . locals . borrow ( ) ;
392
+ debug ! ( "Pattern binding {} is assigned to {}" ,
393
+ self . tcx. sess. str_of( path. segments[ 0 ] . identifier) ,
394
+ self . fcx. infcx( ) . ty_to_str(
395
+ locals. get( ) . get_copy( & p. id) ) ) ;
396
+ }
389
397
}
390
398
_ => { }
391
399
}
@@ -509,9 +517,10 @@ pub fn check_fn(ccx: @CrateCtxt,
509
517
// Add the self parameter
510
518
for self_info in opt_self_info. iter ( ) {
511
519
visit. assign ( self_info. self_id , Some ( self_info. self_ty ) ) ;
520
+ let locals = fcx. inh . locals . borrow ( ) ;
512
521
debug ! ( "self is assigned to {}" ,
513
522
fcx. infcx( ) . ty_to_str(
514
- fcx . inh . locals. get_copy( & self_info. self_id) ) ) ;
523
+ locals. get ( ) . get_copy( & self_info. self_id) ) ) ;
515
524
}
516
525
517
526
// Add formal parameters.
@@ -1079,7 +1088,8 @@ impl FnCtxt {
1079
1088
}
1080
1089
1081
1090
pub fn local_ty ( & self , span : Span , nid : ast:: NodeId ) -> ty:: t {
1082
- match self . inh . locals . find ( & nid) {
1091
+ let locals = self . inh . locals . borrow ( ) ;
1092
+ match locals. get ( ) . find ( & nid) {
1083
1093
Some ( & t) => t,
1084
1094
None => {
1085
1095
self . tcx ( ) . sess . span_bug (
0 commit comments