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

Nodes in the dependency graph.

A node in the dependency graph is represented by a DepNode. 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. The fingerprinting approach has a few advantages:

DepNode definition happens in the define_dep_nodes!() macro. This macro defines the DepKind enum. Each DepKind has its own parameters that are needed at runtime in order to construct a valid DepNode fingerprint. However, only CompileCodegenUnit is constructed explicitly (with make_compile_codegen_unit).

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

make_compile_codegen_unit, together with DepNode::new(), ensures that only valid DepNode instances can be constructed. For example, the API does not allow for constructing parameterless DepNodes with anything other than a zeroed out fingerprint. More generally speaking, it relieves the user of the DepNode API of having to know how to compute the expected fingerprint for a given set of node parameters.

Modules

dep_kind
label_strs

Contains variant => str representations for constructing DepNode groups for tests.

Structs

DepKindStruct

This struct stores metadata about each DepKind.

Enums

DepKind

This enum serves as an index into the DEP_KINDS array.

Statics

DEP_KINDS

Traits

DepContext
DepNodeExt
DepNodeParams

Functions

dep_kind_from_label_string
make_compile_codegen_unit

Type Definitions

DepNode