blob: 2c08f7e6ed4be68434ec1b0fa42a1e73affa60b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
//! Logic for validating block expressions i.e. `ast::BlockExpr`.
use crate::{
ast::{self, AstNode, AttrsOwner},
SyntaxError,
SyntaxKind::*,
};
pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
if let Some(parent) = block.syntax().parent() {
match parent.kind() {
FN_DEF | EXPR_STMT | BLOCK_EXPR => return,
_ => {}
}
}
errors.extend(block.attrs().map(|attr| {
SyntaxError::new(
"A block in this position cannot accept inner attributes",
attr.syntax().text_range(),
)
}))
}
|