mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Make the expansion of guard metavars begin guard non-terminals
This commit is contained in:
@@ -3464,11 +3464,7 @@ pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
|
||||
}
|
||||
|
||||
pub(crate) fn eat_metavar_guard(&mut self) -> Option<Box<Guard>> {
|
||||
self.eat_metavar_seq_with_matcher(
|
||||
|mv_kind| matches!(mv_kind, MetaVarKind::Guard),
|
||||
|this| this.parse_match_arm_guard(),
|
||||
)
|
||||
.flatten()
|
||||
self.eat_metavar_seq(MetaVarKind::Guard, |this| this.parse_match_arm_guard()).flatten()
|
||||
}
|
||||
|
||||
fn parse_match_arm_guard(&mut self) -> PResult<'a, Option<Box<Guard>>> {
|
||||
|
||||
@@ -105,7 +105,10 @@ fn may_be_ident(kind: MetaVarKind) -> bool {
|
||||
token::Lifetime(..) | token::NtLifetime(..) => true,
|
||||
_ => false,
|
||||
},
|
||||
NonterminalKind::Guard => token.is_keyword(kw::If),
|
||||
NonterminalKind::Guard => match token.kind {
|
||||
token::OpenInvisible(InvisibleOrigin::MetaVar(MetaVarKind::Guard)) => true,
|
||||
_ => token.is_keyword(kw::If),
|
||||
},
|
||||
NonterminalKind::TT | NonterminalKind::Item | NonterminalKind::Stmt => {
|
||||
token.kind.close_delim().is_none()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user