@@ -284,15 +284,15 @@ enum DuplicateCheckingMode {
284
284
285
285
/// One local scope.
286
286
struct Rib {
287
- bindings : @ mut HashMap < Name , DefLike > ,
287
+ bindings : RefCell < HashMap < Name , DefLike > > ,
288
288
self_binding : @mut Option < DefLike > ,
289
289
kind : RibKind ,
290
290
}
291
291
292
292
impl Rib {
293
293
fn new ( kind : RibKind ) -> Rib {
294
294
Rib {
295
- bindings : @ mut HashMap :: new ( ) ,
295
+ bindings : RefCell :: new ( HashMap :: new ( ) ) ,
296
296
self_binding : @mut None ,
297
297
kind : kind
298
298
}
@@ -3494,8 +3494,12 @@ impl Resolver {
3494
3494
let mut i = ribs. len ( ) ;
3495
3495
while i != 0 {
3496
3496
i -= 1 ;
3497
- match ribs[ i] . bindings . find ( & name) {
3498
- Some ( & def_like) => {
3497
+ let binding_opt = {
3498
+ let bindings = ribs[ i] . bindings . borrow ( ) ;
3499
+ bindings. get ( ) . find_copy ( & name)
3500
+ } ;
3501
+ match binding_opt {
3502
+ Some ( def_like) => {
3499
3503
return self . upvarify ( ribs, i, def_like, span,
3500
3504
allow_capturing_self) ;
3501
3505
}
@@ -3572,8 +3576,10 @@ impl Resolver {
3572
3576
self . type_ribs . push ( self_type_rib) ;
3573
3577
// plain insert (no renaming)
3574
3578
let name = self . type_self_ident . name ;
3575
- self_type_rib. bindings . insert ( name,
3576
- DlDef ( DefSelfTy ( item. id ) ) ) ;
3579
+ {
3580
+ let mut bindings = self_type_rib. bindings . borrow_mut ( ) ;
3581
+ bindings. get ( ) . insert ( name, DlDef ( DefSelfTy ( item. id ) ) ) ;
3582
+ }
3577
3583
3578
3584
// Create a new rib for the trait-wide type parameters.
3579
3585
self . with_type_parameter_rib ( HasTypeParameters ( generics,
@@ -3710,7 +3716,9 @@ impl Resolver {
3710
3716
self . record_def ( type_parameter. id ,
3711
3717
( DefTyParamBinder ( node_id) , AllPublic ) ) ;
3712
3718
// plain insert (no renaming)
3713
- function_type_rib. bindings . insert ( ident. name , def_like) ;
3719
+ let mut bindings = function_type_rib. bindings
3720
+ . borrow_mut ( ) ;
3721
+ bindings. get ( ) . insert ( ident. name , def_like) ;
3714
3722
}
3715
3723
}
3716
3724
@@ -4333,8 +4341,12 @@ impl Resolver {
4333
4341
let this = & mut * self ;
4334
4342
let last_rib = this. value_ribs [
4335
4343
this. value_ribs . len ( ) - 1 ] ;
4336
- last_rib. bindings . insert ( renamed,
4337
- DlDef ( def) ) ;
4344
+ {
4345
+ let mut bindings =
4346
+ last_rib. bindings . borrow_mut ( ) ;
4347
+ bindings. get ( ) . insert ( renamed,
4348
+ DlDef ( def) ) ;
4349
+ }
4338
4350
bindings_list. insert ( renamed, pat_id) ;
4339
4351
}
4340
4352
Some ( b) => {
@@ -4354,8 +4366,12 @@ impl Resolver {
4354
4366
let this = & mut * self ;
4355
4367
let last_rib = this. value_ribs [
4356
4368
this. value_ribs . len ( ) - 1 ] ;
4357
- last_rib. bindings . insert ( renamed,
4358
- DlDef ( def) ) ;
4369
+ {
4370
+ let mut bindings =
4371
+ last_rib. bindings . borrow_mut ( ) ;
4372
+ bindings. get ( ) . insert ( renamed,
4373
+ DlDef ( def) ) ;
4374
+ }
4359
4375
}
4360
4376
}
4361
4377
}
@@ -4911,7 +4927,8 @@ impl Resolver {
4911
4927
let mut j = this. value_ribs . len ( ) ;
4912
4928
while j != 0 {
4913
4929
j -= 1 ;
4914
- for ( & k, _) in this. value_ribs [ j] . bindings . iter ( ) {
4930
+ let bindings = this. value_ribs [ j] . bindings . borrow ( ) ;
4931
+ for ( & k, _) in bindings. get ( ) . iter ( ) {
4915
4932
maybes. push ( interner_get ( k) ) ;
4916
4933
values. push ( uint:: max_value) ;
4917
4934
}
@@ -5060,7 +5077,10 @@ impl Resolver {
5060
5077
let def_like = DlDef ( DefLabel ( expr. id ) ) ;
5061
5078
let rib = this. label_ribs [ this. label_ribs . len ( ) - 1 ] ;
5062
5079
// plain insert (no renaming)
5063
- rib. bindings . insert ( label. name , def_like) ;
5080
+ {
5081
+ let mut bindings = rib. bindings . borrow_mut ( ) ;
5082
+ bindings. get ( ) . insert ( label. name , def_like) ;
5083
+ }
5064
5084
5065
5085
visit:: walk_expr ( this, expr, ( ) ) ;
5066
5086
} )
0 commit comments