Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

destruct struct as the left-hand side of an assignment #12322

Closed
Debonex opened this issue May 20, 2022 · 3 comments · Fixed by #12428
Closed

destruct struct as the left-hand side of an assignment #12322

Debonex opened this issue May 20, 2022 · 3 comments · Fixed by #12428
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@Debonex
Copy link

Debonex commented May 20, 2022

I noticed that we can destruct struct as the left-hand side of an assignment since rust version 1.59.0.
https://blog.rust-lang.org/2022/02/24/Rust-1.59.0.html
According to that, I wrote a simple demo, but something wrong happened.
unknown

unknown2


rust-analyzer version: (eg. output of "Rust Analyzer: Show RA Version" command)
rust-analyzer version: 7e95c14 2022-05-17 stable
rustc version: (eg. output of rustc -V)
rustc 1.61.0 (fe5b13d68 2022-05-18)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)

@Debonex
Copy link
Author

Debonex commented May 20, 2022

I've tried rust-analyzer pre-release version, cargo check and cargo test work without problem.

@flodiebold flodiebold added A-ty type system / type inference / traits / method resolution C-bug Category: bug labels May 20, 2022
@ruabmbua
Copy link
Contributor

ruabmbua commented May 23, 2022

Seems like the issue starts at parsing.

The LHS of the statement is parsed as a RecordExpr, but it should be a RecordPat.

@Veykril
Copy link
Member

Veykril commented May 23, 2022

No that is correct, destructuring assignments have an expression as the LHS. It's just a subset of expressions that are allowed there. It's just the diagnostic that seems to misfire here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants