diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-06-15 12:17:51 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-06-15 14:10:07 +0200 |
| commit | 5fb518abc9539ef114cfe9a08fa1964d28c98ef3 (patch) | |
| tree | f950c000c80a49f3957961ceea0a5fd094c2b6b0 /src/comp/middle | |
| parent | 180db08470390ed2c350d01ae09be1e47f6135be (diff) | |
| download | rust-5fb518abc9539ef114cfe9a08fa1964d28c98ef3.tar.gz rust-5fb518abc9539ef114cfe9a08fa1964d28c98ef3.zip | |
Fix assignments to immutable fields throughout the code
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/metadata.rs | 10 | ||||
| -rw-r--r-- | src/comp/middle/resolve.rs | 11 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 15 | ||||
| -rw-r--r-- | src/comp/middle/tstate/auxiliary.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/tstate/ck.rs | 10 |
5 files changed, 25 insertions, 25 deletions
diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs index 07293e0a306..ed385dcad75 100644 --- a/src/comp/middle/metadata.rs +++ b/src/comp/middle/metadata.rs @@ -672,10 +672,9 @@ fn hash_path(&str s) -> uint { fn create_index[T](&vec[tup(T, uint)] index, fn(&T) -> uint hash_fn) -> vec[vec[tup(T, uint)]] { - let vec[vec[tup(T, uint)]] buckets = []; + let vec[mutable vec[tup(T, uint)]] buckets = vec::empty_mut(); for each (uint i in uint::range(0u, 256u)) { - let vec[tup(T, uint)] bucket = []; - buckets += [bucket]; + buckets += [mutable []]; } for (tup(T, uint) elt in index) { @@ -683,10 +682,11 @@ fn create_index[T](&vec[tup(T, uint)] index, fn(&T) -> uint hash_fn) buckets.(h % 256u) += [elt]; } - ret buckets; + ret vec::freeze(buckets); } -fn encode_index[T](&ebml::writer ebml_w, &vec[vec[tup(T, uint)]] buckets, +fn encode_index[T](&ebml::writer ebml_w, + &vec[vec[tup(T, uint)]] buckets, fn(&io::writer, &T) write_fn) { auto writer = io::new_writer_(ebml_w.writer); diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 01570dc7789..41feac5251e 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -80,7 +80,8 @@ tag mod_index_entry { type mod_index = hashmap[ident,list[mod_index_entry]]; type indexed_mod = rec(option::t[ast::_mod] m, - mod_index index, vec[def] glob_imports, + mod_index index, + mutable vec[def] glob_imports, hashmap[str,import_state] glob_imported_names); /* native modules can't contain tags, and we don't store their ASTs because we only need to look at them to determine exports, which they can't control.*/ @@ -141,7 +142,7 @@ fn map_crate(&@env e, &@ast::crate c) { // Register the top-level mod e.mod_map.insert(-1, @rec(m=some(c.node.module), index=index_mod(c.node.module), - glob_imports=vec::empty[def](), + mutable glob_imports=vec::empty[def](), glob_imported_names =new_str_hash[import_state]())); @@ -160,7 +161,7 @@ fn map_crate(&@env e, &@ast::crate c) { case (ast::item_mod(_, ?md, ?defid)) { e.mod_map.insert(defid._1, @rec(m=some(md), index=index_mod(md), - glob_imports=vec::empty[def](), + mutable glob_imports=vec::empty[def](), glob_imported_names =new_str_hash[import_state]())); e.ast_map.insert(defid, i); @@ -169,7 +170,7 @@ fn map_crate(&@env e, &@ast::crate c) { e.mod_map.insert(defid._1, @rec(m=none[ast::_mod], index=index_nmod(nmd), - glob_imports=vec::empty[def](), + mutable glob_imports=vec::empty[def](), glob_imported_names =new_str_hash[import_state]())); e.ast_map.insert(defid, i); @@ -850,7 +851,7 @@ fn lookup_glob_in_mod(&env e, @indexed_mod info, &span sp, auto matches = vec::filter_map[def, def] (bind l_i_m_r(e, _, sp, id, ns, dr), - info.glob_imports); + {info.glob_imports}); if (vec::len(matches) == 0u) { ret none[def]; } else if (vec::len(matches) == 1u){ diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index ab2bf5a46bd..03e9d83c53e 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5995,12 +5995,12 @@ fn trans_rec(&@block_ctxt cx, &vec[ast::field] fields, } fn trans_expr(&@block_ctxt cx, &@ast::expr e) -> result { - be trans_expr_out(cx, e, return); + ret trans_expr_out(cx, e, return); } fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) -> result { - *cx = rec(sp=e.span with *cx); + // FIXME Fill in cx.sp alt (e.node) { case (ast::expr_lit(?lit, ?ann)) { ret res(cx, trans_lit(cx.fcx.lcx.ccx, *lit, ann)); @@ -6059,7 +6059,6 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) } case (ast::expr_block(?blk, ?ann)) { - *cx = rec(sp=blk.span with *cx); auto sub_cx = new_scope_block_ctxt(cx, "block-expr body"); auto next_cx = new_sub_block_ctxt(cx, "next"); auto sub = with_out_method(bind trans_block(sub_cx, blk, _), @@ -6072,7 +6071,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) case (ast::expr_move(?dst, ?src, _)) { auto lhs_res = trans_lval(cx, dst); assert (lhs_res.is_mem); - *(lhs_res.res.bcx) = rec(sp=src.span with *(lhs_res.res.bcx)); + // FIXME Fill in lhs_res.res.bcx.sp auto rhs_res = trans_lval(lhs_res.res.bcx, src); auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, src); // FIXME: calculate copy init-ness in typestate. @@ -6084,7 +6083,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) case (ast::expr_assign(?dst, ?src, _)) { auto lhs_res = trans_lval(cx, dst); assert (lhs_res.is_mem); - *(lhs_res.res.bcx) = rec(sp=src.span with *(lhs_res.res.bcx)); + // FIXME Fill in lhs_res.res.bcx.sp auto rhs_res = trans_expr(lhs_res.res.bcx, src); auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, src); // FIXME: calculate copy init-ness in typestate. @@ -6097,7 +6096,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, src); auto lhs_res = trans_lval(cx, dst); assert (lhs_res.is_mem); - *(lhs_res.res.bcx) = rec(sp=src.span with *(lhs_res.res.bcx)); + // FIXME Fill in lhs_res.res.bcx.sp auto rhs_res = trans_expr(lhs_res.res.bcx, src); if (ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) { alt (op) { @@ -7182,7 +7181,7 @@ fn zero_alloca(&@block_ctxt cx, ValueRef llptr, ty::t t) -> result { } fn trans_stmt(&@block_ctxt cx, &ast::stmt s) -> result { - *cx = rec(sp=s.span with *cx); + // FIXME Fill in cx.sp auto bcx = cx; alt (s.node) { case (ast::stmt_expr(?e,_)) { @@ -7352,7 +7351,7 @@ fn alloc_local(&@block_ctxt cx, &@ast::local_ local) -> result { fn trans_block(&@block_ctxt cx, &ast::block b, &out_method output) -> result { auto bcx = cx; for each (@ast::local_ local in block_locals(b)) { - *bcx = rec(sp=local_rhs_span(local, cx.sp) with *bcx); + // FIXME Update bcx.sp bcx = alloc_local(bcx, local).bcx; } auto r = res(bcx, C_nil()); diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index 9b5c44bc6ad..df715da7c0f 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -255,7 +255,7 @@ type constr_map = @std::map::hashmap[def_id, constraint]; type fn_info = rec(constr_map constrs, uint num_constraints, controlflow cf); /* mapping from node ID to typestate annotation */ -type node_ann_table = @mutable vec[ts_ann]; +type node_ann_table = @mutable vec[mutable ts_ann]; /* mapping from function name to fn_info map */ type fn_info_map = @std::map::hashmap[def_id, fn_info]; @@ -485,7 +485,7 @@ fn num_constraints(fn_info m) -> uint { } fn new_crate_ctxt(ty::ctxt cx) -> crate_ctxt { - let vec[ts_ann] na = []; + let vec[mutable ts_ann] na = vec::empty_mut(); ret rec(tcx=cx, node_anns=@mutable na, fm=@new_def_hash[fn_info]()); } diff --git a/src/comp/middle/tstate/ck.rs b/src/comp/middle/tstate/ck.rs index 27e885e66d8..0ebc3541ef9 100644 --- a/src/comp/middle/tstate/ck.rs +++ b/src/comp/middle/tstate/ck.rs @@ -114,9 +114,9 @@ fn check_states_stmt(&fn_ctxt fcx, &stmt s) -> () { fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &ann a) -> () { auto enclosing = fcx.enclosing; auto nv = num_constraints(enclosing); - auto post = @empty_poststate(nv); + auto post = @mutable empty_poststate(nv); - fn do_one_(fn_ctxt fcx, &@stmt s, @poststate post) -> () { + fn do_one_(fn_ctxt fcx, &@stmt s, @mutable poststate post) -> () { check_states_stmt(fcx, *s); *post = stmt_poststate(fcx.ccx, *s); } @@ -124,7 +124,7 @@ fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &ann a) -> () { auto do_one = bind do_one_(fcx, _, post); vec::map[@stmt, ()](do_one, f.body.node.stmts); - fn do_inner_(fn_ctxt fcx, &@expr e, @poststate post) -> () { + fn do_inner_(fn_ctxt fcx, &@expr e, @mutable poststate post) -> () { check_states_expr(fcx, e); *post = expr_poststate(fcx.ccx, e); } @@ -135,7 +135,7 @@ fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &ann a) -> () { /* Finally, check that the return value is initialized */ let aux::constr_ ret_c = rec(id=fcx.id, c=aux::ninit(fcx.name)); if (f.proto == ast::proto_fn - && ! promises(fcx, *post, ret_c) + && ! promises(fcx, {*post}, ret_c) && ! type_is_nil(fcx.ccx.tcx, ret_ty_of_fn(fcx.ccx.tcx, a)) && cf == return) { @@ -149,7 +149,7 @@ fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &ann a) -> () { // check that this really always fails // the fcx.id bit means "returns" for a returning fn, // "diverges" for a non-returning fn - if (! promises(fcx, *post, ret_c)) { + if (! promises(fcx, {*post}, ret_c)) { fcx.ccx.tcx.sess.span_err(f.body.span, "In non-returning function " + fcx.name + ", some control paths may return to the caller"); |
