Module rustc_span::def_id
source · Macros§
Structs§
- A
DefIdidentifies a particular definition, by combining a crate index and a def index. - A DefIndex is an index into the hir-map for a crate, identifying a particular definition. It should really be considered an interned shorthand for a particular DefPath.
- A
DefPathHashis a fixed-size representation of aDefPaththat is stable across crate and compilation session boundaries. It consists of two separate 64-bit hashes. The first uniquely identifies the crate thisDefPathHashoriginates from (see StableCrateId), and the second uniquely identifies the correspondingDefPathwithin that crate. Together they form a unique identifier within an entire crate graph. - A
LocalDefIdis equivalent to aDefIdwithkrate == LOCAL_CRATE. Since we encode this information in the type, we can ensure at compile time that noDefIds from upstream crates get thrown into the mix. There are quite a few cases where we know that onlyDefIds from the local crate are expected; aDefIdfrom a different crate would signify a bug somewhere. This is whenLocalDefIdcomes in handy. - A
StableCrateIdis a 64-bit hash of a crate name, together with all-Cmetadataarguments, and some other data. It is toCrateNumwhatDefPathHashis toDefId. It is stable across compilation sessions.
Constants§
- The crate root is always assigned index 0 by the AST Map code, thanks to
NodeCollector::new. - Item definitions in the currently-compiled crate would have the
CrateNumLOCAL_CRATEin theirDefId.