From abbee6decdfd0cf69428c5964738bb7526e18dd1 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 21 Dec 2013 16:03:27 -0800 Subject: [PATCH] librustc: De-`@mut` `ScopeInfo` --- src/librustc/middle/trans/base.rs | 15 ++++++++------- src/librustc/middle/trans/common.rs | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 4df8b2efdd50..c92386cc1ba2 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1005,7 +1005,7 @@ pub fn have_cached_lpad(bcx: @Block) -> bool { return res; } -pub fn in_lpad_scope_cx(bcx: @Block, f: |si: &mut ScopeInfo|) { +pub fn in_lpad_scope_cx(bcx: @Block, f: |si: &ScopeInfo|) { let mut bcx = bcx; let mut cur_scope = bcx.scope.get(); loop { @@ -1191,7 +1191,7 @@ pub fn trans_stmt(cx: @Block, s: &ast::Stmt) -> @Block { // next three functions instead. pub fn new_block(cx: @FunctionContext, parent: Option<@Block>, - scope: Option<@mut ScopeInfo>, + scope: Option<@ScopeInfo>, is_lpad: bool, name: &str, opt_node_info: Option) @@ -1216,9 +1216,10 @@ pub fn new_block(cx: @FunctionContext, } } -pub fn simple_block_scope(parent: Option<@mut ScopeInfo>, - node_info: Option) -> @mut ScopeInfo { - @mut ScopeInfo { +pub fn simple_block_scope(parent: Option<@ScopeInfo>, + node_info: Option) + -> @ScopeInfo { + @ScopeInfo { parent: parent, loop_break: None, loop_label: None, @@ -1248,7 +1249,7 @@ pub fn loop_scope_block(bcx: @Block, loop_label: Option, n: &str, opt_node_info: Option) -> @Block { - return new_block(bcx.fcx, Some(bcx), Some(@mut ScopeInfo { + return new_block(bcx.fcx, Some(bcx), Some(@ScopeInfo { parent: None, loop_break: Some(loop_break), loop_label: loop_label, @@ -1329,7 +1330,7 @@ pub fn cleanup_and_leave(bcx: @Block, cur_scope = match cur_scope { Some (inf) if !inf.empty_cleanups() => { let (sub_cx, dest, inf_cleanups) = { - let inf = &mut *inf; + let inf = &*inf; let mut skip = 0; let mut dest = None; { diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 26866ce3aef0..d5481b1e1d1e 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -430,7 +430,7 @@ pub struct cleanup_path { dest: BasicBlockRef } -pub fn shrink_scope_clean(scope_info: &mut ScopeInfo, size: uint) { +pub fn shrink_scope_clean(scope_info: &ScopeInfo, size: uint) { scope_info.landing_pad.set(None); let new_cleanup_paths = { let cleanup_paths = scope_info.cleanup_paths.borrow(); @@ -443,7 +443,7 @@ pub fn shrink_scope_clean(scope_info: &mut ScopeInfo, size: uint) { scope_info.cleanup_paths.set(new_cleanup_paths) } -pub fn grow_scope_clean(scope_info: &mut ScopeInfo) { +pub fn grow_scope_clean(scope_info: &ScopeInfo) { scope_info.landing_pad.set(None); } @@ -623,7 +623,7 @@ pub fn block_cleanups(bcx: &Block) -> ~[cleanup] { } pub struct ScopeInfo { - parent: Option<@mut ScopeInfo>, + parent: Option<@ScopeInfo>, loop_break: Option<@Block>, loop_label: Option, // A list of functions that must be run at when leaving this @@ -640,7 +640,7 @@ pub struct ScopeInfo { } impl ScopeInfo { - pub fn empty_cleanups(&mut self) -> bool { + pub fn empty_cleanups(&self) -> bool { let cleanups = self.cleanups.borrow(); cleanups.get().is_empty() } @@ -694,7 +694,7 @@ pub struct Block { unreachable: Cell, parent: Option<@Block>, // The current scope within this basic block - scope: RefCell>, + scope: RefCell>, // Is this block part of a landing pad? is_lpad: bool, // info about the AST node this block originated from, if any @@ -803,7 +803,7 @@ pub fn val_ty(v: ValueRef) -> Type { pub fn in_scope_cx(cx: @Block, scope_id: Option, - f: |si: &mut ScopeInfo|) { + f: |si: &ScopeInfo|) { let mut cur = cx; let mut cur_scope = cur.scope.get(); loop {