CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

rust-lang/rust

Scanned commit c64de18c55 dated 2026-09-22 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/rust-lang/rust ↗ · 4000 files · 28.0 MB · scan capped

[Website][Rust] | [Getting started] | [Learn] | [Documentation] | [Contributing] This is the main source code repository for [Rust].

Deep analysis by swe-2 via the devin CLI on 2026-09-22 (runtime not recorded) — every claim below links to its cited source files.

Overview

This is rust-lang/rust, the monorepo for the Rust programming language: it contains the rustc compiler (~70 rustc_* crates under compiler/), the standard library (library/core, alloc, std), the 'bootstrap' build system invoked via ./x, the compiletest test harness, in-tree documentation including the rustc-dev-guide, and externally-maintained tool subtrees (clippy, rustfmt, miri, rust-analyzer). The rustc binary itself is a thin shell (compiler/rustc/src/main.rs) that delegates to rustc_driver_impl::run_compiler, which orchestrates parsing, macro expansion, the demand-driven query system (TyCtxt), and a pluggable codegen backend (default: LLVM). Everything — building, testing, formatting, dist — flows through the ./x bootstrap entry point rather than direct cargo invocations.

System map

The repo is a Cargo workspace whose members are the rustc binary crate plus ~35 in-tree tools; the compiler proper is ~70 rustc_* crates under compiler/, the standard library is a separate workspace under library/, and src/bootstrap is a self-contained build system excluded from the workspace. The rustc binary is a stub that links rustc_driver as a dylib and calls rustc_driver::main(). The heart of the compiler is the query system defined in compiler/rustc_middle/src/queries.rs and wired together in rustc_interface::passes::DEFAULT_QUERY_PROVIDERS. Build/test orchestration is bootstrap (x.py -> src/bootstrap), and CI is GitHub Actions whose job matrix is computed by the in-tree citool crate from src/ci/github-actions/jobs.yml.

All 13 system map claims →

Feature catalog

User-facing surface = the rustc CLI plus the ./x build CLI plus the bundled tools and libraries. rustc supports the usual compile driver flags plus --print, --explain, -Zunpretty pretty-printing, --check-cfg validation, pluggable codegen backends via -Zcodegen-backend, incremental compilation, MIR emission, and hundreds of lints. ./x exposes subcommands like build/check/test/doc/dist/fmt/miri implemented as bootstrap Steps. The repo also ships rustdoc (with JSON output), the test harness crate library/test, and subtrees for clippy/rustfmt/miri/rust-analyzer.

All 13 feature catalog claims →

Data flow

Data enters as a source file (or string) plus CLI options, is lexed/parsed into an AST, expanded and lowered to HIR, then nearly everything else is demand-driven through the TyCtxt query system: type checking, trait solving, borrow checking, MIR construction/transforms, monomorphization, and finally codegen through a CodegenBackend trait to object files and a linked binary. Cross-crate state travels via rustc_metadata .rmeta blobs in rlibs/dylibs; incremental state is a serialized dep-graph+query cache; diagnostics flow out through rustc_errors' DiagCtxt. Bootstrap's data flow is stage0 binaries -> stage1 artifacts -> stage2 artifacts under build/.

All 13 data flow claims →

Behavior traces

Three flows traced end-to-end. (1) ./x build: x.py -> bootstrap.py downloads stage0 per src/stage0 -> builds bootstrap binary -> cli_main::main -> Flags::parse -> Config::parse -> out/lock -> Builder runs Step descriptions. (2) rustc hello.rs: main.rs -> rustc_driver_impl::main -> run_compiler -> interface::run_compiler -> parse -> create_and_enter_global_ctxt -> resolver_for_lowering -> analysis -> Linker::codegen_and_build_linker -> link. (3) ./x test: bootstrap test steps build compiletest -> run_tests walks suite dirs -> directive parsing -> per-mode runtest runners -> snapshot diffing. CI is a fourth: ci.yml -> citool matrix -> run-build-from-ci.sh -> x.

Testing signals

Testing is dominated by compiletest-driven suites under tests/ (~27k .rs files; tests/ui alone has ~21k), organized by 15 TestModes with //@-style file directives. Unit tests live inside compiler crates as #[cfg(test)] modules and in library/coretests + alloctests. tidy enforces repo-wide hygiene. CI runs everything via the citool-computed matrix in jobs.yml, and bootstrap itself has python and Rust self-tests. Coverage tests exercise LLVM source-based coverage; rustdoc has html/json/js/gui suites.

Risk map

The dominant risks are soundness and supply-chain. AGENTS.md explicitly classifies the query system, type checking, trait solving, MIR, borrow checking, const eval, layout, and codegen as soundness-sensitive where LLM implementation is banned. The compiler dlopens codegen backends and proc-macro dylibs, executes test binaries, downloads stage0 toolchains, and deserializes incremental caches — all trust boundaries. Several giant files (runtest.rs ~3.2k lines, queries.rs ~2.9k) concentrate coupling, and externally-maintained subtrees must not be edited in-place.

All 14 risk map claims →

Extension points

rustc is unusually extensible: the CodegenBackend trait supports drop-in backends loaded as dylibs, Config exposes override_queries/register_lints/file_loader/make_codegen_backend/track_state/psess_created hooks for custom drivers, and the query system is a registry where adding a query is a declaration plus a provider. Bootstrap adds steps via the Step trait + describe! macro; compiletest adds modes via the TestMode enum + a runtest module + directives; tidy adds checks as modules; new targets are TOML-less spec modules; lints, features, attributes, and diagnostics are all declare-and-register tables.

All 14 extension points claims →

Contributor handoff

AGENTS.md is the controlling document and is unusually strict: a named human reviewer must be named in-conversation before any edit, certain text categories (PR text, diagnostics, doc prose) are prohibited for LLMs, bug fixes require an observed failing test first, and all soundness-sensitive implementation is banned outright — test-only work is allowed there. External subtrees must be routed upstream. Operationally: use ./x for everything (never cargo directly), ./x fmt for formatting, ./x test tidy for style gates, bootstrap.toml for config, and expect builds/tests to run under build/. Read the in-tree rustc-dev-guide (src/doc/rustc-dev-guide) for architecture.

All 13 contributor handoff claims →

Languages

LanguageFilesShare of source
Rust3894497%
Markdown1485docs/config
TOML6312%
JavaScript1660%
HTML140docs/config
Shell1390%
C1310%
YAML78docs/config

Start reading here

Probable source entrypoint: Cargo.toml — inferred from the directory tree and manifest, not the upstream docs.

Source roots

src/ (985 files)

Repository structure

Top-level pathFiles
src/985
compiler/985
library/985
tests/984
.github/18
LICENSES/12

Docs found: AGENTS.mdCLAUDE.mdCONTRIBUTING.mdREADME.md

Package

Cargo.toml — , 0 declared dependencies.

CI & config entrypoints

Structural health signals

Average score 7.4/10 across 96 analyzed source files; 30 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history