2019-07-04 23:05:17 +03:00
|
|
|
use crate::{
|
|
|
|
ast::{self, AstNode, AttrsOwner},
|
2019-02-20 16:16:14 +03:00
|
|
|
SyntaxError,
|
|
|
|
SyntaxErrorKind::*,
|
2019-07-04 23:05:17 +03:00
|
|
|
SyntaxKind::*,
|
2019-01-28 20:03:56 +00:00
|
|
|
};
|
|
|
|
|
2019-07-18 19:23:05 +03:00
|
|
|
pub(crate) fn validate_block_node(node: ast::Block, errors: &mut Vec<SyntaxError>) {
|
2019-01-28 20:03:56 +00:00
|
|
|
if let Some(parent) = node.syntax().parent() {
|
|
|
|
match parent.kind() {
|
|
|
|
FN_DEF => return,
|
|
|
|
BLOCK_EXPR => match parent.parent().map(|v| v.kind()) {
|
|
|
|
Some(EXPR_STMT) | Some(BLOCK) => return,
|
|
|
|
_ => {}
|
|
|
|
},
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
2019-07-20 12:58:27 +03:00
|
|
|
errors.extend(
|
|
|
|
node.attrs().map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())),
|
|
|
|
)
|
2019-01-28 20:03:56 +00:00
|
|
|
}
|