Closed
Description
When changing a pattern binding from something like
match some_value {
SomeEnum::SomeVariant { ref some_field } => { /* do something with some_field */ },
_ => {}
}
to something like
match some_value {
SomeEnum::SomeVariant { some_field: ref alias } => { /* do something with alias */ },
_ => {}
}
it's easy to end up with
match some_value {
SomeEnum::SomeVariant { ref some_field: alias } => { /* do something with alias */ },
_ => {}
}
which yields an unhelpful syntax error message (playground). I don't believe it's obvious why ref some_field
and some_field: alias
are valid, but ref some_field: alias
is not. The same holds for ref 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.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.