Skip to content

Commit 7acaa73

Browse files
committed
librustc: De-@mut ScopeInfo::cleanup_paths
1 parent 89a85e4 commit 7acaa73

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ pub fn simple_block_scope(parent: Option<@mut ScopeInfo>,
12231223
loop_break: None,
12241224
loop_label: None,
12251225
cleanups: RefCell::new(~[]),
1226-
cleanup_paths: ~[],
1226+
cleanup_paths: RefCell::new(~[]),
12271227
landing_pad: None,
12281228
node_info: node_info,
12291229
}
@@ -1253,7 +1253,7 @@ pub fn loop_scope_block(bcx: @Block,
12531253
loop_break: Some(loop_break),
12541254
loop_label: loop_label,
12551255
cleanups: RefCell::new(~[]),
1256-
cleanup_paths: ~[],
1256+
cleanup_paths: RefCell::new(~[]),
12571257
landing_pad: None,
12581258
node_info: opt_node_info,
12591259
}), bcx.is_lpad, n, opt_node_info);
@@ -1333,7 +1333,12 @@ pub fn cleanup_and_leave(bcx: @Block,
13331333
let mut skip = 0;
13341334
let mut dest = None;
13351335
{
1336-
let r = (*inf).cleanup_paths.rev_iter().find(|cp| cp.target == leave);
1336+
let cleanup_paths = inf.cleanup_paths.borrow();
1337+
let r = cleanup_paths.get()
1338+
.rev_iter()
1339+
.find(|cp| {
1340+
cp.target == leave
1341+
});
13371342
for cp in r.iter() {
13381343
let cleanups = inf.cleanups.borrow();
13391344
if cp.size == cleanups.get().len() {
@@ -1348,7 +1353,9 @@ pub fn cleanup_and_leave(bcx: @Block,
13481353
let sub_cx = sub_block(bcx, "cleanup");
13491354
Br(bcx, sub_cx.llbb);
13501355
let cleanups = inf.cleanups.borrow();
1351-
inf.cleanup_paths.push(cleanup_path {
1356+
let mut cleanup_paths = inf.cleanup_paths
1357+
.borrow_mut();
1358+
cleanup_paths.get().push(cleanup_path {
13521359
target: leave,
13531360
size: cleanups.get().len(),
13541361
dest: sub_cx.llbb

src/librustc/middle/trans/common.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,15 @@ pub struct cleanup_path {
432432

433433
pub fn shrink_scope_clean(scope_info: &mut ScopeInfo, size: uint) {
434434
scope_info.landing_pad = None;
435-
scope_info.cleanup_paths = scope_info.cleanup_paths.iter()
436-
.take_while(|&cu| cu.size <= size).map(|&x|x).collect();
435+
let new_cleanup_paths = {
436+
let cleanup_paths = scope_info.cleanup_paths.borrow();
437+
cleanup_paths.get()
438+
.iter()
439+
.take_while(|&cu| cu.size <= size)
440+
.map(|&x| x)
441+
.collect()
442+
};
443+
scope_info.cleanup_paths.set(new_cleanup_paths)
437444
}
438445

439446
pub fn grow_scope_clean(scope_info: &mut ScopeInfo) {
@@ -625,7 +632,7 @@ pub struct ScopeInfo {
625632
cleanups: RefCell<~[cleanup]>,
626633
// Existing cleanup paths that may be reused, indexed by destination and
627634
// cleared when the set of cleanups changes.
628-
cleanup_paths: ~[cleanup_path],
635+
cleanup_paths: RefCell<~[cleanup_path]>,
629636
// Unwinding landing pad. Also cleared when cleanups change.
630637
landing_pad: Option<BasicBlockRef>,
631638
// info about the AST node this scope originated from, if any

0 commit comments

Comments
 (0)