When parsing patterns, bubble all errors except reserved idents that aren't likely to appear in for head or match arm
This commit is contained in:
parent
44fd3b4d46
commit
ed084a9343
6 changed files with 221 additions and 7 deletions
|
@ -141,7 +141,19 @@ impl<'a> Parser<'a> {
|
|||
};
|
||||
|
||||
// Parse the first pattern (`p_0`).
|
||||
let mut first_pat = self.parse_pat_no_top_alt(expected, syntax_loc)?;
|
||||
let mut first_pat = match self.parse_pat_no_top_alt(expected, syntax_loc) {
|
||||
Ok(pat) => pat,
|
||||
Err(mut err)
|
||||
if self.token.is_reserved_ident()
|
||||
&& !self.token.is_keyword(kw::In)
|
||||
&& !self.token.is_keyword(kw::If) =>
|
||||
{
|
||||
err.emit();
|
||||
self.bump();
|
||||
self.mk_pat(self.token.span, PatKind::Wild)
|
||||
}
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
if rc == RecoverComma::Yes {
|
||||
self.maybe_recover_unexpected_comma(
|
||||
first_pat.span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue