Module rustc::dep_graph::dep_node[][src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

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 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:

The DepConstructor enum, 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.

Re-exports

use mir::interpret::GlobalId;
use hir::def_id::CrateNum;
use hir::def_id::DefId;
use hir::def_id::DefIndex;
use hir::def_id::CRATE_DEF_INDEX;
use hir::map::DefPathHash;
use hir::HirId;
use hir::ItemLocalId;
use ich::Fingerprint;
use ich::StableHashingContext;
use rustc_data_structures::stable_hasher::StableHasher;
use rustc_data_structures::stable_hasher::HashStable;
use std::fmt;
use std::hash::Hash;
use syntax_pos::symbol::InternedString;
use traits::query::CanonicalProjectionGoal;
use traits::query::CanonicalTyGoal;
use traits::query::CanonicalPredicateGoal;
use ty::TyCtxt;
use ty::Instance;
use ty::InstanceDef;
use ty::ParamEnv;
use ty::ParamEnvAnd;
use ty::PolyTraitRef;
use ty::Ty;
use ty::subst::Substs;

Modules

label_strs [
Experimental
]

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

Structs

DepNode [
Experimental
]
WorkProductId [
Experimental
]

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.)

Enums

DepConstructor [
Experimental
]
DepKind [
Experimental
]

Traits

DepNodeParams [
Experimental
]