Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borrowck doesn't propagate mutability to supercomponents correctly #3828

Closed
nikomatsakis opened this issue Oct 22, 2012 · 0 comments
Closed
Assignees
Labels
A-lifetimes Area: Lifetimes / regions A-typesystem Area: The type system
Milestone

Comments

@nikomatsakis
Copy link
Contributor

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.

@ghost ghost assigned nikomatsakis Oct 22, 2012
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

1 participant