Open-Source Wikis

/

Rust

/

Compiler

/

Other compiler crates

rust-lang/rust

Other compiler crates

A grab-bag page covering the smaller rustc_* crates that don't fit neatly into the major sections. Most of them are infrastructure: utility data structures, support for serialization, target descriptions, attribute parsing.

Data structures and primitives

Crate What it provides
rustc_data_structures The compiler's standard library: FxHashMap, FxHashSet, IndexVec, BitSet, BitMatrix, Steal, Sync*, WorkerLocal, sharded maps, stable hashing primitives, sync wrappers
rustc_arena Typed arena allocators (typed &'tcx [T], typed &'tcx T, drop arenas)
rustc_index IndexVec<I, T> and the newtype_index! macro for typed indices
rustc_index_macros Proc macro for newtype_index!
rustc_hashes FxHash and other hashing primitives shared across crates
rustc_graphviz Graphviz emission for dep graph and CFG dumps
rustc_thread_pool rustc's Rayon fork with deadlock detection
rustc_fs_util Filesystem helpers (atomic write, etc.)

Macros and serialization

Crate What it provides
rustc_macros Compiler-internal proc macros: Diagnostic, Subdiagnostic, LintDiagnostic, HashStable, TypeFoldable, TypeVisitable, Encodable_NoContext, Decodable_NoContext, query
rustc_serialize Internal binary serialization (used for .rmeta, the incremental cache, the metadata blobs)
rustc_log tracing setup, env filter installation

Spans, sources, attributes

Crate What it provides
rustc_span Span, Symbol, Ident, SourceMap, SyntaxContext (hygiene), BytePos
rustc_attr_parsing Attribute parsing — turning #[derive(Foo)], #[cfg(feature = "x")] and friends into structured data

Targets and ABI

Crate What it provides
rustc_target The list of built-in target triples and the Target struct
rustc_abi Layout, LayoutS, calling-convention metadata; reusable by Miri / external tools

rustc_target is the larger of the two; it has hundreds of target spec files under compiler/rustc_target/src/spec/targets/ — one per supported triple.

Unicode / ICU

rustc_baked_icu_data embeds a pre-compiled ICU data blob used for diagnostic message formatting (locale-aware quoting, segmentation). It's "baked" — generated and committed — to avoid an ICU build dependency at compile time. The crate that consumes it is rustc_error_messages.

Public APIs (StableMIR)

Crate What it provides
rustc_public A stable (in intent, still under development) API exposing rustc's MIR and types — formerly StableMIR
rustc_public_bridge Translates rustc internals into rustc_public shapes

These let external tools observe the compiler's view of a program without depending on the internal rustc_middle types directly. The API surface is intentionally small and is the long-term direction for tools that need rustc's analysis.

Windows resources

rustc_windows_rc handles .rc resource compilation on Windows targets — version info, icons, manifest. Used when building Rust binaries that ship native Windows resources.

Crates that mostly exist as workspace plumbing

A few entries in compiler/ are tiny wrappers or workspace-only:

  • rustc_proc_macro — small, mostly a re-export and bridge target for the proc-macro server
  • rustc_hir_id — separate from rustc_hir so dependent crates can refer to identifier types without pulling the whole HIR
  • rustc_lint_defs — separate from rustc_lint to break a dependency cycle
  • rustc_type_ir and rustc_type_ir_macros — separated so rustc_next_trait_solver can use them without depending on rustc_middle

Why so many crates?

There are ~70 rustc_* crates. The reasons are:

  1. Incremental rebuilds — touching a small crate doesn't recompile everything that imports rustc_middle.
  2. Dependency-cycle breaking — many crates exist solely to factor out types from a cycle (rustc_lint_defs, rustc_hir_id, rustc_type_ir).
  3. Documentation boundaries — each crate has an impl_doc_comment.rs or lib.rs that documents its scope.
  4. Reusabilityrustc_lexer, rustc_pattern_analysis, rustc_abi are designed to be reusable by external tools (rust-analyzer, Miri).

Entry points for modification

  • A new collection or sync primitive → rustc_data_structures
  • A new macro for compiler internals → rustc_macros
  • A new target triple → rustc_target/src/spec/targets/
  • A new ABI / layout rule → rustc_abi (and update target specs)
  • A serialization format → rustc_serialize
  • A new arena type → rustc_arena plus the matching tcx.arena field

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Other compiler crates – Rust wiki | Factory