You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot assign twice to immutable variable with 'l: while break 'l {} as initializer #62115
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() -> (){letmut _0:();// return place in scope 0 at src/lib.rs:1:9: 1:9let _1:();// "_x" in scope 0 at src/lib.rs:2:9: 2:11scope1{}bb0:{StorageLive(_1);// bb0[0]: scope 0 at src/lib.rs:2:9: 2:11StorageDead(_1);// bb0[1]: scope 0 at src/lib.rs:3:1: 3:2return;// bb0[2]: scope 0 at src/lib.rs:3:2: 3:2}}
Activity
pnkfelix commentedon Jun 25, 2019
@eddyb points out that the first bullet item of PR #61872 says that it fixes this.
Centril commentedon Jun 25, 2019
Great. Then we'll just need to add a regression test to https://github.com/rust-lang/rust/blob/07e5297faf2966a77c466b0b5ad936c0deb828ac/src/test/ui/nll/assign-while-to-immutable.rs once the PR is merged.
eddyb commentedon Jun 25, 2019
@Centril once it's merged? @matthewjasper could add this test and close this issue as part of the PR.
Auto merge of #61872 - matthewjasper:refactor-mir-drop-gen, r=nikomat…