@@ -594,7 +594,7 @@ pub struct Liveness {
594
594
users : @mut ~[ Users ] ,
595
595
// The list of node IDs for the nested loop scopes
596
596
// we're in.
597
- loop_scope : @mut ~[ NodeId ] ,
597
+ loop_scope : @RefCell < ~[ NodeId ] > ,
598
598
// mappings from loop node ID to LiveNode
599
599
// ("break" label should map to loop node ID,
600
600
// it probably doesn't now)
@@ -612,7 +612,7 @@ fn Liveness(ir: @IrMaps, specials: Specials) -> Liveness {
612
612
users : @mut vec:: from_elem ( ir. num_live_nodes . get ( ) *
613
613
ir. num_vars . get ( ) ,
614
614
invalid_users ( ) ) ,
615
- loop_scope : @mut ~[ ] ,
615
+ loop_scope : @RefCell :: new ( ~[ ] ) ,
616
616
break_ln : @RefCell :: new ( HashMap :: new ( ) ) ,
617
617
cont_ln : @RefCell :: new ( HashMap :: new ( ) ) ,
618
618
}
@@ -762,7 +762,8 @@ impl Liveness {
762
762
None => {
763
763
// Vanilla 'break' or 'loop', so use the enclosing
764
764
// loop scope
765
- if self . loop_scope . len ( ) == 0 {
765
+ let loop_scope = self . loop_scope . borrow ( ) ;
766
+ if loop_scope. get ( ) . len ( ) == 0 {
766
767
self . tcx . sess . span_bug ( sp, "break outside loop" ) ;
767
768
} else {
768
769
// FIXME(#5275): this shouldn't have to be a method...
@@ -773,8 +774,8 @@ impl Liveness {
773
774
}
774
775
775
776
pub fn last_loop_scope ( & self ) -> NodeId {
776
- let loop_scope = & mut * self . loop_scope ;
777
- * loop_scope. last ( )
777
+ let loop_scope = self . loop_scope . borrow ( ) ;
778
+ * loop_scope. get ( ) . last ( )
778
779
}
779
780
780
781
pub fn ln_str ( & self , ln : LiveNode ) -> ~str {
@@ -1418,16 +1419,22 @@ impl Liveness {
1418
1419
cont_ln : LiveNode ,
1419
1420
f: || -> R )
1420
1421
-> R {
1421
- debug ! ( "with_loop_nodes: {} {}" , loop_node_id, * break_ln) ;
1422
- self . loop_scope . push ( loop_node_id) ;
1422
+ debug ! ( "with_loop_nodes: {} {}" , loop_node_id, * break_ln) ;
1423
+ {
1424
+ let mut loop_scope = self . loop_scope . borrow_mut ( ) ;
1425
+ loop_scope. get ( ) . push ( loop_node_id) ;
1426
+ }
1423
1427
{
1424
1428
let mut this_break_ln = self . break_ln . borrow_mut ( ) ;
1425
1429
let mut this_cont_ln = self . cont_ln . borrow_mut ( ) ;
1426
1430
this_break_ln. get ( ) . insert ( loop_node_id, break_ln) ;
1427
1431
this_cont_ln. get ( ) . insert ( loop_node_id, cont_ln) ;
1428
1432
}
1429
1433
let r = f ( ) ;
1430
- self . loop_scope . pop ( ) ;
1434
+ {
1435
+ let mut loop_scope = self . loop_scope . borrow_mut ( ) ;
1436
+ loop_scope. get ( ) . pop ( ) ;
1437
+ }
1431
1438
r
1432
1439
}
1433
1440
}
0 commit comments