[−][src]Module rustc_query_system::dep_graph::dep_node

This module defines the DepNode type which the compiler uses to represent nodes in the dependency graph. A DepNode consists of a DepKind (which specifies the kind of thing it represents, like a piece of HIR, MIR, etc) and a Fingerprint, a 128 bit hash value the exact meaning of which depends on the node's DepKind. Together, the kind and the fingerprint fully identify a dependency node, even across multiple compilation sessions. In other words, the value of the fingerprint does not depend on anything that is specific to a given compilation session, like an unpredictable interning key (e.g., NodeId, DefId, Symbol) or the numeric value of a pointer. The concept behind this could be compared to how git commit hashes uniquely identify a given commit and has a few advantages:

DepNode definition happens in librustc_middle with the define_dep_nodes!() macro. This macro defines the DepKind enum and a corresponding DepConstructor enum. The DepConstructor enum links a DepKind to the parameters that are needed at runtime in order to construct a valid DepNode fingerprint.

Because the macro sees what parameters a given DepKind requires, it can "infer" some properties for each kind of DepNode:

Structs

DepNode
WorkProductId

A "work product" corresponds to a .o (or other) file that we save in between runs. These IDs do not have a DefId but rather some independent path or string that persists between runs without the need to be mapped or unmapped. (This ensures we can serialize them even in the absence of a tcx.)

Traits

DepNodeParams