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

Confusing error message when not having a variable name #73750

Closed
AZanellato opened this issue Jun 26, 2020 · 2 comments
Closed

Confusing error message when not having a variable name #73750

AZanellato opened this issue Jun 26, 2020 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@AZanellato
Copy link

I had a weird error message on the rust compiler when trying to compile something like this:

let Struct { name: "a".to_string() }

Here is a playground link that reproduces it better.

This gives out a weird expected ',' error, which wasn't at all what I was expecting. Certainly because of my sleepy state, but still weird.

@LeSeulArtichaut LeSeulArtichaut added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 26, 2020
@estebank estebank added A-parser Area: The parsing of Rust source code to an AST. and removed C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Jul 4, 2020
@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 5, 2020
@estebank
Copy link
Contributor

estebank commented Jul 6, 2020

Btw, the parser was expecting a comma because let doesn't just take identifiers, but patterns, which let's you write let Struct { name, ..} = struct_val;.

Would the following have been enough to help you?

error: expected `,`
  --> src/main.rs:10:13
   |
 9 |     let Test {
   |         ---- while parsing this pattern
10 |       name: "a".to_owned()
   |             ^^^

@AZanellato
Copy link
Author

I discovered this shortly thereafter! I think that would happen a ton. Maybe something along the lines of "Maybe you missed a name"?

But that would be awesome already 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants