Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/validation/block.rs')
| -rw-r--r-- | crates/syntax/src/validation/block.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/syntax/src/validation/block.rs b/crates/syntax/src/validation/block.rs index 40170014f9..e03a77749d 100644 --- a/crates/syntax/src/validation/block.rs +++ b/crates/syntax/src/validation/block.rs @@ -9,14 +9,16 @@ use crate::{ pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) { if let Some(parent) = block.syntax().parent() { match parent.kind() { - FN | EXPR_STMT | BLOCK_EXPR => return, + FN | EXPR_STMT | STMT_LIST => return, _ => {} } } - errors.extend(block.attrs().filter(|attr| attr.kind().is_inner()).map(|attr| { - SyntaxError::new( - "A block in this position cannot accept inner attributes", - attr.syntax().text_range(), - ) - })) + if let Some(stmt_list) = block.stmt_list() { + errors.extend(stmt_list.attrs().filter(|attr| attr.kind().is_inner()).map(|attr| { + SyntaxError::new( + "A block in this position cannot accept inner attributes", + attr.syntax().text_range(), + ) + })) + } } |