Fix all occurrences of writing to immutable aliases

You'd be surprised.
This commit is contained in:
Marijn Haverbeke 2011-06-10 12:02:57 +02:00
parent c51c6ba354
commit 798bbd2e22
5 changed files with 20 additions and 19 deletions

View File

@ -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) }

View File

@ -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); }

View File

@ -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) {

View File

@ -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];

View File

@ -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]; }