aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/validation/block.rs
blob: c85bbc1f4fc4ecec09d1bdf9a907fbd3f09e1ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! FIXME: write short doc here

use crate::{
    ast::{self, AstNode, AttrsOwner},
    SyntaxError,
    SyntaxErrorKind::*,
    SyntaxKind::*,
};

pub(crate) fn validate_block_expr(expr: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
    if let Some(parent) = expr.syntax().parent() {
        match parent.kind() {
            FN_DEF | EXPR_STMT | BLOCK => return,
            _ => {}
        }
    }
    if let Some(block) = expr.block() {
        errors.extend(
            block
                .attrs()
                .map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())),
        )
    }
}