Skip to content

MIR borrowck: variables are still initialized after their storage ends #45642

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

Closed
arielb1 opened this issue Oct 30, 2017 · 1 comment · Fixed by #45936
Closed

MIR borrowck: variables are still initialized after their storage ends #45642

arielb1 opened this issue Oct 30, 2017 · 1 comment · Fixed by #45936
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug.

Comments

@arielb1
Copy link
Contributor

arielb1 commented Oct 30, 2017

MIR borrowck considers variables still initialized after their storage ends, so if an immutable variable is defined and used in a loop, this causes an error. e.g.:

fn main() {
    loop {
        let _x = 0;
    }
}

Which causes:

$ rustc x.rs -Z borrowck-mir
error[E0384]: re-assignment of immutable variable `_x` (Mir)
 --> x.rs:3:18
  |
3 |         let _x = 0;
  |                  ^

error: aborting due to previous error
@arielb1 arielb1 added A-borrow-checker Area: The borrow checker WG-compiler-nll labels Oct 30, 2017
@TimNN TimNN added the C-bug Category: This is a bug. label Oct 31, 2017
@mikhail-m1
Copy link
Contributor

working on it

bors added a commit that referenced this issue Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants