Closed
Description
With:
fn _f() {
let _x = 'label: while break 'label {};
}
we get:
warning[E0384]: cannot assign twice to immutable variable `_x`
--> src/lib.rs:2:14
|
2 | let _x = 'label: while break 'label {};
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
| |
| first assignment to `_x`
| help: make this binding mutable: `mut _x`
|
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
= note: for more information, try `rustc --explain E0729`
This seems wrong. At least from a source view, _x
is assigned to once.
Current MIR dump:
fn _f() -> () {
let mut _0: (); // return place in scope 0 at src/lib.rs:1:9: 1:9
let _1: (); // "_x" in scope 0 at src/lib.rs:2:9: 2:11
scope 1 {
}
bb0: {
StorageLive(_1); // bb0[0]: scope 0 at src/lib.rs:2:9: 2:11
StorageDead(_1); // bb0[1]: scope 0 at src/lib.rs:3:1: 3:2
return; // bb0[2]: scope 0 at src/lib.rs:3:2: 3:2
}
}
This might possibly be fixed by #61988.
Metadata
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the compiler team, which will review and decide on the PR/issue.