Skip to main content

Crate cargo_build_rx

Crate cargo_build_rx 

Source
Expand description

cargo-build-rx: a compile-time diagnostic and prescription tool for Rust projects.

The tool reads a project’s cargo metadata, its Cargo.toml, its .cargo/config.toml, and a few environment variables, then runs a set of pure-function checks over that gathered context::ProjectContext. Each check returns finding::Findings with a severity, an estimated impact, and (usually) a concrete fix. No part of the target project is compiled.

The ten checks are:

  1. linker: recommends a fast linker (mold/lld) on Linux, or split debug info on macOS.
  2. profile: flags debug = 2, opt-level > 0 in dev, and a missing build-override opt-level for proc-macros.
  3. duplicates: the same crate compiled in several distinct versions.
  4. proc-macros: the syn 1.x/2.x split and a high proc-macro count.
  5. build-scripts: an inventory of build.rs crates, flagging native links.
  6. features: heavy default feature sets (e.g. tokio full).
  7. dev-deps: heavy dev-dependencies such as criterion or proptest.
  8. toolchain: the installed toolchain versus the project’s MSRV.
  9. workspace: large workspaces without a workspace-hack crate.
  10. incremental: CARGO_INCREMENTAL=0 set in a local dev shell.

§Library usage

The check engine is exposed so it can be embedded or tested directly:

use cargo_build_rx::{checks, context::ProjectContext};

let ctx = ProjectContext::gather(None)?;
let findings = checks::run_checks(&ctx, &[], &[]);
println!("{} findings", findings.len());

Modules§

checks
The check registry and the Check trait every diagnostic implements.
cli
Command-line surface: the cargo build-rx argument parser.
context
Gathers everything the checks need, once, up front.
finding
The data model every check produces: Finding and its parts.
output
Rendering: turn a slice of Findings into terminal text or JSON.