mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 04:04:06 +00:00
Remove match_armlist validator
This commit is contained in:
parent
96e3ac389f
commit
bb25958705
@ -3,7 +3,6 @@ mod byte_string;
|
|||||||
mod char;
|
mod char;
|
||||||
mod string;
|
mod string;
|
||||||
mod block;
|
mod block;
|
||||||
mod match_armlist;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
SourceFile, syntax_node::SyntaxError, AstNode,
|
SourceFile, syntax_node::SyntaxError, AstNode,
|
||||||
@ -20,7 +19,6 @@ pub(crate) fn validate(file: &SourceFile) -> Vec<SyntaxError> {
|
|||||||
.visit::<ast::Char, _>(self::char::validate_char_node)
|
.visit::<ast::Char, _>(self::char::validate_char_node)
|
||||||
.visit::<ast::String, _>(self::string::validate_string_node)
|
.visit::<ast::String, _>(self::string::validate_string_node)
|
||||||
.visit::<ast::Block, _>(self::block::validate_block_node)
|
.visit::<ast::Block, _>(self::block::validate_block_node)
|
||||||
.visit::<ast::MatchArmList, _>(self::match_armlist::validate_match_armlist)
|
|
||||||
.accept(node);
|
.accept(node);
|
||||||
}
|
}
|
||||||
errors
|
errors
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
use crate::{
|
|
||||||
ast::{self, AttrsOwner, AstNode},
|
|
||||||
syntax_node::{
|
|
||||||
SyntaxError,
|
|
||||||
SyntaxErrorKind::*,
|
|
||||||
Direction,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(crate) fn validate_match_armlist(node: &ast::MatchArmList, errors: &mut Vec<SyntaxError>) {
|
|
||||||
// Report errors for any inner attribute
|
|
||||||
// which has a preceding matcharm or an outer attribute
|
|
||||||
for inner_attr in node.attrs().filter(|s| s.is_inner()) {
|
|
||||||
let any_errors = inner_attr.syntax().siblings(Direction::Prev).any(|s| {
|
|
||||||
match (ast::MatchArm::cast(s), ast::Attr::cast(s)) {
|
|
||||||
(Some(_), _) => true,
|
|
||||||
// Outer attributes which preceed an inner attribute are not allowed
|
|
||||||
(_, Some(a)) if !a.is_inner() => true,
|
|
||||||
(_, Some(_)) => false,
|
|
||||||
(None, None) => false,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if any_errors {
|
|
||||||
errors.push(SyntaxError::new(InvalidMatchInnerAttr, inner_attr.syntax().range()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user