mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Derive block attributes from block item tree
This commit is contained in:
parent
05b0612051
commit
e5b23e3bc1
8 changed files with 41 additions and 27 deletions
|
@ -61,6 +61,14 @@ impl ast::BlockExpr {
|
|||
pub fn tail_expr(&self) -> Option<ast::Expr> {
|
||||
self.stmt_list()?.tail_expr()
|
||||
}
|
||||
/// Block expressions accept outer and inner attributes, but only when they are the outer
|
||||
/// expression of an expression statement or the final expression of another block expression.
|
||||
pub fn may_carry_attributes(&self) -> bool {
|
||||
matches!(
|
||||
self.syntax().parent().map(|it| it.kind()),
|
||||
Some(SyntaxKind::BLOCK_EXPR | SyntaxKind::EXPR_STMT)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue