aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-02 17:33:02 +0100
committerAleksey Kladov <[email protected]>2019-09-02 18:15:51 +0100
commit3c2dea7f55830ba2391e5eb8525cdbb43ac666c2 (patch)
tree4856efbfaf1b52e441bd7bd8a5f6a26e454edb07 /crates/ra_syntax
parenta8397deab914240aca8f015fb3736689919c0a5b (diff)
always wrap block into an expression
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/validation.rs2
-rw-r--r--crates/ra_syntax/src/validation/block.rs20
2 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs
index ee8797410..16824f3c4 100644
--- a/crates/ra_syntax/src/validation.rs
+++ b/crates/ra_syntax/src/validation.rs
@@ -97,7 +97,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
97 for node in root.descendants() { 97 for node in root.descendants() {
98 let _ = visitor_ctx(&mut errors) 98 let _ = visitor_ctx(&mut errors)
99 .visit::<ast::Literal, _>(validate_literal) 99 .visit::<ast::Literal, _>(validate_literal)
100 .visit::<ast::Block, _>(block::validate_block_node) 100 .visit::<ast::BlockExpr, _>(block::validate_block_expr)
101 .visit::<ast::FieldExpr, _>(|it, errors| validate_numeric_name(it.name_ref(), errors)) 101 .visit::<ast::FieldExpr, _>(|it, errors| validate_numeric_name(it.name_ref(), errors))
102 .visit::<ast::RecordField, _>(|it, errors| validate_numeric_name(it.name_ref(), errors)) 102 .visit::<ast::RecordField, _>(|it, errors| validate_numeric_name(it.name_ref(), errors))
103 .accept(&node); 103 .accept(&node);
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::{
5 SyntaxKind::*, 5 SyntaxKind::*,
6}; 6};
7 7
8pub(crate) fn validate_block_node(node: ast::Block, errors: &mut Vec<SyntaxError>) { 8pub(crate) fn validate_block_expr(expr: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
9 if let Some(parent) = node.syntax().parent() { 9 if let Some(parent) = expr.syntax().parent() {
10 match parent.kind() { 10 match parent.kind() {
11 FN_DEF => return, 11 FN_DEF | EXPR_STMT | BLOCK => return,
12 BLOCK_EXPR => match parent.parent().map(|v| v.kind()) {
13 Some(EXPR_STMT) | Some(BLOCK) => return,
14 _ => {}
15 },
16 _ => {} 12 _ => {}
17 } 13 }
18 } 14 }
19 errors.extend( 15 if let Some(block) = expr.block() {
20 node.attrs().map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())), 16 errors.extend(
21 ) 17 block
18 .attrs()
19 .map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())),
20 )
21 }
22} 22}