Skip to content

incorrect "cannot assign twice to immutable variable _" with try_blocks + never_type + nll #62165

New issue

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

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

Already on GitHub? # to your account

Closed
goffrie opened this issue Jun 27, 2019 · 1 comment · Fixed by #62465
Closed
Assignees
Labels
A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@goffrie
Copy link
Contributor

goffrie commented Jun 27, 2019

The following program:

#![feature(nll)]
#![feature(never_type)]
#![feature(try_blocks)]

fn main() {
    loop {
        let _x: Result<_, ()> = try {
            Err(())?;
        };
    }
}

now produces the following error, as of 2019-06-27:

error[E0384]: cannot assign twice to immutable variable `_`
 --> src/main.rs:8:13
  |
8 |             Err(())?;
  |             ^^^^^^^^ cannot assign twice to immutable variable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0384`.

(note that the playground link currently compiles; I think it's on an older nightly?)

From bisection, this appears to be a regression from #61872 (cc @matthewjasper).

Oddly, removing #![feature(never_type)] causes the problem to disappear.

@Centril Centril added A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 27, 2019
@matthewjasper
Copy link
Contributor

Minimised:

#![feature(nll, never_type)]

pub fn main() {
    loop {
        match None {
            None => return,
            Some(val) => val,
        };
    };
}

@matthewjasper matthewjasper self-assigned this Jun 29, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 10, 2019
…=pnkfelix

Sometimes generate storage statements for temporaries with type `!`

Closes rust-lang#62165
cc rust-lang#42371
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants