rust-lang/rust
Dependencies
The repository's dependency story is unusually conservative — adding a new external dependency requires team review, and the standard library has essentially zero crates.io dependencies. This page summarizes the structure.
Workspaces
There are several Cargo workspaces in this repo:
| Workspace root | Purpose |
|---|---|
Cargo.toml |
Compiler crates + most internal tools |
library/Cargo.toml |
std + core + alloc + runtime crates |
src/bootstrap/Cargo.toml |
The bootstrap binary |
compiler/rustc_codegen_cranelift/Cargo.toml |
Cranelift backend (own workspace) |
compiler/rustc_codegen_gcc/Cargo.toml |
GCC backend (own workspace) |
Each has its own Cargo.lock. Splitting into multiple workspaces is required because each has different toolchain or build constraints.
External dependencies in compiler/
The compiler uses a curated list of crates.io dependencies. Highlights:
| Crate | Used for |
|---|---|
tracing |
Compiler-wide structured logging |
tracing-subscriber |
Filter / format tracing events |
bitflags |
Bitset-of-flags types |
serde (and friends) |
JSON output (--error-format=json, -Zself-profile) |
thin-vec |
Smaller Vec<T> for sparse data |
smallvec |
Inline-buffer Vec<T> for hot paths |
parking_lot |
Faster locks than std |
rustc-demangle |
Symbol demangling |
tikv-jemallocator / tikv-jemalloc-sys |
Optional jemalloc backend |
rayon-core (forked → rustc_thread_pool) |
Parallel queries |
regex |
Limited use (e.g., tidy) |
gimli, object, addr2line |
DWARF / object file handling for backtraces |
cranelift-* |
Backend (in cranelift workspace only) |
gccjit |
Backend (in gcc workspace only) |
libc |
OS bindings (carefully scoped) |
The full list shows up in Cargo.lock. Adding a new crates.io dependency to compiler code requires:
- A team-aligned reason
- An entry in the allow-list at
src/tools/tidy/src/extdeps.rs - Tidy passing locally
- Code review for the dependency choice itself
External dependencies in library/
The standard library is as close to zero external dependencies as possible. The crates that do show up in library/Cargo.lock:
compiler-builtins(in tree, vendored as a subtree)hashbrown— implementation behindstd::collections::HashMapunicode-width— for terminal-aware string display in std internals (limited)windows-targets/windows-sys(Windows only) — system call bindingslibc(Unix only) — C library bindings (carefully gated)rustc-std-workspace-{core,alloc,std}— workspace shims for crates that need to be Cargo-built but use the in-tree std
Adding a dependency to library/ requires libs-api signoff and very strong justification — the standard library must be buildable everywhere Rust is.
Vendored subtrees
These are full external projects mirrored into the repo as Git subtrees. Changes flow upstream → here, periodically:
| Path | Upstream |
|---|---|
compiler/rustc_codegen_cranelift/ |
rust-lang/rustc_codegen_cranelift |
compiler/rustc_codegen_gcc/ |
rust-lang/rustc_codegen_gcc |
src/tools/clippy/ |
rust-lang/rust-clippy |
src/tools/miri/ |
rust-lang/miri |
src/tools/rustfmt/ |
rust-lang/rustfmt |
src/doc/rustc-dev-guide/ |
rust-lang/rustc-dev-guide |
library/stdarch/ |
rust-lang/stdarch |
library/portable-simd/ |
rust-lang/portable-simd |
library/compiler-builtins/ |
rust-lang/compiler-builtins |
library/backtrace/ |
rust-lang/backtrace-rs |
Subtree pulls happen via automation; PRs that touch only a subtree should usually go to the upstream repo first. See CONTRIBUTING.md.
Submodules
Submodules are pinned commits, fetched on demand:
| Path | Upstream |
|---|---|
src/llvm-project/ |
A fork of llvm/llvm-project |
src/tools/cargo/ |
rust-lang/cargo |
src/tools/rust-analyzer/ |
rust-lang/rust-analyzer |
src/tools/rustc-perf/ |
rust-lang/rustc-perf |
src/tools/enzyme/ |
EnzymeAD/Enzyme |
src/doc/book/, src/doc/reference/, src/doc/nomicon/, src/doc/edition-guide/, src/doc/embedded-book/, src/doc/rust-by-example/ |
Various doc repos |
src/gcc/ |
sourceware.org gcc (when needed) |
Submodules are listed in .gitmodules. They're fetched lazily by bootstrap when needed (./x build only fetches submodules required for the requested step). The "lazy submodule" handling is in src/bootstrap/src/utils/.
Workspace [patch] and replacements
The root Cargo.toml doesn't usually have [patch.crates-io] entries (it's documented as commented-out for users who want to test local crates). The notable workspace replacements are:
rustc-std-workspace-{core,alloc,std}— shim crates that allowlibrary/crates to depend oncore/alloc/stdvia crates.io-style names while actually resolving to the in-tree versions
CI dependencies
CI uses several non-Rust dependencies:
- Docker images under
src/ci/docker/define the per-job environment - LLVM (the in-tree submodule) is built or downloaded depending on
bootstrap.toml - Various platform SDKs are bundled inside the Docker images
mdbookfor doc builds (vendored as a Cargo binary, installed by bootstrap)
See also
- Tools — many of these external repos manifest as tools in this repo
- Bootstrap — how dependencies get fetched and built
- Patterns and conventions — the "do not bloat" attitude
Cargo.toml— workspace manifestCargo.lock— locked main workspacelibrary/Cargo.lock— locked library workspace
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.