Skip to main content

verify_node_identity

Function verify_node_identity 

Source
pub fn verify_node_identity(
    nodes: &HashMap<AbsPath, HashMap<NodeId, NodeInfo>>,
    node_id: NodeId,
    expected_abs_path: &str,
    expected_name_offset: usize,
    expected_name: &str,
) -> bool
Expand description

Verify that a NodeId in a specific build refers to the expected source entity.

Node IDs are per-compilation — the same numeric ID can refer to completely different functions in different builds (e.g. ID 616 = swap in the file build, but ID 616 = some library function in a sub-cache). This function checks three properties to confirm the node is the one we expect:

  1. File — the node must exist in expected_abs_path within this build.
  2. Position — the node’s name_location byte offset must equal expected_name_offset.
  3. Name — the source text at the name_location must match expected_name.

If all three match the node is guaranteed to be the same source entity, regardless of which compilation produced the build. The check is O(1) — a single HashMap lookup + integer/string comparison.

Returns true if the node passes identity verification.