Remove unnecessary braces on PatWithOr patterns.

This commit is contained in:
Nicholas Nethercote 2023-08-10 20:11:22 +10:00
parent 4ab3e9d5b9
commit acd3a5e35f
2 changed files with 5 additions and 5 deletions

View File

@ -1328,7 +1328,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
_ => IsInFollow::No(TOKENS), _ => IsInFollow::No(TOKENS),
} }
} }
NonterminalKind::PatWithOr { .. } => { NonterminalKind::PatWithOr => {
const TOKENS: &[&str] = &["`=>`", "`,`", "`=`", "`if`", "`in`"]; const TOKENS: &[&str] = &["`=>`", "`,`", "`=`", "`if`", "`in`"];
match tok { match tok {
TokenTree::Token(token) => match token.kind { TokenTree::Token(token) => match token.kind {

View File

@ -64,7 +64,7 @@ impl<'a> Parser<'a> {
}, },
_ => false, _ => false,
}, },
NonterminalKind::PatParam { .. } | NonterminalKind::PatWithOr { .. } => { NonterminalKind::PatParam { .. } | NonterminalKind::PatWithOr => {
match &token.kind { match &token.kind {
token::Ident(..) | // box, ref, mut, and other identifiers (can stricten) token::Ident(..) | // box, ref, mut, and other identifiers (can stricten)
token::OpenDelim(Delimiter::Parenthesis) | // tuple pattern token::OpenDelim(Delimiter::Parenthesis) | // tuple pattern
@ -79,7 +79,7 @@ impl<'a> Parser<'a> {
token::Lt | // path (UFCS constant) token::Lt | // path (UFCS constant)
token::BinOp(token::Shl) => true, // path (double UFCS) token::BinOp(token::Shl) => true, // path (double UFCS)
// leading vert `|` or-pattern // leading vert `|` or-pattern
token::BinOp(token::Or) => matches!(kind, NonterminalKind::PatWithOr {..}), token::BinOp(token::Or) => matches!(kind, NonterminalKind::PatWithOr),
token::Interpolated(nt) => may_be_ident(nt), token::Interpolated(nt) => may_be_ident(nt),
_ => false, _ => false,
} }
@ -127,10 +127,10 @@ impl<'a> Parser<'a> {
.into_diagnostic(&self.sess.span_diagnostic)); .into_diagnostic(&self.sess.span_diagnostic));
} }
}, },
NonterminalKind::PatParam { .. } | NonterminalKind::PatWithOr { .. } => { NonterminalKind::PatParam { .. } | NonterminalKind::PatWithOr => {
token::NtPat(self.collect_tokens_no_attrs(|this| match kind { token::NtPat(self.collect_tokens_no_attrs(|this| match kind {
NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None, None), NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None, None),
NonterminalKind::PatWithOr { .. } => this.parse_pat_allow_top_alt( NonterminalKind::PatWithOr => this.parse_pat_allow_top_alt(
None, None,
RecoverComma::No, RecoverComma::No,
RecoverColon::No, RecoverColon::No,