mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Move inclusive range check to validation
This commit is contained in:
parent
989cebc99c
commit
a68aefdc46
5 changed files with 33 additions and 11 deletions
|
@ -103,6 +103,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
|
|||
ast::FieldExpr(it) => { validate_numeric_name(it.name_ref(), &mut errors) },
|
||||
ast::RecordField(it) => { validate_numeric_name(it.name_ref(), &mut errors) },
|
||||
ast::Visibility(it) => { validate_visibility(it, &mut errors) },
|
||||
ast::RangeExpr(it) => { validate_range_expr(it, &mut errors) },
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -227,3 +228,16 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
|
|||
.push(SyntaxError::new(SyntaxErrorKind::VisibilityNotAllowed, vis.syntax.text_range()))
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_range_expr(expr: ast::RangeExpr, errors: &mut Vec<SyntaxError>) {
|
||||
let last_child = match expr.syntax().last_child_or_token() {
|
||||
Some(it) => it,
|
||||
None => return,
|
||||
};
|
||||
if last_child.kind() == T![..=] {
|
||||
errors.push(SyntaxError::new(
|
||||
SyntaxErrorKind::InclusiveRangeMissingEnd,
|
||||
last_child.text_range(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue