Skip to content

librustc: Remove all mutable fields from librustc. rs=demuting #5076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
396 changes: 223 additions & 173 deletions src/librustc/middle/resolve.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ pub fn extract_variant_args(bcx: block,
-> ExtractedBlock {
let (enm, evar) = vdefs;
let _icx = bcx.insn_ctxt("match::extract_variant_args");
let ccx = bcx.fcx.ccx;
let ccx = *bcx.fcx.ccx;
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty {
ty::ty_enum(id, ref substs) => {
assert id == enm;
Expand Down Expand Up @@ -1272,7 +1272,7 @@ pub fn compile_submatch(bcx: block,

let vals_left = vec::append(vec::slice(vals, 0u, col).to_vec(),
vec::slice(vals, col + 1u, vals.len()));
let ccx = bcx.fcx.ccx;
let ccx = *bcx.fcx.ccx;
let mut pat_id = 0;
for vec::each(m) |br| {
// Find a real id (we're adding placeholder wildcard patterns, but
Expand Down Expand Up @@ -1710,7 +1710,7 @@ pub fn bind_irrefutable_pat(bcx: block,
binding_mode: IrrefutablePatternBindingMode)
-> block {
let _icx = bcx.insn_ctxt("match::bind_irrefutable_pat");
let ccx = bcx.fcx.ccx;
let ccx = *bcx.fcx.ccx;
let mut bcx = bcx;

// Necessary since bind_irrefutable_pat is called outside trans_match
Expand Down
106 changes: 59 additions & 47 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,8 @@ pub fn need_invoke(bcx: block) -> bool {
// Walk the scopes to look for cleanups
let mut cur = bcx;
loop {
match cur.kind {
block_scope(ref inf) => {
match *cur.kind {
block_scope(ref mut inf) => {
for vec::each((*inf).cleanups) |cleanup| {
match *cleanup {
clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) => {
Expand Down Expand Up @@ -898,16 +898,21 @@ pub fn have_cached_lpad(bcx: block) -> bool {
return res;
}

pub fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) {
pub fn in_lpad_scope_cx(bcx: block, f: fn(&mut scope_info)) {
let mut bcx = bcx;
loop {
match bcx.kind {
block_scope(ref inf) => {
if (*inf).cleanups.len() > 0u || bcx.parent.is_none() {
f((*inf)); return;
{
// XXX: Borrow check bug workaround.
let kind: &mut block_kind = &mut *bcx.kind;
match *kind {
block_scope(ref mut inf) => {
if inf.cleanups.len() > 0u || bcx.parent.is_none() {
f(inf);
return;
}
}
_ => ()
}
}
_ => ()
}
bcx = block_parent(bcx);
}
Expand Down Expand Up @@ -1157,7 +1162,7 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block {
}
}
}
ast::decl_item(i) => trans_item(cx.fcx.ccx, *i)
ast::decl_item(i) => trans_item(*cx.fcx.ccx, *i)
}
}
ast::stmt_mac(*) => cx.tcx().sess.bug(~"unexpanded macro")
Expand Down Expand Up @@ -1198,9 +1203,9 @@ pub fn simple_block_scope() -> block_kind {
block_scope(scope_info {
loop_break: None,
loop_label: None,
mut cleanups: ~[],
mut cleanup_paths: ~[],
mut landing_pad: None
cleanups: ~[],
cleanup_paths: ~[],
landing_pad: None
})
}

Expand All @@ -1226,9 +1231,9 @@ pub fn loop_scope_block(bcx: block,
return new_block(bcx.fcx, Some(bcx), block_scope(scope_info {
loop_break: Some(loop_break),
loop_label: loop_label,
mut cleanups: ~[],
mut cleanup_paths: ~[],
mut landing_pad: None
cleanups: ~[],
cleanup_paths: ~[],
landing_pad: None
}), bcx.is_lpad, n, opt_node_info);
}

Expand Down Expand Up @@ -1301,23 +1306,30 @@ pub fn cleanup_and_leave(bcx: block,
@fmt!("cleanup_and_leave(%s)", cur.to_str()));
}

match cur.kind {
block_scope(ref inf) if !inf.cleanups.is_empty() => {
for vec::find((*inf).cleanup_paths,
|cp| cp.target == leave).each |cp| {
Br(bcx, cp.dest);
return;
{
// XXX: Borrow check bug workaround.
let kind: &mut block_kind = &mut *cur.kind;
match *kind {
block_scope(ref mut inf) if !inf.cleanups.is_empty() => {
for vec::find((*inf).cleanup_paths,
|cp| cp.target == leave).each |cp| {
Br(bcx, cp.dest);
return;
}
let sub_cx = sub_block(bcx, ~"cleanup");
Br(bcx, sub_cx.llbb);
inf.cleanup_paths.push(cleanup_path {
target: leave,
dest: sub_cx.llbb
});
bcx = trans_block_cleanups_(sub_cx,
block_cleanups(cur),
is_lpad);
}
_ => ()
}
let sub_cx = sub_block(bcx, ~"cleanup");
Br(bcx, sub_cx.llbb);
(*inf).cleanup_paths.push(cleanup_path {
target: leave,
dest: sub_cx.llbb
});
bcx = trans_block_cleanups_(sub_cx, block_cleanups(cur), is_lpad);
}
_ => ()
}

match upto {
Some(bb) => { if cur.llbb == bb { break; } }
_ => ()
Expand Down Expand Up @@ -1572,25 +1584,25 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
param_substs: Option<@param_substs>,
sp: Option<span>) -> fn_ctxt {
let llbbs = mk_standard_basic_blocks(llfndecl);
return @fn_ctxt_ {
return @mut fn_ctxt_ {
llfn: llfndecl,
llenv: unsafe { llvm::LLVMGetParam(llfndecl, 1u as c_uint) },
llretptr: unsafe { llvm::LLVMGetParam(llfndecl, 0u as c_uint) },
mut llstaticallocas: llbbs.sa,
mut llloadenv: None,
mut llreturn: llbbs.rt,
mut llself: None,
mut personality: None,
mut loop_ret: None,
llargs: HashMap(),
lllocals: HashMap(),
llupvars: HashMap(),
llstaticallocas: llbbs.sa,
llloadenv: None,
llreturn: llbbs.rt,
llself: None,
personality: None,
loop_ret: None,
llargs: @HashMap(),
lllocals: @HashMap(),
llupvars: @HashMap(),
id: id,
impl_id: impl_id,
param_substs: param_substs,
span: sp,
path: path,
ccx: ccx
ccx: @ccx
};
}

Expand Down Expand Up @@ -1780,7 +1792,7 @@ pub fn trans_closure(ccx: @CrateContext,
llvm::LLVMSetGC(fcx.llfn, strategy);
}
}
ccx.uses_gc = true;
*ccx.uses_gc = true;
}

// Create the first basic block in the function and keep a handle on it to
Expand Down Expand Up @@ -2803,7 +2815,7 @@ pub fn trap(bcx: block) {
}

pub fn decl_gc_metadata(ccx: @CrateContext, llmod_id: ~str) {
if !ccx.sess.opts.gc || !ccx.uses_gc {
if !ccx.sess.opts.gc || !*ccx.uses_gc {
return;
}

Expand Down Expand Up @@ -3038,7 +3050,7 @@ pub fn trans_crate(sess: session::Session,
discrims: HashMap(),
discrim_symbols: HashMap(),
tydescs: ty::new_ty_hash(),
mut finished_tydescs: false,
finished_tydescs: @mut false,
external: HashMap(),
monomorphized: HashMap(),
monomorphizing: HashMap(),
Expand Down Expand Up @@ -3080,9 +3092,9 @@ pub fn trans_crate(sess: session::Session,
builder: BuilderRef_res(unsafe { llvm::LLVMCreateBuilder() }),
shape_cx: mk_ctxt(llmod),
crate_map: crate_map,
mut uses_gc: false,
uses_gc: @mut false,
dbg_cx: dbg_cx,
mut do_not_commit_warning_issued: false
do_not_commit_warning_issued: @mut false
};

{
Expand Down
Loading