mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
internal: more reasonable grammar for blocks
Consider these expples { 92 } async { 92 } 'a: { 92 } #[a] { 92 } Previously the tree for them were BLOCK_EXPR { ... } EFFECT_EXPR async BLOCK_EXPR { ... } EFFECT_EXPR 'a: BLOCK_EXPR { ... } BLOCK_EXPR #[a] { ... } As you see, it gets progressively worse :) The last two items are especially odd. The last one even violates the balanced curleys invariant we have (#10357) The new approach is to say that the stuff in `{}` is stmt_list, and the block is stmt_list + optional modifiers BLOCK_EXPR STMT_LIST { ... } BLOCK_EXPR async STMT_LIST { ... } BLOCK_EXPR 'a: STMT_LIST { ... } BLOCK_EXPR #[a] STMT_LIST { ... }
This commit is contained in:
parent
c51a3c78cf
commit
2bf81922f7
233 changed files with 11762 additions and 11343 deletions
|
@ -86,8 +86,8 @@ pub(super) fn try_expr(
|
|||
ast::Fn(fn_) => sema.to_def(&fn_)?.ret_type(sema.db),
|
||||
ast::Item(__) => return None,
|
||||
ast::ClosureExpr(closure) => sema.type_of_expr(&closure.body()?)?.original,
|
||||
ast::EffectExpr(effect) => if matches!(effect.effect(), ast::Effect::Async(_) | ast::Effect::Try(_)| ast::Effect::Const(_)) {
|
||||
sema.type_of_expr(&effect.block_expr()?.into())?.original
|
||||
ast::BlockExpr(block_expr) => if matches!(block_expr.modifier(), Some(ast::BlockModifier::Async(_) | ast::BlockModifier::Try(_)| ast::BlockModifier::Const(_))) {
|
||||
sema.type_of_expr(&block_expr.into())?.original
|
||||
} else {
|
||||
continue;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue