Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Handle mutablity because of a mut reference #30

Closed
arora-aman opened this issue Dec 2, 2020 · 1 comment
Closed

Handle mutablity because of a mut reference #30

arora-aman opened this issue Dec 2, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@arora-aman
Copy link
Member

arora-aman commented Dec 2, 2020

Consider the following codesample:

#![feature(capture_disjoint_fields)]

fn main() {
    let mut t = (10, 10);

    let t1 = (&mut t, 10);

    let mut c = || {
        t1.0.0 += 10;
    };

    c();
}

The code sample is valid because t1.0 is a mutable reference to t. However today this results in an error saying t1.0.0 is not mutable.

This is because the two things that are looked at are t1 or t1.0.0 which are &(&mut, i32) and i32 respectively which are both immutable.

We need to add extra information in ty::CapturePlace storing if the place can be mutated.

@arora-aman arora-aman self-assigned this Dec 2, 2020
@arora-aman arora-aman added the bug Something isn't working label Dec 4, 2020
@arora-aman
Copy link
Member Author

rust-lang/rust#80092

@nikomatsakis nikomatsakis added this to the Feature complete milestone Feb 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants