# Extension points — rust-lang/rust

> Canonical page: https://codevetter.com/unpack/rust/extension-points

# Extension points — rust-lang/rust

Scanned commit c64de18c55c70d62aa88a5722dea8f8e263bacf3 (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

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.
- New codegen backend: implement rustc_codegen_ssa::traits::CodegenBackend (name, init, target_config, provide, codegen/link methods) and expose it via the __rustc_codegen_backend symbol in a dylib loadable by -Zcodegen-backend, or inject it via Config::make_codegen_backend in a custom driver. — [compiler/rustc_codegen_ssa/src/traits/backend.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_codegen_ssa/src/traits/backend.rs) [compiler/rustc_interface/src/util.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/util.rs) [compiler/rustc_interface/src/interface.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/interface.rs)
- Custom drivers can override individual queries through Config::override_queries (fn(&Session, &mut Providers)) invoked after codegen_backend.provide in create_and_enter_global_ctxt — the mechanism rustc tools use to intercept analysis. — [compiler/rustc_interface/src/interface.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/interface.rs) [compiler/rustc_interface/src/passes.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/passes.rs)
- New queries: add a `query` block in compiler/rustc_middle/src/queries.rs with key/value types and modifiers; rustc_macros::rustc_queries generates the TyCtxt accessor and Providers field; implement the provider fn and register it in the owning crate's provide() chained into DEFAULT_QUERY_PROVIDERS. — [compiler/rustc_middle/src/queries.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_middle/src/queries.rs) [compiler/rustc_macros/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_macros/src/lib.rs) [compiler/rustc_interface/src/passes.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/passes.rs)
- New lints: declare_lint!/declare_lint_pass!/impl_lint_pass from rustc_lint_defs, implement an EarlyLintPass or LateLintPass in rustc_lint, and register via register_builtins' lint_vec() lists; drivers can add out-of-tree lints through Config::register_lints. — [compiler/rustc_lint/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_lint/src/lib.rs) [compiler/rustc_interface/src/interface.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/interface.rs)
- Driver hooks in interface::Config: file_loader (custom source loading, designed for rust-analyzer's VFS), psess_created (mutate ParseSess), track_state (record env/file deps into sess.env_depinfo/file_depinfo), extra_symbols (pre-interned symbols after PREDEFINED_SYMBOLS_COUNT), using_internal_features. — [compiler/rustc_interface/src/interface.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/interface.rs)
- New bootstrap step: implement the Step trait (run/should_run/make_run metadata) and list it in Builder::get_step_descriptions' describe! macro for the relevant Kind; step bodies live in src/bootstrap/src/core/build_steps/. — [src/bootstrap/src/core/builder/mod.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/bootstrap/src/core/builder/mod.rs)
- New compiletest suite/mode: add a TestMode variant in common.rs, a runner module under runtest/ (mod list is tidy-alphabetized), directive names in directives/directive_names.rs, and handlers in directives/handlers.rs' DIRECTIVE_HANDLERS_MAP. — [src/tools/compiletest/src/common.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/tools/compiletest/src/common.rs) [src/tools/compiletest/src/runtest.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/tools/compiletest/src/runtest.rs) [src/tools/compiletest/src/directives/handlers.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/tools/compiletest/src/directives/handlers.rs)
- New tidy check: add a module in src/tools/tidy/src/ and spawn it from main.rs' scoped-thread section; existing examples cover style, deps, extdeps allowlists, ui_tests conventions, target_policy, edition, and alphabetical ordering. — [src/tools/tidy/src/main.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/tools/tidy/src/main.rs)
- New compiler flag: add entries in rustc_session's options table (compiler/rustc_session/src/options.rs and options/ submodules); dep_tracking macros (hash_opt!/insert!) tie each option into incremental-crate-hash computation, and untracked options are marked [UNTRACKED]/[TRACKED_NO_CRATE_HASH]. — [compiler/rustc_session/src/options.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_session/src/options.rs)
- New target: add a spec module under compiler/rustc_target/src/spec/targets/ (335 existing target modules) — spec/json.rs also supports JSON target descriptions loaded at runtime. — [compiler/rustc_target/src/spec/mod.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_target/src/spec/mod.rs) [compiler/rustc_target/src/spec/json.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_target/src/spec/json.rs)
- New language feature: register it in rustc_feature/src/unstable.rs (and move to accepted.rs/removed.rs on stabilization/removal); builtin attributes live in builtin_attrs.rs. — [compiler/rustc_feature/src/unstable.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_feature/src/unstable.rs)
- New diagnostics: derive Diagnostic/Subdiagnostic via rustc_macros' diagnostics module and use inline Fluent DiagMessage strings; rustc_error_messages::register_functions exposes custom Fluent functions (e.g. STREQ). — [compiler/rustc_macros/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_macros/src/lib.rs) [compiler/rustc_error_messages/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_error_messages/src/lib.rs)
- New CI job: edit src/ci/github-actions/jobs.yml (runner anchors like &job-linux-4c plus job entries); citool's calculate-job-matrix turns it into the matrix consumed by ci.yml — ci.yml itself says to modify jobs.yml rather than the workflow. — [.github/workflows/ci.yml](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/.github/workflows/ci.yml) [src/ci/github-actions/jobs.yml](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/ci/github-actions/jobs.yml)
- Custom rustc-like binaries: link rustc_driver (dylib) and call rustc_driver_impl::run_compiler(at_args, callbacks) with a Callbacks impl (config/after_crate_root_parsing/after_expansion/after_analysis) — the pattern used by clippy/rustdoc-style drivers, with rustc_driver::main as the minimal example. — [compiler/rustc_driver_impl/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_driver_impl/src/lib.rs) [compiler/rustc_driver/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_driver/src/lib.rs)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
