@@ -14,7 +14,7 @@ use rustc::mir::repr::{self, Mir, BasicBlock, Lvalue, Rvalue};
14
14
use rustc:: mir:: repr:: { StatementKind , Terminator } ;
15
15
use rustc:: util:: nodemap:: FnvHashMap ;
16
16
17
- use std:: cell:: { Cell , RefCell } ;
17
+ use std:: cell:: { Cell } ;
18
18
use std:: collections:: hash_map:: Entry ;
19
19
use std:: fmt;
20
20
use std:: iter;
@@ -220,8 +220,8 @@ type MovePathInverseMap = Vec<Option<MovePathIndex>>;
220
220
221
221
struct MovePathDataBuilder < ' a , ' tcx : ' a > {
222
222
mir : & ' a Mir < ' tcx > ,
223
- pre_move_paths : RefCell < Vec < PreMovePath < ' tcx > > > ,
224
- rev_lookup : RefCell < MovePathLookup < ' tcx > > ,
223
+ pre_move_paths : Vec < PreMovePath < ' tcx > > ,
224
+ rev_lookup : MovePathLookup < ' tcx > ,
225
225
}
226
226
227
227
/// Tables mapping from an l-value to its MovePathIndex.
@@ -400,41 +400,32 @@ impl<'tcx> MovePathLookup<'tcx> {
400
400
401
401
impl < ' a , ' tcx > MovePathDataBuilder < ' a , ' tcx > {
402
402
fn lookup ( & mut self , lval : & Lvalue < ' tcx > ) -> Lookup < MovePathIndex > {
403
- let proj = {
404
- let mut rev_lookup = self . rev_lookup . borrow_mut ( ) ;
405
- match * lval {
406
- Lvalue :: Var ( var_idx) =>
407
- return rev_lookup. lookup_var ( var_idx) ,
408
- Lvalue :: Temp ( temp_idx) =>
409
- return rev_lookup. lookup_temp ( temp_idx) ,
410
- Lvalue :: Arg ( arg_idx) =>
411
- return rev_lookup. lookup_arg ( arg_idx) ,
412
- Lvalue :: Static ( _def_id) =>
413
- return rev_lookup. lookup_static ( ) ,
414
- Lvalue :: ReturnPointer =>
415
- return rev_lookup. lookup_return_pointer ( ) ,
416
- Lvalue :: Projection ( ref proj) => {
417
- proj
418
- }
403
+ let proj = match * lval {
404
+ Lvalue :: Var ( var_idx) =>
405
+ return self . rev_lookup . lookup_var ( var_idx) ,
406
+ Lvalue :: Temp ( temp_idx) =>
407
+ return self . rev_lookup . lookup_temp ( temp_idx) ,
408
+ Lvalue :: Arg ( arg_idx) =>
409
+ return self . rev_lookup . lookup_arg ( arg_idx) ,
410
+ Lvalue :: Static ( _def_id) =>
411
+ return self . rev_lookup . lookup_static ( ) ,
412
+ Lvalue :: ReturnPointer =>
413
+ return self . rev_lookup . lookup_return_pointer ( ) ,
414
+ Lvalue :: Projection ( ref proj) => {
415
+ proj
419
416
}
420
- // drop the rev_lookup here ...
421
417
} ;
422
418
423
419
let base_index = self . move_path_for ( & proj. base ) ;
424
-
425
- // ... restablish exclusive access to rev_lookup here.
426
- let mut rev_lookup = self . rev_lookup . borrow_mut ( ) ;
427
- rev_lookup. lookup_proj ( proj, base_index)
420
+ self . rev_lookup . lookup_proj ( proj, base_index)
428
421
}
429
422
430
- // Caller must ensure self's RefCells (i.e. `self.pre_move_paths`
431
- // and `self.rev_lookup`) are not mutably borrowed.
432
423
fn move_path_for ( & mut self , lval : & Lvalue < ' tcx > ) -> MovePathIndex {
433
424
let lookup: Lookup < MovePathIndex > = self . lookup ( lval) ;
434
425
435
426
// `lookup` is either the previously assigned index or a
436
427
// newly-allocated one.
437
- debug_assert ! ( lookup. idx( ) <= self . pre_move_paths. borrow ( ) . len( ) ) ;
428
+ debug_assert ! ( lookup. idx( ) <= self . pre_move_paths. len( ) ) ;
438
429
439
430
if let Lookup ( LookupKind :: Generate , mpi) = lookup {
440
431
let parent;
@@ -465,8 +456,7 @@ impl<'a, 'tcx> MovePathDataBuilder<'a, 'tcx> {
465
456
let idx = self . move_path_for ( & proj. base ) ;
466
457
parent = Some ( idx) ;
467
458
468
- let mut pre_move_paths = self . pre_move_paths . borrow_mut ( ) ;
469
- let parent_move_path = & mut pre_move_paths[ idx. idx ( ) ] ;
459
+ let parent_move_path = & mut self . pre_move_paths [ idx. idx ( ) ] ;
470
460
471
461
// At last: Swap in the new first_child.
472
462
sibling = parent_move_path. first_child . get ( ) ;
@@ -486,8 +476,7 @@ impl<'a, 'tcx> MovePathDataBuilder<'a, 'tcx> {
486
476
first_child : Cell :: new ( None ) ,
487
477
} ;
488
478
489
- let mut pre_move_paths = self . pre_move_paths . borrow_mut ( ) ;
490
- pre_move_paths. push ( move_path) ;
479
+ self . pre_move_paths . push ( move_path) ;
491
480
}
492
481
493
482
return lookup. 1 ;
@@ -519,8 +508,8 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
519
508
// straight-forward than mutable borrows in this instance.)
520
509
let mut builder = MovePathDataBuilder {
521
510
mir : mir,
522
- pre_move_paths : RefCell :: new ( Vec :: new ( ) ) ,
523
- rev_lookup : RefCell :: new ( MovePathLookup :: new ( ) ) ,
511
+ pre_move_paths : Vec :: new ( ) ,
512
+ rev_lookup : MovePathLookup :: new ( ) ,
524
513
} ;
525
514
526
515
for bb in bbs {
@@ -644,10 +633,10 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
644
633
// All such paths were not referenced ...
645
634
//
646
635
// well you know, lets actually try just asserting that the path map *is* complete.
647
- assert_eq ! ( path_map. len( ) , builder. pre_move_paths. borrow ( ) . len( ) ) ;
648
- path_map. fill_to ( builder. pre_move_paths . borrow ( ) . len ( ) - 1 ) ;
636
+ assert_eq ! ( path_map. len( ) , builder. pre_move_paths. len( ) ) ;
637
+ path_map. fill_to ( builder. pre_move_paths . len ( ) - 1 ) ;
649
638
650
- let pre_move_paths = builder. pre_move_paths . into_inner ( ) ;
639
+ let pre_move_paths = builder. pre_move_paths ;
651
640
let move_paths: Vec < _ > = pre_move_paths. into_iter ( )
652
641
. map ( |p| p. into_move_path ( ) )
653
642
. collect ( ) ;
@@ -672,7 +661,7 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
672
661
moves : moves,
673
662
loc_map : LocMap { map : loc_map } ,
674
663
path_map : PathMap { map : path_map } ,
675
- rev_lookup : builder. rev_lookup . into_inner ( ) ,
664
+ rev_lookup : builder. rev_lookup ,
676
665
}
677
666
}
678
667
0 commit comments