mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-28 14:24:23 +00:00
Rename ra_syntax -> syntax
This commit is contained in:
parent
3d6889cba7
commit
a1c187eef3
958 changed files with 353 additions and 363 deletions
22
crates/syntax/src/validation/block.rs
Normal file
22
crates/syntax/src/validation/block.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
//! Logic for validating block expressions i.e. `ast::BlockExpr`.
|
||||
|
||||
use crate::{
|
||||
ast::{self, AstNode, AttrsOwner},
|
||||
SyntaxError,
|
||||
SyntaxKind::*,
|
||||
};
|
||||
|
||||
pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
|
||||
if let Some(parent) = block.syntax().parent() {
|
||||
match parent.kind() {
|
||||
FN | EXPR_STMT | BLOCK_EXPR => return,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
errors.extend(block.attrs().map(|attr| {
|
||||
SyntaxError::new(
|
||||
"A block in this position cannot accept inner attributes",
|
||||
attr.syntax().text_range(),
|
||||
)
|
||||
}))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue