@@ -14,7 +14,7 @@ use rustc::mir::repr::{self, Mir, BasicBlock, Lvalue, Rvalue};
1414use rustc:: mir:: repr:: { StatementKind , Terminator } ;
1515use rustc:: util:: nodemap:: FnvHashMap ;
1616
17- use std:: cell:: { Cell , RefCell } ;
17+ use std:: cell:: { Cell } ;
1818use std:: collections:: hash_map:: Entry ;
1919use std:: fmt;
2020use std:: iter;
@@ -220,8 +220,8 @@ type MovePathInverseMap = Vec<Option<MovePathIndex>>;
220220
221221struct MovePathDataBuilder < ' a , ' tcx : ' a > {
222222 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 > ,
225225}
226226
227227/// Tables mapping from an l-value to its MovePathIndex.
@@ -400,41 +400,32 @@ impl<'tcx> MovePathLookup<'tcx> {
400400
401401impl < ' a , ' tcx > MovePathDataBuilder < ' a , ' tcx > {
402402 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
419416 }
420- // drop the rev_lookup here ...
421417 } ;
422418
423419 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)
428421 }
429422
430- // Caller must ensure self's RefCells (i.e. `self.pre_move_paths`
431- // and `self.rev_lookup`) are not mutably borrowed.
432423 fn move_path_for ( & mut self , lval : & Lvalue < ' tcx > ) -> MovePathIndex {
433424 let lookup: Lookup < MovePathIndex > = self . lookup ( lval) ;
434425
435426 // `lookup` is either the previously assigned index or a
436427 // newly-allocated one.
437- debug_assert ! ( lookup. idx( ) <= self . pre_move_paths. borrow ( ) . len( ) ) ;
428+ debug_assert ! ( lookup. idx( ) <= self . pre_move_paths. len( ) ) ;
438429
439430 if let Lookup ( LookupKind :: Generate , mpi) = lookup {
440431 let parent;
@@ -465,8 +456,7 @@ impl<'a, 'tcx> MovePathDataBuilder<'a, 'tcx> {
465456 let idx = self . move_path_for ( & proj. base ) ;
466457 parent = Some ( idx) ;
467458
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 ( ) ] ;
470460
471461 // At last: Swap in the new first_child.
472462 sibling = parent_move_path. first_child . get ( ) ;
@@ -486,8 +476,7 @@ impl<'a, 'tcx> MovePathDataBuilder<'a, 'tcx> {
486476 first_child : Cell :: new ( None ) ,
487477 } ;
488478
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) ;
491480 }
492481
493482 return lookup. 1 ;
@@ -519,8 +508,8 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
519508 // straight-forward than mutable borrows in this instance.)
520509 let mut builder = MovePathDataBuilder {
521510 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 ( ) ,
524513 } ;
525514
526515 for bb in bbs {
@@ -644,10 +633,10 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
644633 // All such paths were not referenced ...
645634 //
646635 // 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 ) ;
649638
650- let pre_move_paths = builder. pre_move_paths . into_inner ( ) ;
639+ let pre_move_paths = builder. pre_move_paths ;
651640 let move_paths: Vec < _ > = pre_move_paths. into_iter ( )
652641 . map ( |p| p. into_move_path ( ) )
653642 . collect ( ) ;
@@ -672,7 +661,7 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
672661 moves : moves,
673662 loc_map : LocMap { map : loc_map } ,
674663 path_map : PathMap { map : path_map } ,
675- rev_lookup : builder. rev_lookup . into_inner ( ) ,
664+ rev_lookup : builder. rev_lookup ,
676665 }
677666}
678667
0 commit comments