2019-01-28 20:03:56 +00:00
|
|
|
use crate::{SyntaxKind::*,
|
|
|
|
ast::{self, AttrsOwner, AstNode},
|
2019-02-12 18:41:57 +03:00
|
|
|
syntax_node::{
|
2019-01-28 20:03:56 +00:00
|
|
|
SyntaxError,
|
|
|
|
SyntaxErrorKind::*,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
pub(crate) fn validate_block_node(node: &ast::Block, errors: &mut Vec<SyntaxError>) {
|
|
|
|
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-02-08 14:49:43 +03:00
|
|
|
errors
|
|
|
|
.extend(node.attrs().map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().range())))
|
2019-01-28 20:03:56 +00:00
|
|
|
}
|