@@ -38,7 +38,7 @@ pub struct MoveData {
38
38
path_map : HashMap < @LoanPath , MovePathIndex > ,
39
39
40
40
/// Each move or uninitialized variable gets an entry here.
41
- moves : ~[ Move ] ,
41
+ moves : RefCell < ~[ Move ] > ,
42
42
43
43
/// Assignments to a variable, like `x = foo`. These are assigned
44
44
/// bits for dataflow, since we must track them to ensure that
@@ -167,7 +167,7 @@ impl MoveData {
167
167
MoveData {
168
168
paths : RefCell :: new ( ~[ ] ) ,
169
169
path_map : HashMap :: new ( ) ,
170
- moves : ~[ ] ,
170
+ moves : RefCell :: new ( ~[ ] ) ,
171
171
path_assignments : ~[ ] ,
172
172
var_assignments : ~[ ] ,
173
173
assignee_ids : HashSet :: new ( ) ,
@@ -216,7 +216,8 @@ impl MoveData {
216
216
217
217
fn move_next_move ( & self , index : MoveIndex ) -> MoveIndex {
218
218
//! Type safe indexing operator
219
- self . moves [ * index] . next_move
219
+ let moves = self . moves . borrow ( ) ;
220
+ moves. get ( ) [ * index] . next_move
220
221
}
221
222
222
223
fn is_var_path ( & self , index : MovePathIndex ) -> bool {
@@ -349,17 +350,23 @@ impl MoveData {
349
350
kind) ;
350
351
351
352
let path_index = self . move_path ( tcx, lp) ;
352
- let move_index = MoveIndex ( self . moves . len ( ) ) ;
353
+ let move_index = {
354
+ let moves = self . moves . borrow ( ) ;
355
+ MoveIndex ( moves. get ( ) . len ( ) )
356
+ } ;
353
357
354
358
let next_move = self . path_first_move ( path_index) ;
355
359
self . set_path_first_move ( path_index, move_index) ;
356
360
357
- self . moves . push ( Move {
358
- path : path_index,
359
- id : id,
360
- kind : kind,
361
- next_move : next_move
362
- } ) ;
361
+ {
362
+ let mut moves = self . moves . borrow_mut ( ) ;
363
+ moves. get ( ) . push ( Move {
364
+ path : path_index,
365
+ id : id,
366
+ kind : kind,
367
+ next_move : next_move
368
+ } ) ;
369
+ }
363
370
}
364
371
365
372
pub fn add_assignment ( & mut self ,
@@ -411,8 +418,11 @@ impl MoveData {
411
418
* killed by scoping. See `doc.rs` for more details.
412
419
*/
413
420
414
- for ( i, move ) in self . moves . iter ( ) . enumerate ( ) {
415
- dfcx_moves. add_gen ( move . id, i) ;
421
+ {
422
+ let moves = self . moves . borrow ( ) ;
423
+ for ( i, move ) in moves. get ( ) . iter ( ) . enumerate ( ) {
424
+ dfcx_moves. add_gen ( move . id, i) ;
425
+ }
416
426
}
417
427
418
428
for ( i, assignment) in self . var_assignments . iter ( ) . enumerate ( ) {
@@ -523,12 +533,14 @@ impl FlowedMoveData {
523
533
body : & ast:: Block )
524
534
-> FlowedMoveData
525
535
{
526
- let mut dfcx_moves =
536
+ let mut dfcx_moves = {
537
+ let moves = move_data. moves . borrow ( ) ;
527
538
DataFlowContext :: new ( tcx,
528
539
method_map,
529
540
MoveDataFlowOperator ,
530
541
id_range,
531
- move_data. moves . len ( ) ) ;
542
+ moves. get ( ) . len ( ) )
543
+ } ;
532
544
let mut dfcx_assign =
533
545
DataFlowContext :: new ( tcx,
534
546
method_map,
@@ -554,7 +566,8 @@ impl FlowedMoveData {
554
566
*/
555
567
556
568
self . dfcx_moves . each_gen_bit_frozen ( id, |index| {
557
- let move = & self . move_data . moves [ index] ;
569
+ let moves = self . move_data . moves . borrow ( ) ;
570
+ let move = & moves. get ( ) [ index] ;
558
571
let moved_path = move . path;
559
572
f ( move , self . move_data . path_loan_path ( moved_path) )
560
573
} )
@@ -592,7 +605,8 @@ impl FlowedMoveData {
592
605
let mut ret = true ;
593
606
594
607
self . dfcx_moves . each_bit_on_entry_frozen ( id, |index| {
595
- let move = & self . move_data . moves [ index] ;
608
+ let moves = self . move_data . moves . borrow ( ) ;
609
+ let move = & moves. get ( ) [ index] ;
596
610
let moved_path = move . path;
597
611
if base_indices. iter ( ) . any ( |x| x == & moved_path) {
598
612
// Scenario 1 or 2: `loan_path` or some base path of
0 commit comments