Better message when trying to assign two variables at once / match on a tuple without using parentheses #140615
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=b8d43356c6ba14b240ab12eea1f883da
Current output
Desired output
Something along the lines of:
Rationale and extra context
No response
Other cases
For this:
Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=2cb37a7ed277f032bcae34c793cdfcfb
The error is already helpful by telling us how to match a tuple:
Ideally, the error output of this code would already include the hint of how to achieve the whole thing (adding parentheses on both sides).
Rust Version
Anything else?
Motivation is this use case: https://stackoverflow.com/questions/69051429/what-is-the-function-to-get-the-quotient-and-remainder-divmod-for-rust
Also, the concern that it isn’t optimised away into one divmod if spread out across different lines.
Not a huge issue in case it's hard to recognise this case in the compiler. It’d just be a nicer error message helping to save a bit of time or helping someone not familiar with tuples and tuple destructuring.
The text was updated successfully, but these errors were encountered: