rustc
$ rustc Official Low RiskThe official Rust compiler frontend and LLVM/Cranelift codegen driver. While multi-crate workspaces use cargo, rustc exposes --error-format=json diagnostics, --emit=metadata fast type-checking, --explain error code lookups, and --print target-list for target introspection.
brew install rust Direct local compiler invoked standalone for single files or orchestrated by cargo.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
First-class --error-format=json, --color=never, --print, and --explain flags with zero interactive prompts.
- Native
--error-format=jsonemits spans and suggested fixes - Supports
--explainand--printqueries
Zero network or credential access; purely local compilation with explicit -o output control.
- Deterministic local execution with no remote side effects
Distributed globally via rustup and brew install rust on macOS, Linux, and Windows.
- Cross-platform
rustuptoolchain support
Essential compiler backend, though real multi-file projects should invoke cargo rather than raw rustc.
- Best suited to single-file checks, target queries, and error explanations
Official Rust Foundation compiler with six-week release cadence and strong stability guarantees.
- Official
rust-lang/rustrepository
Dedicated rustc Book and built-in --explain error catalog.
- Official docs at doc.rust-lang.org/rustc
Security, Auth & Guardrails
No authentication required; operates strictly on local source files and installed Rust sysroots.
Dual MIT / Apache-2.0 open-source compiler; completely free.
# rustc Agent Rules - Use `cargo check --message-format=json` for Cargo projects; invoke `rustc` directly only for standalone `.rs` files or `--explain` / `--print` queries. - Always pass `--error-format=json --color=never` when parsing compiler diagnostics.
Agent-Ready Command Recipes
Safe Read-Only Queries
rustc --explain E0382
Prints detailed official examples and remediation guidance for a specific compiler error code.
rustc --print target-list
Outputs all built-in cross-compilation target triples without modifying disk state.
Controlled Writes & Previews
rustc --error-format=json --color=never main.rs -o build/main
Compiles main.rs to build/main while emitting structured JSON diagnostics on stderr.
Strengths for Agents
- +
--error-format=jsondelivers exact byte/line spans and machine-applicable fix suggestions. - +
rustc --explain <CODE>resolves borrow-checker errors offline without web searches.
Caveats & Pitfalls
- ! Does not resolve external crates from
Cargo.toml; usecargofor workspace builds. - ! Cross-compiling requires adding the target sysroot via
rustup target add.