Closed
Description
Borrowck doesn't always propagate mutability correctly to base components.
Here is an example:
struct Foo {
x: uint
}
struct Bar {
foo: Foo
}
fn main() {
let mut b = Bar { foo: Foo { x: 3 } };
let p = &b;
let q = &mut b.foo.x;
let r = &p.foo.x;
io::println(fmt!("*r = %u", *r));
*q += 1;
io::println(fmt!("*r = %u", *r));
}
Here, r has type &uint
and thus *r
should always yield the same result. The problem is that when creating the loan for &mut
we propagate &const
as the required type for base loans. This causes us to miss the conflict.
I have a fix for this already prepared.