mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
feat: Implement expr_2021
This commit is contained in:
parent
94b526fc86
commit
d34a663c70
5 changed files with 192 additions and 21 deletions
|
@ -105,6 +105,16 @@ pub(crate) enum RepeatKind {
|
|||
ZeroOrOne,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum ExprKind {
|
||||
// Matches expressions using the post-edition 2024. Was written using
|
||||
// `expr` in edition 2024 or later.
|
||||
Expr,
|
||||
// Matches expressions using the pre-edition 2024 rules.
|
||||
// Either written using `expr` in edition 2021 or earlier or.was written using `expr_2021`.
|
||||
Expr2021,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum MetaVarKind {
|
||||
Path,
|
||||
|
@ -116,7 +126,7 @@ pub(crate) enum MetaVarKind {
|
|||
Meta,
|
||||
Item,
|
||||
Vis,
|
||||
Expr,
|
||||
Expr(ExprKind),
|
||||
Ident,
|
||||
Tt,
|
||||
Lifetime,
|
||||
|
@ -277,17 +287,27 @@ fn eat_fragment_kind(
|
|||
let kind = match ident.sym.as_str() {
|
||||
"path" => MetaVarKind::Path,
|
||||
"ty" => MetaVarKind::Ty,
|
||||
"pat" => match edition(ident.span.ctx) {
|
||||
Edition::Edition2015 | Edition::Edition2018 => MetaVarKind::PatParam,
|
||||
Edition::Edition2021 | Edition::Edition2024 => MetaVarKind::Pat,
|
||||
},
|
||||
"pat" => {
|
||||
if edition(ident.span.ctx).at_least_2021() {
|
||||
MetaVarKind::Pat
|
||||
} else {
|
||||
MetaVarKind::PatParam
|
||||
}
|
||||
}
|
||||
"pat_param" => MetaVarKind::PatParam,
|
||||
"stmt" => MetaVarKind::Stmt,
|
||||
"block" => MetaVarKind::Block,
|
||||
"meta" => MetaVarKind::Meta,
|
||||
"item" => MetaVarKind::Item,
|
||||
"vis" => MetaVarKind::Vis,
|
||||
"expr" => MetaVarKind::Expr,
|
||||
"expr" => {
|
||||
if edition(ident.span.ctx).at_least_2024() {
|
||||
MetaVarKind::Expr(ExprKind::Expr)
|
||||
} else {
|
||||
MetaVarKind::Expr(ExprKind::Expr2021)
|
||||
}
|
||||
}
|
||||
"expr_2021" => MetaVarKind::Expr(ExprKind::Expr2021),
|
||||
"ident" => MetaVarKind::Ident,
|
||||
"tt" => MetaVarKind::Tt,
|
||||
"lifetime" => MetaVarKind::Lifetime,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue