mirror of
https://github.com/astro/deadnix.git
synced 2024-11-24 09:12:50 +03:00
delint
This commit is contained in:
parent
53a6235307
commit
ccb492e923
@ -66,7 +66,7 @@ impl Settings {
|
||||
body == binding.decl_node
|
||||
// excluding already unused results
|
||||
|| dead.contains(&body)
|
||||
|| is_dead_inherit(&dead, &body)
|
||||
|| is_dead_inherit(dead, &body)
|
||||
// or not used anywhere
|
||||
|| ! usage::find(&binding.name, &body)
|
||||
)
|
||||
@ -91,15 +91,13 @@ impl Settings {
|
||||
}
|
||||
}
|
||||
|
||||
/// is node body (InheritFrom) of an inherit clause that contains only dead bindings?
|
||||
/// is node body (`InheritFrom`) of an inherit clause that contains only dead bindings?
|
||||
fn is_dead_inherit(dead: &HashSet<SyntaxNode<NixLanguage>>, node: &SyntaxNode<NixLanguage>) -> bool {
|
||||
if node.kind() != SyntaxKind::NODE_INHERIT_FROM {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(inherit) = node.parent().and_then(|parent|
|
||||
Inherit::cast(parent)
|
||||
) {
|
||||
if let Some(inherit) = node.parent().and_then(Inherit::cast) {
|
||||
inherit.attrs().all(|attr| dead.contains(attr.syntax()))
|
||||
} else {
|
||||
false
|
||||
|
@ -104,7 +104,7 @@ fn let_in_inherit_shadowed() {
|
||||
let results = run(nix);
|
||||
assert_eq!(1, results.len());
|
||||
assert_eq!(results[0].binding.name.to_string(), "x");
|
||||
let first_pos = nix.find("x").unwrap();
|
||||
let first_pos = nix.find('x').unwrap();
|
||||
assert_eq!(usize::from(results[0].binding.name.syntax().text_range().start()), first_pos);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user