Skip to main content

compute_symbol_semantic_hash

Function compute_symbol_semantic_hash 

Source
pub fn compute_symbol_semantic_hash(
    kind: SymbolKindTag,
    token_stream: &[u8],
) -> ContentHash
Expand description

Compute a symbol’s normalization-stable semantic_hash.

Canonical layout hd-sem-sym-v1: kind_tag ‖ 0x00 ‖ token_stream.

token_stream is produced by a DFS in document order over the symbol’s definition node, skipping comment-kind subtrees, emitting for each remaining leaf u32-LE(byte_len) ‖ exact source bytes. Length-prefixed rather than space-joined so token boundaries are unambiguous. Callers assemble the stream (they hold the tree); this owns the framing.