mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +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
|
@ -342,14 +342,7 @@ fn inner_attributes(
|
|||
ast::Impl(it) => it.assoc_item_list()?.syntax().clone(),
|
||||
ast::Module(it) => it.item_list()?.syntax().clone(),
|
||||
ast::BlockExpr(it) => {
|
||||
use syntax::SyntaxKind::{BLOCK_EXPR , EXPR_STMT};
|
||||
// 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.
|
||||
let may_carry_attributes = matches!(
|
||||
it.syntax().parent().map(|it| it.kind()),
|
||||
Some(BLOCK_EXPR | EXPR_STMT)
|
||||
);
|
||||
if !may_carry_attributes {
|
||||
if !it.may_carry_attributes() {
|
||||
return None
|
||||
}
|
||||
syntax.clone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue