diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-02 20:20:24 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-02 20:20:24 +0100 |
commit | 7faec1c30046769d4ae490e15cf5405bcfbdeef8 (patch) | |
tree | 6d268b721027a5350928a6c5a0ec227b5fde8ebc /crates/ra_syntax/src/validation | |
parent | a8397deab914240aca8f015fb3736689919c0a5b (diff) | |
parent | e94587e3153b52684fd3f6b82c8e7efc09ff5c8d (diff) |
Merge #1752
1752: Always wrap blocks into block expressions r=flodiebold a=matklad
This way, things like function bodies are expressions, and we don't have to single them out
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/validation')
-rw-r--r-- | crates/ra_syntax/src/validation/block.rs | 20 |
1 files changed, 10 insertions, 10 deletions
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 | ||
8 | pub(crate) fn validate_block_node(node: ast::Block, errors: &mut Vec<SyntaxError>) { | 8 | pub(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 | } |