rust/crates/ra_syntax/src/validation/block.rs

25 lines
621 B
Rust
Raw Normal View History

//! FIXME: write short doc here
use crate::{
ast::{self, AstNode, AttrsOwner},
2019-02-20 13:16:14 +00:00
SyntaxError,
SyntaxErrorKind::*,
SyntaxKind::*,
};
2019-09-02 16:33:02 +00:00
pub(crate) fn validate_block_expr(expr: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
if let Some(parent) = expr.syntax().parent() {
match parent.kind() {
2019-09-02 16:33:02 +00:00
FN_DEF | EXPR_STMT | BLOCK => return,
_ => {}
}
}
2019-09-02 16:33:02 +00:00
if let Some(block) = expr.block() {
errors.extend(
block
.attrs()
.map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())),
)
}
}