Skip to main content

is_node_unused

Function is_node_unused 

Source
pub fn is_node_unused<S: BuildHasher>(
    node_id: NodeId,
    scope: UnusedScope,
    graph: &CodeGraph,
    reachable: Option<&HashSet<NodeId, S>>,
) -> bool
Expand description

Check if a specific node is unused based on the scope filter.

A node is considered unused if:

  1. It matches the scope filter (All, Public, Private, Function, or Struct)
  2. It is not an entry point (main, test, or export)
  3. It is not reachable from any entry point

§Arguments

  • node_id - The node to check
  • scope - Filter for which types of nodes to check
  • graph - The code graph to analyze
  • reachable - Optional pre-computed reachable set (for efficiency when checking many nodes)

§Returns

true if the node is unused and matches the scope, false otherwise. Returns false for invalid or non-existent nodes.