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
I expected to see this being treated as a (trivial) destructuring assignment.
Instead, it fails with:
error[E0070]: invalid left-hand side of assignment
--> src/main.rs:3:10
|
3 | Unit = Unit;
| ---- ^
| |
| cannot assign to this expression
For more information about this error, try `rustc --explain E0070`.
error: could not compile `playground` (bin "playground") due to previous error
It looks like enums are also not implemented. The PR implementing this for structs seems to overlook unit structs, and I couldn't find any place claiming to implement it for enums.
Oh, this was supposed to have been fixed in 1.62.0 with #95380. But that implements:
struct Unit;
(Unit, _) = (Unit, 123);
which isn't how I read "We support the following classes of expressions ... structs (including unit)", as I'd expect all those classes of expression to be valid at the top-level of the assignment.
Rollup merge of rust-lang#118759 - compiler-errors:bare-unit-structs, r=petrochenkov
Support bare unit structs in destructuring assignments
We should be allowed to use destructuring assignments on *bare* unit structs, not just unit structs that are located within other pattern constructors.
Fixesrust-lang#118753
r? petrochenkov since you reviewed rust-lang#95380, reassign if you're busy or don't want to review this.
I tried this code:
I expected to see this being treated as a (trivial) destructuring assignment.
Instead, it fails with:
Likewise:
fails similarly.
On the other hand the very similar:
works as expected.
The RFC for this says:
It looks like enums are also not implemented. The PR implementing this for structs seems to overlook unit structs, and I couldn't find any place claiming to implement it for enums.
Meta
rustc --version --verbose
:And is also present in nightly.
The text was updated successfully, but these errors were encountered: