Skip to main content

Module format

Module format 

Source
Expand description

Binary format specifications for the RIDX (.ridx) index file.

All integer values are stored in little-endian format. Structures are designed for zero-copy memory-mapped reading with natural alignment.

Re-exports§

pub use crate::driver_hash::*;

Structs§

AssocTyEntry
Associated type binding inside an ImplEntry (type Item = T;, 16 bytes, 4-byte aligned).
CfgEntry
Fixed-size 8-byte cfg table entry (align 4, zero padding).
DefEntry
A definition record in the index.
DefTyEntry
Structured type/constructor descriptor keyed by def_index (16 bytes, 4-byte aligned).
DerefEntry
Deref target mapping entry for resolving autoderef chains (e.g. String -> str).
FieldEntry
Structured field row for a Struct, Union, or Enum Variant (20 bytes, 4-byte aligned).
FileEntry
File table entry: string pool offset for file path, and 64-bit source text provenance hash.
FnSigEntry
Structured function or method signature (16 bytes, align 4), sorted ascending by def_index.
GenericArgWord
Packed 32-bit generic argument word stored in ty_args.
GenericParamEntry
Structured generic parameter declaration (20 bytes, 4-byte aligned).
HashIndexEntry
Hash table entry for $O(\log N)$ or binary search lookup by string hash.
Header
Fixed-size header at offset 0 of any .ridx file (format version 5, 416 bytes; v4 is 176, v3 is 160).
HeaderV2
Fixed-size header for version 2 .ridx files (128 bytes).
ImplEntry
Structured inherent or trait impl header (32 bytes, 4-byte aligned).
LangItemEntry
Fixed-size 12-byte lang-item mapping row in lang_items, sorted by kind.
MacroDefEntry
Fixed-size 12-byte declarative macro table entry (align 4, zero wasted alignment gaps).
NoteEntry
A note record: the text a span carries, by kind.
OwnerIndexEntry
Definition owner index entry for fast lookup of methods, fields, and associated items by owner.
RefEntry
A reference/usage record pointing to a target definition or symbol.
Span
Source location span: file ID and line:column ranges (1-based, inclusive start, exclusive end).
TyBoundEntry
Trait bound entry used by Dyn, ImplTrait, and generic predicates (16 bytes).
TyDefEntry
Interned definition reference for ADTs, traits, and function items in TyArena (16 bytes).
TyDefId
32-bit interned type-level definition reference within a shard’s ty_defs table.
TyEntry
Fixed-size 16-byte interned type node in ty_entries.
TyId
32-bit interned type identifier within a shard’s TyArena.
TypeEntry
Inferred expression type record.
UseEntry
Fixed-size 28-byte module use / glob / re-export / extern crate row in uses, sorted by (owner_raw, name_str, ...) for O(log N) lookup by owner and identifier.
WherePredEntry
Structured where / inline bound / supertrait / assoc-item bound predicate (28 bytes, 4-byte aligned).

Enums§

ConstArg
Const generic / array length representation encoded inside a single u32 word.
CtorShape
Syntactic/constructor shape of a Struct, Union, or Enum Variant.
DefKind
Category of definition, matching common Rust HIR DefKind.
FloatTyWidth
Floating-point width.
FnAbiKind
Function pointer ABI category.
GenericOwner
Owner of a GenericParamEntry or WherePredEntry row (DefEntry or ImplEntry).
GenericParamKind
Discriminator of a generic parameter (1 byte).
IntTyWidth
Signed integer width.
ItemVis
Visibility level matching DefEntry.visibility (0 = Public, 1 = Crate, 2 = Restricted, 3 = Private).
LangItemKind
Canonical compiler #[lang = "..."] item (and associated trait item) identifier.
MacroDelim
Outer delimiter of the macro definition body (macro_rules! foo { ... } / ( ... ) / [ ... ]).
MacroEdition
Hygiene edition of the crate that defined the declarative macro.
SimplifiedSelfKind
Coarse head-constructor discriminator for ImplEntry.self_ty (1 byte).
TyMutability
Reference or raw-pointer mutability.
TyTag
Discriminant tag for TyEntry (Infer-free by construction).
UintTyWidth
Unsigned integer width.
UseOwner
Scope owning a UseEntry (CrateRoot = 0, Def(def_index) = def_index + 1).
UsePrimTy
Built-in primitive target for use core::primitive::* / std::primitive::* imports.
WherePredKind
Discriminator of a WherePredEntry clause (1 byte).

Constants§

BOUND_FLAG_MAYBE
CURRENT_FORMAT_VERSION
CURRENT_VERSION
DEF_TY_FLAG_DEFAULT_ASSOC
DefTyEntry.flags: trait AssocTy declaration carrying a default type (type Item = DefaultTy;).
DEF_TY_FLAG_FUNDAMENTAL
DefTyEntry.flags: #[fundamental] ADT (Box<T>, Pin<P>).
DEF_TY_FLAG_MUT_STATIC
DefTyEntry.flags: static mut (Mutability::Mut).
DEF_TY_FLAG_NON_EXHAUSTIVE
DefTyEntry.flags: #[non_exhaustive] on Enum variant list or Struct/Variant field list.
DEF_TY_FLAG_UNSAFE_STATIC
DefTyEntry.flags: unsafe extern static (Safety::Unsafe).
EXTRACTOR_VERSION
FIELD_FLAG_TUPLE
FieldEntry.flags: positional tuple field (.0, .1, …).
FIELD_FLAG_UNSAFE
FieldEntry.flags: unsafe field (FieldDef.safety.is_unsafe()).
FLAG_MACRO_EXPANSION
A definition record in the index.
FLAG_REEXPORT
FN_FLAG_ASYNC
FN_FLAG_CONST
FN_FLAG_HAS_SELF
FN_FLAG_UNSAFE
FN_FLAG_VARIADIC
GENERIC_OWNER_IMPL_BIT
High-bit tag in owner_key distinguishing ImplEntry owners (0x8000_0000 | impl_index) from DefEntry owners (0..0x7fff_ffff).
GENERIC_PARAM_FLAG_HAS_DEFAULT
GenericParamEntry.flags: parameter declares a default (type T = U or const N: usize = 4).
GENERIC_PARAM_FLAG_HOST_EFFECT
GenericParamEntry.flags: compiler host/const effect parameter.
GENERIC_PARAM_FLAG_IS_SELF
GenericParamEntry.flags: implicit Self parameter (index == 0) on a Trait or TraitAlias.
GENERIC_PARAM_FLAG_SIZED
GenericParamEntry.flags: Type parameter has Sized bound (unset when ?Sized).
GENERIC_PARAM_FLAG_SYNTHETIC
GenericParamEntry.flags: synthetic impl Trait in argument position (APIT).
HEADER_V3_SIZE
Size of a version 3 header (160 bytes): before notes and TyArena sections.
HEADER_V4_SIZE
Size of a version 4 header (176 bytes): before TyArena sections.
IMPL_FLAG_CONST
ImplEntry.flags: impl const Trait for Self.
IMPL_FLAG_NEGATIVE
ImplEntry.flags: negative polarity (impl !Send for Self).
IMPL_FLAG_RESERVATION
ImplEntry.flags: compiler reservation impl (#[rustc_reservation_impl]).
IMPL_FLAG_TRAIT
ImplEntry.flags: impl Trait for Self (unset for inherent impl Self).
IMPL_FLAG_UNSAFE
ImplEntry.flags: unsafe impl Trait for Self.
LIFETIME_ELIDED
Sentinel lifetime values encoded in Ref / Dyn / GenericArgWord::from_lifetime.
LIFETIME_STATIC
MACRO_FLAG_BUILTIN
Macro carries #[rustc_builtin_macro] (compiler built-in expansion stub in core/std).
MACRO_FLAG_EXPORTED
Macro carries #[macro_export].
MACRO_FLAG_LOCAL_INNER
Macro carries #[macro_export(local_inner_macros)].
MACRO_FLAG_MACRO_RULES
Macro was defined with macro_rules! (true) vs declarative macro 2.0 (false).
MAGIC
NOTE_CALL_ARGS
The generic arguments of a call, at the callee’s name: `T` = `String`, `A` = `Global`.
NOTE_LAYOUT
The memory layout of a type, field, variant or binding, at its name: size = 8, align = 0x8, no Drop.
NO_CFG_VALUE
Sentinel value_offset indicating a bare atom predicate (#[cfg(unix)], #[cfg(test)]) as opposed to a key-value predicate (#[cfg(feature = "std")], including empty "").
USE_FLAG_EXTERN_CRATE
extern crate foo [as bar]; binding (type_def points to target crate root Mod).
USE_FLAG_GLOB
Glob import or glob re-export (use path::*;, name == "*", target Mod/Enum in type_def).
USE_FLAG_PRELUDE
Compiler-injected #[prelude_import] crate-wide prelude glob (std::prelude::rust_2021::*, etc.).
USE_FLAG_PRIM_TY
prim_tag carries a non-zero UsePrimTy in the type namespace.
USE_FLAG_REEXPORT
Exported / re-exported binding (pub use, pub(crate) use, ModChild re-export, or #[macro_export]).
USE_FLAG_UNDERSCORE
Anonymous trait import (use Trait as _;, name == "_").
WHERE_FLAG_CONST
WherePredEntry.flags: const trait bound (T: ~const Trait / const Trait).
WHERE_FLAG_HRTB
WherePredEntry.flags: higher-ranked binder for<'a> wraps this predicate.
WHERE_FLAG_NEGATIVE
WherePredEntry.flags: negative polarity (T: !Trait).

Functions§

cache_object_path
Returns the path to an object shard inside the global cache for a given unit key.
compute_source_snapshot_digest
Computes an aggregate 64-bit digest over a map of file paths to their 64-bit source hashes.
fnv1a_64
FNV-1a 64-bit string hash used across the RIDX format.
is_readable_format_version
Whether a manifest of format_version can be opened: versions 3 and 4 read with empty newer tables.
join_resolving_overlap
Joins a base root directory with a relative path, resolving any overlapping path prefix.
merge_embedded_hashes_authoritative
Merges embedded file hashes into a file_hashes map, ensuring embedded hashes are authoritative across both package-relative and absolute/canonical aliases under source_root, and dropping any conflicting aliases.
normalized_source_hash
Computes a 64-bit FNV-1a hash over source bytes after stripping UTF-8 BOM and normalizing CRLF to LF, exactly matching rustc’s internal SourceFile.src normalization.
resolve_cache_dir
Resolves the global RIDX shared cache directory for external crate dependencies. Uses $RIDX_CACHE_DIR if set, or platform default:
resolve_cache_dir_with