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

MIR borrowck: spurious cannot borrow immutable item error with a closure #46160

Closed
arielb1 opened this issue Nov 21, 2017 · 2 comments
Closed
Labels
C-bug Category: This is a bug.
Milestone

Comments

@arielb1
Copy link
Contributor

arielb1 commented Nov 21, 2017

e.g. this variant of the test run-pass/issue-16671.rs

fn foo<F: FnOnce()>(_f: F) { }

fn main() {
    let mut var = 0;
    foo(move|| {
        &mut var;
    });
}

Causes this error:

error[E0596]: cannot borrow immutable item `var` as mutable (Mir)
  --> ../src/test/run-pass/issue-16671.rs:18:9
   |
18 |         &mut var;
   |         ^^^^^^^^ cannot borrow as mutable
   |
   = note: Value not mutable causing this error: `_`

error: aborting due to previous error

@arielb1 arielb1 added this to the NLL prototype milestone Nov 21, 2017
@TimNN TimNN added the C-bug Category: This is a bug. label Nov 21, 2017
bors added a commit that referenced this issue Dec 1, 2017
MIR-borrowck: immutable unique closure upvars can be mutated

Fixes #46023 and #46160 (see [this comment](#46236 (comment))).
@davidtwco
Copy link
Member

Can be closed now, @arielb1 with #46236 merged?

@nikomatsakis
Copy link
Contributor

Looks like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants