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
Destructuring assignment doesn't work for bare unit structs #118753
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.
changed the title [-]Destructuring assignment doesn't work for unit structs[/-][+]Destructuring assignment doesn't work for bare unit structs[/+]on Dec 8, 2023
Activity
jsgf commentedon Dec 8, 2023
Oh, this was supposed to have been fixed in 1.62.0 with #95380. But that implements:
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.
jsgf commentedon Dec 8, 2023
does work, using the "
{}can be used on any unit struct" loophole.[-]Destructuring assignment doesn't work for unit structs[/-][+]Destructuring assignment doesn't work for bare unit structs[/+]Rollup merge of rust-lang#118759 - compiler-errors:bare-unit-structs,…
Unrolled build for rust-lang#118759