diff options
Diffstat (limited to 'compiler/rustc_parse/src/parser/nonterminal.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/nonterminal.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 5c4a2785d6e..0c43e304f1e 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -61,7 +61,8 @@ impl<'a> Parser<'a> { }, _ => false, }, - NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => match token.kind { + NonterminalKind::PatParam { .. } | NonterminalKind::PatWithOr { .. } => { + match token.kind { token::Ident(..) | // box, ref, mut, and other identifiers (can stricten) token::OpenDelim(token::Paren) | // tuple pattern token::OpenDelim(token::Bracket) | // slice pattern @@ -75,10 +76,11 @@ impl<'a> Parser<'a> { token::Lt | // path (UFCS constant) token::BinOp(token::Shl) => true, // path (double UFCS) // leading vert `|` or-pattern - token::BinOp(token::Or) => matches!(kind, NonterminalKind::Pat2021 {..}), + token::BinOp(token::Or) => matches!(kind, NonterminalKind::PatWithOr {..}), token::Interpolated(ref nt) => may_be_ident(nt), _ => false, - }, + } + } NonterminalKind::Lifetime => match token.kind { token::Lifetime(_) => true, token::Interpolated(ref nt) => { @@ -118,10 +120,10 @@ impl<'a> Parser<'a> { return Err(self.struct_span_err(self.token.span, "expected a statement")); } }, - NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => { + NonterminalKind::PatParam { .. } | NonterminalKind::PatWithOr { .. } => { token::NtPat(self.collect_tokens_no_attrs(|this| match kind { - NonterminalKind::Pat2015 { .. } => this.parse_pat_no_top_alt(None), - NonterminalKind::Pat2021 { .. } => { + NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None), + NonterminalKind::PatWithOr { .. } => { this.parse_pat_allow_top_alt(None, RecoverComma::No) } _ => unreachable!(), |
