Improve suggestion for tuple struct pattern matching errors.
Currently, when a user uses a struct pattern to pattern match on a tuple struct, the errors we emit generally suggest adding fields using their field names, which are numbers. However, numbers are not valid identifiers, so the suggestions, which use the shorthand notation, are not valid syntax. This commit changes those errors to suggest using the actual tuple struct pattern syntax instead, which is a more actionable suggestion.
This commit is contained in:
parent
058a710165
commit
8a83c8f64f
5 changed files with 118 additions and 14 deletions
|
@ -999,7 +999,7 @@ impl<'a> Parser<'a> {
|
|||
let boxed_span = self.token.span;
|
||||
let is_ref = self.eat_keyword(kw::Ref);
|
||||
let is_mut = self.eat_keyword(kw::Mut);
|
||||
let fieldname = self.parse_ident()?;
|
||||
let fieldname = self.parse_field_name()?;
|
||||
hi = self.prev_token.span;
|
||||
|
||||
let bind_type = match (is_ref, is_mut) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue