Skip to content

Commit

Permalink
fix: fix inherit from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RobWalt committed Jan 10, 2025
1 parent f9d44aa commit 79f5eda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/src/lints/manual_inherit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Rule for ManualInherit {
if let key_path = key_value_stmt.attrpath()?;
if let Some(key_node) = key_path.attrs().next();
// ensure that path has exactly one component
if key_path.attrs().next().is_none();
if key_path.attrs().count() == 1;
if let Some(key) = Ident::cast(key_node.syntax().clone());

if let Some(value_node) = key_value_stmt.value();
Expand Down
9 changes: 5 additions & 4 deletions lib/src/lints/manual_inherit_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ struct ManualInheritFrom;

impl Rule for ManualInheritFrom {
fn validate(&self, node: &SyntaxElement, _sess: &SessionInfo) -> Option<Report> {
println!("===");
if_chain! {
if let NodeOrToken::Node(node) = node;
if let Some(key_value_stmt) = AttrpathValue::cast(node.clone());
if let mut key_path = key_value_stmt.attrpath()?.attrs();
if let Some(key_node) = key_path.next();
if let key_path = key_value_stmt.attrpath()?;
if let Some(key_node) = key_path.attrs().next();
// ensure that path has exactly one component
if key_path.next().is_none();
if key_path.attrs().count() == 1;
if let Some(key) = Ident::cast(key_node.syntax().clone());

if let Some(value_node) = key_value_stmt.value();
if let Some(value) = Select::cast(value_node.syntax().clone());
if let Some(index_node) = value.expr();
if let Some(index_node) = value.attrpath().and_then(|attrs| attrs.attrs().next());
if let Some(index) = Ident::cast(index_node.syntax().clone());

if key.to_string() == index.to_string();
Expand Down

0 comments on commit 79f5eda

Please sign in to comment.