Inherit mutability through fixed-length vectors.

Fixes #3226.  No review (one line bug fix).
This commit is contained in:
Niko Matsakis 2012-11-14 19:28:43 -08:00
parent f4a5a76aa4
commit b7c04d152b
2 changed files with 18 additions and 1 deletions

View File

@ -797,7 +797,8 @@ impl &mem_categorization_ctxt {
deref_comp(_) => {
// fixed-length vectors have no deref
comp(expr, base_cmt, base_cmt.ty, mt.mutbl, mt.ty)
let m = self.inherited_mutability(base_cmt.mutbl, mt.mutbl);
comp(expr, base_cmt, base_cmt.ty, m, mt.ty)
}
};

View File

@ -0,0 +1,16 @@
fn test1() {
let mut ints = [0, ..32];
ints[0] += 1;
assert ints[0] == 1;
}
fn test2() {
let mut ints = [0, ..32];
for vec::each_mut(ints) |i| { *i += 22; }
for ints.each |i| { assert *i == 22; }
}
fn main() {
test1();
test2();
}