Skip to content

Commit 79f5eda

Browse files
committed
fix: fix inherit from tests
1 parent f9d44aa commit 79f5eda

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/src/lints/manual_inherit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Rule for ManualInherit {
4848
if let key_path = key_value_stmt.attrpath()?;
4949
if let Some(key_node) = key_path.attrs().next();
5050
// ensure that path has exactly one component
51-
if key_path.attrs().next().is_none();
51+
if key_path.attrs().count() == 1;
5252
if let Some(key) = Ident::cast(key_node.syntax().clone());
5353

5454
if let Some(value_node) = key_value_stmt.value();

lib/src/lints/manual_inherit_from.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ struct ManualInheritFrom;
4242

4343
impl Rule for ManualInheritFrom {
4444
fn validate(&self, node: &SyntaxElement, _sess: &SessionInfo) -> Option<Report> {
45+
println!("===");
4546
if_chain! {
4647
if let NodeOrToken::Node(node) = node;
4748
if let Some(key_value_stmt) = AttrpathValue::cast(node.clone());
48-
if let mut key_path = key_value_stmt.attrpath()?.attrs();
49-
if let Some(key_node) = key_path.next();
49+
if let key_path = key_value_stmt.attrpath()?;
50+
if let Some(key_node) = key_path.attrs().next();
5051
// ensure that path has exactly one component
51-
if key_path.next().is_none();
52+
if key_path.attrs().count() == 1;
5253
if let Some(key) = Ident::cast(key_node.syntax().clone());
5354

5455
if let Some(value_node) = key_value_stmt.value();
5556
if let Some(value) = Select::cast(value_node.syntax().clone());
56-
if let Some(index_node) = value.expr();
57+
if let Some(index_node) = value.attrpath().and_then(|attrs| attrs.attrs().next());
5758
if let Some(index) = Ident::cast(index_node.syntax().clone());
5859

5960
if key.to_string() == index.to_string();

0 commit comments

Comments
 (0)