mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
always wrap block into an expression
This commit is contained in:
parent
a8397deab9
commit
3c2dea7f55
5 changed files with 19 additions and 14 deletions
|
@ -5,18 +5,18 @@ use crate::{
|
|||
SyntaxKind::*,
|
||||
};
|
||||
|
||||
pub(crate) fn validate_block_node(node: ast::Block, errors: &mut Vec<SyntaxError>) {
|
||||
if let Some(parent) = node.syntax().parent() {
|
||||
pub(crate) fn validate_block_expr(expr: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
|
||||
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())),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue