Skip to content

Commit f049ecd

Browse files
committed
---
yaml --- r: 147703 b: refs/heads/try2 c: eaf6949 h: refs/heads/master i: 147701: 4d13796 147699: 311282f 147695: 0c79be4 v: v3
1 parent 8817fe8 commit f049ecd

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 298d0b870ff9201ee05c5517ade88da84a61cdf1
8+
refs/heads/try2: eaf69494a5a126189b052102e1b36d1d8bced953
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/liveness.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ pub struct Liveness {
594594
users: @mut ~[Users],
595595
// The list of node IDs for the nested loop scopes
596596
// we're in.
597-
loop_scope: @mut ~[NodeId],
597+
loop_scope: @RefCell<~[NodeId]>,
598598
// mappings from loop node ID to LiveNode
599599
// ("break" label should map to loop node ID,
600600
// it probably doesn't now)
@@ -612,7 +612,7 @@ fn Liveness(ir: @IrMaps, specials: Specials) -> Liveness {
612612
users: @mut vec::from_elem(ir.num_live_nodes.get() *
613613
ir.num_vars.get(),
614614
invalid_users()),
615-
loop_scope: @mut ~[],
615+
loop_scope: @RefCell::new(~[]),
616616
break_ln: @RefCell::new(HashMap::new()),
617617
cont_ln: @RefCell::new(HashMap::new()),
618618
}
@@ -762,7 +762,8 @@ impl Liveness {
762762
None => {
763763
// Vanilla 'break' or 'loop', so use the enclosing
764764
// loop scope
765-
if self.loop_scope.len() == 0 {
765+
let loop_scope = self.loop_scope.borrow();
766+
if loop_scope.get().len() == 0 {
766767
self.tcx.sess.span_bug(sp, "break outside loop");
767768
} else {
768769
// FIXME(#5275): this shouldn't have to be a method...
@@ -773,8 +774,8 @@ impl Liveness {
773774
}
774775

775776
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()
778779
}
779780

780781
pub fn ln_str(&self, ln: LiveNode) -> ~str {
@@ -1418,16 +1419,22 @@ impl Liveness {
14181419
cont_ln: LiveNode,
14191420
f: || -> R)
14201421
-> 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+
}
14231427
{
14241428
let mut this_break_ln = self.break_ln.borrow_mut();
14251429
let mut this_cont_ln = self.cont_ln.borrow_mut();
14261430
this_break_ln.get().insert(loop_node_id, break_ln);
14271431
this_cont_ln.get().insert(loop_node_id, cont_ln);
14281432
}
14291433
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+
}
14311438
r
14321439
}
14331440
}

0 commit comments

Comments
 (0)