diff options
| author | bors <bors@rust-lang.org> | 2024-05-17 21:54:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-17 21:54:14 +0000 |
| commit | 9b75a4388143a163b77fa7d458e4aa4dd34ac1bd (patch) | |
| tree | 4c8d8efca048351bbeea54551b0b5be141ffd17b /compiler/rustc_ast/src/token.rs | |
| parent | 1a7397988684934ae01a71f524bdfff24895d8cc (diff) | |
| parent | 3986ea0ea555ab6de8af46932da94c26aa1c28ee (diff) | |
| download | rust-9b75a4388143a163b77fa7d458e4aa4dd34ac1bd.tar.gz rust-9b75a4388143a163b77fa7d458e4aa4dd34ac1bd.zip | |
Auto merge of #123865 - eholk:expr_2021, r=fmease
Update `expr` matcher for Edition 2024 and add `expr_2021` nonterminal
This commit adds a new nonterminal `expr_2021` in macro patterns, and `expr_fragment_specifier_2024` feature flag.
This change also updates `expr` so that on Edition 2024 it will also match `const { ... }` blocks, while `expr_2021` preserves the current behavior of `expr`, matching expressions without `const` blocks.
Joint work with `@vincenzopalazzo.`
Issue #123742
Diffstat (limited to 'compiler/rustc_ast/src/token.rs')
| -rw-r--r-- | compiler/rustc_ast/src/token.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index d00352ea2e1..099a6096d0b 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -881,6 +881,8 @@ pub enum NonterminalKind { }, PatWithOr, Expr, + /// Matches an expression using the rules from edition 2021 and earlier. + Expr2021, Ty, Ident, Lifetime, @@ -910,6 +912,7 @@ impl NonterminalKind { }, sym::pat_param => NonterminalKind::PatParam { inferred: false }, sym::expr => NonterminalKind::Expr, + sym::expr_2021 if edition().at_least_rust_2021() => NonterminalKind::Expr2021, sym::ty => NonterminalKind::Ty, sym::ident => NonterminalKind::Ident, sym::lifetime => NonterminalKind::Lifetime, @@ -929,6 +932,7 @@ impl NonterminalKind { NonterminalKind::PatParam { inferred: false } => sym::pat_param, NonterminalKind::PatParam { inferred: true } | NonterminalKind::PatWithOr => sym::pat, NonterminalKind::Expr => sym::expr, + NonterminalKind::Expr2021 => sym::expr_2021, NonterminalKind::Ty => sym::ty, NonterminalKind::Ident => sym::ident, NonterminalKind::Lifetime => sym::lifetime, |
