Unhelpful message for syntax error in pattern bindings #72298
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The lexing & parsing of Rust source code to an AST
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
When changing a pattern binding from something like
to something like
it's easy to end up with
which yields an unhelpful syntax error message (playground). I don't believe it's obvious why
ref some_field
andsome_field: alias
are valid, butref some_field: alias
is not. The same holds forref mut
bindings, of course.It would be nice if rustc's parser accepted the invalid syntax and provided one of its helpful "did you mean to write
some_field: ref alias
?" error messages.The text was updated successfully, but these errors were encountered: