From 798bbd2e226c17024252192f939ce5c9ae59a99b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 10 Jun 2011 12:02:57 +0200 Subject: [PATCH] Fix all occurrences of writing to immutable aliases You'd be surprised. --- src/comp/front/creader.rs | 8 ++++---- src/comp/middle/resolve.rs | 13 +++++++------ src/comp/middle/trans.rs | 12 ++++++------ src/lib/extfmt.rs | 2 +- src/lib/vec.rs | 4 ++-- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/comp/front/creader.rs b/src/comp/front/creader.rs index 9a93263af35f..4cb889de16c8 100644 --- a/src/comp/front/creader.rs +++ b/src/comp/front/creader.rs @@ -585,15 +585,15 @@ fn lookup_defs(session::session sess, int cnum, vec[ast::ident] path) auto data = sess.get_external_crate(cnum).data; ret vec::map(bind lookup_def(cnum, data, _), - resolve_path(path, data)); + resolve_path(path, data)); } // FIXME doesn't yet handle re-exported externals -fn lookup_def(int cnum, vec[u8] data, &ast::def_id did) -> ast::def { - auto item = lookup_item(did._1, data); +fn lookup_def(int cnum, vec[u8] data, &ast::def_id did_) -> ast::def { + auto item = lookup_item(did_._1, data); auto kind_ch = item_kind(item); - did = tup(cnum, did._1); + auto did = tup(cnum, did_._1); auto def = alt (kind_ch as char) { case ('c') { ast::def_const(did) } diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 58f801ca48e3..ef4bab15ceed 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -806,15 +806,16 @@ fn lookup_in_local_native_mod(&env e, def_id defid, &span sp, fn lookup_in_local_mod(&env e, def_id defid, &span sp, &ident id, namespace ns, dir dr) -> option::t[def] { auto info = e.mod_map.get(defid._1); - if (dr == outside && !ast::is_exported(id, option::get(info.m))) { + if (dr == outside && !ast::is_exported(id, option::get(info.m))) { // if we're in a native mod, then dr==inside, so info.m is some _mod ret none[def]; // name is not visible - } + } alt(info.index.find(id)) { case (none) { } - case (some(?lst)) { + case (some(?lst_)) { + auto lst = lst_; while (true) { - alt ({lst}) { + alt (lst) { case (nil) { break; } case (cons(?hd, ?tl)) { auto found = lookup_in_mie(e, hd, ns); @@ -1070,7 +1071,7 @@ fn check_for_collisions(&@env e, &ast::crate c) { visit::visit_crate(c, (), visit::vtor(v)); } -fn check_mod_name(&env e, &ident name, &list[mod_index_entry] entries) { +fn check_mod_name(&env e, &ident name, list[mod_index_entry] entries) { auto saw_mod = false; auto saw_type = false; auto saw_value = false; fn dup(&env e, &span sp, &str word, &ident name) { @@ -1078,7 +1079,7 @@ fn check_mod_name(&env e, &ident name, &list[mod_index_entry] entries) { } while (true) { - alt ({entries}) { + alt (entries) { case (cons(?entry, ?rest)) { if (!option::is_none(lookup_in_mie(e, entry, ns_value))) { if (saw_value) { dup(e, mie_span(entry), "", name); } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 2ce915d0fc63..8c52093963ca 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3285,11 +3285,11 @@ fn copy_val(&@block_ctxt cx, // FIXME: We always zero out the source. Ideally we would detect the // case where a variable is always deinitialized by block exit and thus // doesn't need to be dropped. -fn move_val(&@block_ctxt cx, - copy_action action, - ValueRef dst, - ValueRef src, - &ty::t t) -> result { +fn move_val(@block_ctxt cx, + copy_action action, + ValueRef dst, + ValueRef src, + &ty::t t) -> result { if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t) || ty::type_is_native(cx.fcx.lcx.ccx.tcx, t)) { ret res(cx, cx.build.Store(src, dst)); @@ -5717,7 +5717,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ret res(sub.res.bcx, load_if_immediate(sub.res.bcx, sub.res.val, t)); } -fn with_out_method(fn(&out_method) -> result work, &@block_ctxt cx, +fn with_out_method(fn(&out_method) -> result work, @block_ctxt cx, &ast::ann ann, &out_method outer_output) -> result { auto ccx = cx.fcx.lcx.ccx; if (outer_output != return) { diff --git a/src/lib/extfmt.rs b/src/lib/extfmt.rs index 43ff490757b3..b8f246e6e136 100644 --- a/src/lib/extfmt.rs +++ b/src/lib/extfmt.rs @@ -85,7 +85,7 @@ mod ct { auto lim = str::byte_len(s); auto buf = ""; - fn flush_buf(str buf, &vec[piece] pieces) -> str { + fn flush_buf(str buf, &mutable vec[piece] pieces) -> str { if (str::byte_len(buf) > 0u) { auto piece = piece_string(buf); pieces += [piece]; diff --git a/src/lib/vec.rs b/src/lib/vec.rs index 037b26a51e3c..e1a8e6b03246 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -226,7 +226,7 @@ fn grow_set[T](&mutable vec[mutable T] v, uint index, &T initval, &T val) { v.(index) = val; } -fn grow_init_fn[T](&array[T] v, uint n, fn()->T init_fn) { +fn grow_init_fn[T](&mutable array[T] v, uint n, fn()->T init_fn) { let uint i = n; while (i > 0u) { i -= 1u; @@ -345,7 +345,7 @@ fn clone[T](&vec[T] v) -> vec[T] { ret slice[T](v, 0u, len[T](v)); } -fn plus_option[T](&vec[T] v, &option::t[T] o) -> () { +fn plus_option[T](&mutable vec[T] v, &option::t[T] o) -> () { alt (o) { case (none) {} case (some(?x)) { v += [x]; }