diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-08-12 18:26:51 +0200 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-08-12 18:30:53 +0200 |
| commit | a1c187eef3ba08076aedb5154929f7eda8d1b424 (patch) | |
| tree | 9d898eb9600b0c36a74e4f95238f679c683fa566 /crates/syntax/src/validation | |
| parent | 3d6889cba72a9d02199f7adaa2ecc69bc30af834 (diff) | |
| download | rust-a1c187eef3ba08076aedb5154929f7eda8d1b424.tar.gz rust-a1c187eef3ba08076aedb5154929f7eda8d1b424.zip | |
Rename ra_syntax -> syntax
Diffstat (limited to 'crates/syntax/src/validation')
| -rw-r--r-- | crates/syntax/src/validation/block.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/syntax/src/validation/block.rs b/crates/syntax/src/validation/block.rs new file mode 100644 index 00000000000..ad990146885 --- /dev/null +++ b/crates/syntax/src/validation/block.rs @@ -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(), + ) + })) +} |
