ra_syntax: reshape SyntaxError for the sake of removing redundancy

This commit is contained in:
Veetaha 2020-02-06 02:33:18 +02:00
parent 9053003e3b
commit 9fdf984958
55 changed files with 405 additions and 638 deletions

View file

@ -1,9 +1,8 @@
//! FIXME: write short doc here
//! Logic for validating block expressions i.e. `ast::BlockExpr`.
use crate::{
ast::{self, AstNode, AttrsOwner},
SyntaxError,
SyntaxErrorKind::*,
SyntaxKind::*,
};
@ -15,10 +14,11 @@ pub(crate) fn validate_block_expr(expr: ast::BlockExpr, errors: &mut Vec<SyntaxE
}
}
if let Some(block) = expr.block() {
errors.extend(
block
.attrs()
.map(|attr| SyntaxError::new(InvalidBlockAttr, attr.syntax().text_range())),
)
errors.extend(block.attrs().map(|attr| {
SyntaxError::new(
"A block in this position cannot accept inner attributes",
attr.syntax().text_range(),
)
}))
}
}