refactor: improve "ident starts with number" error
This commit is contained in:
parent
c9ddb73184
commit
b4e17a5098
6 changed files with 61 additions and 20 deletions
|
@ -348,10 +348,6 @@ impl<'a> Parser<'a> {
|
|||
lo = self.token.span;
|
||||
}
|
||||
|
||||
if self.is_lit_bad_ident() {
|
||||
return Err(self.expected_ident_found());
|
||||
}
|
||||
|
||||
let pat = if self.check(&token::BinOp(token::And)) || self.token.kind == token::AndAnd {
|
||||
self.parse_pat_deref(expected)?
|
||||
} else if self.check(&token::OpenDelim(Delimiter::Parenthesis)) {
|
||||
|
@ -395,7 +391,7 @@ impl<'a> Parser<'a> {
|
|||
} else {
|
||||
PatKind::Lit(const_expr)
|
||||
}
|
||||
} else if self.can_be_ident_pat() {
|
||||
} else if self.can_be_ident_pat() || self.is_lit_bad_ident().is_some() {
|
||||
// Parse `ident @ pat`
|
||||
// This can give false positives and parse nullary enums,
|
||||
// they are dealt with later in resolve.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue