This commit is contained in:
Astro 2023-04-29 03:18:01 +02:00
parent 53a6235307
commit ccb492e923
2 changed files with 4 additions and 6 deletions

View File

@ -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

View File

@ -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);
}