1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::linter::{Rule, RuleResult};
use sv_parser::{unwrap_locate, GenerateBlock, RefNode, SyntaxTree};
pub struct GenerateIfWithLabel;
impl Rule for GenerateIfWithLabel {
fn check(&self, _syntax_tree: &SyntaxTree, node: &RefNode) -> RuleResult {
match node {
RefNode::IfGenerateConstruct(x) => {
let (_, _, ref a, ref b) = x.nodes;
match a {
GenerateBlock::Multiple(x) => {
let (_, _, ref a, _, _, _) = x.nodes;
if a.is_some() {
match b {
Some((e, x)) => match x {
GenerateBlock::Multiple(x) => {
let (_, _, ref a, _, _, _) = x.nodes;
if a.is_some() {
RuleResult::Pass
} else {
let locate = unwrap_locate!(e).unwrap();
RuleResult::FailLocate(locate.clone())
}
}
_ => RuleResult::Pass,
},
None => RuleResult::Pass,
}
} else {
RuleResult::Fail
}
}
_ => RuleResult::Fail,
}
}
_ => RuleResult::Pass,
}
}
fn name(&self) -> String {
String::from("generate_if_with_label")
}
fn hint(&self) -> String {
String::from("`generate if` must have label")
}
fn reason(&self) -> String {
String::from("the hierarchiral path can't be determined")
}
}