From 3c2dea7f55830ba2391e5eb8525cdbb43ac666c2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Sep 2019 19:33:02 +0300 Subject: always wrap block into an expression --- crates/ra_syntax/src/validation/block.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/ra_syntax/src/validation/block.rs') diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/ra_syntax/src/validation/block.rs index c5588658d..3c9e96eb3 100644 --- a/crates/ra_syntax/src/validation/block.rs +++ b/crates/ra_syntax/src/validation/block.rs @@ -5,18 +5,18 @@ use crate::{ SyntaxKind::*, }; -pub(crate) fn validate_block_node(node: ast::Block, errors: &mut Vec) { - if let Some(parent) = node.syntax().parent() { +pub(crate) fn validate_block_expr(expr: ast::BlockExpr, errors: &mut Vec) { + if let Some(parent) = expr.syntax().parent() { match parent.kind() { - FN_DEF => return, - BLOCK_EXPR => match parent.parent().map(|v| v.kind()) { - Some(EXPR_STMT) | Some(BLOCK) => return, - _ => {} - }, + FN_DEF | EXPR_STMT | BLOCK => return, _ => {} } } - errors.extend( - node.attrs().map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())), - ) + if let Some(block) = expr.block() { + errors.extend( + block + .attrs() + .map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())), + ) + } } -- cgit v1.2.3