Add expr_2021 nonterminal and feature flag
This commit adds a new nonterminal `expr_2021` in macro patterns, and `expr_fragment_specifier_2024` feature flag. For now, `expr` and `expr_2021` are treated the same, but in future PRs we will update `expr` to match to new grammar. Co-authored-by: Vincezo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
parent
030a12ce2b
commit
ef6478ba5f
10 changed files with 48 additions and 3 deletions
|
@ -433,3 +433,10 @@ pub struct ExpectedParenOrBrace<'a> {
|
|||
pub span: Span,
|
||||
pub token: Cow<'a, str>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_expr_2021_is_experimental)]
|
||||
pub struct Expr2021IsExperimental {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
|
@ -1290,7 +1290,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
|
|||
// maintain
|
||||
IsInFollow::Yes
|
||||
}
|
||||
NonterminalKind::Stmt | NonterminalKind::Expr => {
|
||||
NonterminalKind::Stmt | NonterminalKind::Expr | NonterminalKind::Expr2021 => {
|
||||
const TOKENS: &[&str] = &["`=>`", "`,`", "`;`"];
|
||||
match tok {
|
||||
TokenTree::Token(token) => match token.kind {
|
||||
|
|
|
@ -92,6 +92,12 @@ pub(super) fn parse(
|
|||
token::NonterminalKind::Ident
|
||||
},
|
||||
);
|
||||
if kind == token::NonterminalKind::Expr2021
|
||||
&& !features.expr_fragment_specifier_2024
|
||||
{
|
||||
sess.dcx()
|
||||
.emit_err(errors::Expr2021IsExperimental { span });
|
||||
}
|
||||
result.push(TokenTree::MetaVarDecl(span, ident, Some(kind)));
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue