Aleksey Kladov 1834bae5b8 allow rustfmt to reorder imports
This wasn't a right decision in the first place, the feature flag was
broken in the last rustfmt release, and syntax highlighting of imports
is more important anyway
2019-07-04 23:09:09 +03:00

22 lines
625 B
Rust

use crate::{
ast::{self, AstNode, AttrsOwner},
SyntaxError,
SyntaxErrorKind::*,
SyntaxKind::*,
};
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,
_ => {}
},
_ => {}
}
}
errors
.extend(node.attrs().map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().range())))
}