Module rustc_hir::definitions
source · Expand description
For each definition, we track the following data. A definition
here is defined somewhat circularly as “something with a DefId
”,
but it generally corresponds to things like structs, enums, etc.
There are also some rather random cases (like const initializer
expressions) that are mostly just leftovers.
Structs
- A unique identifier that we can use to lookup a definition precisely. It combines the index of the definition’s parent (if any) with a
DisambiguatedDefPathData
. - A
DefPathHash
is a fixed-size representation of aDefPath
that is stable across crate and compilation session boundaries. It consists of two separate 64-bit hashes. The first uniquely identifies the crate thisDefPathHash
originates from (see StableCrateId), and the second uniquely identifies the correspondingDefPath
within that crate. Together they form a unique identifier within an entire crate graph. - The
DefPathTable
mapsDefIndex
es toDefKey
s and vice versa. Internally theDefPathTable
holds a tree ofDefKey
s, where eachDefKey
stores theDefIndex
of its parent. There is oneDefPathTable
for each crate. - The definition table containing node definitions. It holds the
DefPathTable
forLocalDefId
s/DefPath
s. It also stores mappings to convertLocalDefId
s to/fromHirId
s. - A pair of
DefPathData
and an integer disambiguator. The integer is normally0
, but in the event that there are multiple defs with the sameparent
anddata
, we use this field to disambiguate between them. This introduces some artificial ordering dependency but means that if you have, e.g., two impls for the same type in the same module, they do get distinctDefId
s.