CodeVetter · Repo Unpack · Feature catalog
rust-lang/rust
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.
- rustc CLI option handling lives in rustc_driver_impl: handle_options supports -Zhelp/--help early-exit modes, --explain <code> routes to handle_explain, and --print requests are served by print_crate_info before any input is required.
- --check-cfg arguments are parsed by rustc_interface::parse_check_cfg into a CheckCfg of expected cfg names/values supporting cfg(name, values(...)), any(), none(); passing any --check-cfg enables exhaustive_names and exhaustive_values by default.
- Pretty-printing/unpretty modes (-Zunpretty) are handled in rustc_driver_impl::pretty::print, with PrintExtra::NeedsAstMap running early_lint_checks through TyCtxt when an AST map is needed, and MIR emission via pretty::emit_mir when OutputType::Mir is requested.
- Codegen backends are pluggable: rustc_interface::util::get_codegen_backend loads a backend dylib and resolves the __rustc_codegen_backend symbol (load_backend_from_dylib), selected via -Zcodegen-backend=<name> or Config::make_codegen_backend.
- rustc's lint system registers builtin lint passes through rustc_lint: register_builtins registers BuiltinCombinedPreExpansionLintPass, BuiltinCombinedEarlyLintPass, BuiltinCombinedLateLintModPass, foreign_modules, and hardwired lints into the LintStore; drivers can add more via Config::register_lints.
- -Ztime-passes is implemented by TimePassesCallbacks in rustc_driver_impl, which records total time/RSS around catch_with_exit_code(run_compiler) and prints a 'total' entry unless --print output would be corrupted.
- Incremental compilation is a first-class feature: rustc_incremental persists the dep graph and query results on disk under the incremental directory (persist/{save,load,file_format,work_product}.rs) and create_and_enter_global_ctxt loads the query-result cache before running queries.
- rustdoc lives in src/librustdoc with the binary crate at src/tools/rustdoc; it extern-crates the rustc_* internals (rustc_driver, rustc_interface, rustc_hir, etc.) loaded implicitly from the sysroot, and supports JSON output via src/rustdoc-json-types.
- The standard library ships core (dependency-free primitives), alloc, std (with a sys/ platform-abstraction layer containing pal/fs/net/thread modules), plus supporting crates: test (built-in test harness), backtrace, std_detect, portable-simd, panic_abort/panic_unwind, unwind, and compiler-builtins.
- ./x subcommands are parsed by bootstrap's Flags/Subcommand (src/bootstrap/src/core/config) and dispatched to Step implementations under src/bootstrap/src/core/build_steps/ (check.rs, clean.rs, compile.rs, dist.rs, doc.rs, format.rs, install.rs, llvm.rs, perf.rs, run.rs, setup.rs, test.rs, tool.rs, vendor.rs, gcc.rs, clippy.rs).
- compiletest (src/tools/compiletest) is the compiler test runner supporting 15 TestModes: pretty, debuginfo, codegen, rustdoc-html, rustdoc-json, codegen-units, incremental, run-make, ui, rustdoc-js, mir-opt, assembly, coverage-map, coverage-run, crashes.
- tidy (src/tools/tidy) is the repo style/consistency checker run by `./x test tidy`: it enforces alphabetical-order markers (tidy-alphabetical-start/end), license/deps rules (deps.rs, extdeps.rs), error-code registration, UI test conventions, unstable-book entries, target policy, and more via per-check modules.
- Compiler diagnostics are emitted through rustc_errors' DiagCtxt with messages modeled as rustc_error_messages::DiagMessage — either a plain Str or an Inline Fluent message; register_functions adds custom Fluent functions like STREQ. (No .ftl files exist in the tree; messages are inline.)