cargo_build_rx/lib.rs
1//! `cargo-build-rx`: a compile-time diagnostic and prescription tool for Rust projects.
2//!
3//! The tool reads a project's `cargo metadata`, its `Cargo.toml`, its
4//! `.cargo/config.toml`, and a few environment variables, then runs a set of
5//! pure-function checks over that gathered [`context::ProjectContext`]. Each
6//! check returns [`finding::Finding`]s with a severity, an estimated impact,
7//! and (usually) a concrete fix. No part of the target project is compiled.
8//!
9//! The ten checks are:
10//!
11//! 1. `linker`: recommends a fast linker (mold/lld) on Linux, or split
12//! debug info on macOS.
13//! 2. `profile`: flags `debug = 2`, `opt-level > 0` in dev, and a missing
14//! `build-override` opt-level for proc-macros.
15//! 3. `duplicates`: the same crate compiled in several distinct versions.
16//! 4. `proc-macros`: the `syn` 1.x/2.x split and a high proc-macro count.
17//! 5. `build-scripts`: an inventory of `build.rs` crates, flagging native
18//! `links`.
19//! 6. `features`: heavy default feature sets (e.g. `tokio` `full`).
20//! 7. `dev-deps`: heavy dev-dependencies such as `criterion` or `proptest`.
21//! 8. `toolchain`: the installed toolchain versus the project's MSRV.
22//! 9. `workspace`: large workspaces without a `workspace-hack` crate.
23//! 10. `incremental`: `CARGO_INCREMENTAL=0` set in a local dev shell.
24//!
25//! # Library usage
26//!
27//! The check engine is exposed so it can be embedded or tested directly:
28//!
29//! ```no_run
30//! use cargo_build_rx::{checks, context::ProjectContext};
31//!
32//! let ctx = ProjectContext::gather(None)?;
33//! let findings = checks::run_checks(&ctx, &[], &[]);
34//! println!("{} findings", findings.len());
35//! # Ok::<(), anyhow::Error>(())
36//! ```
37
38#![warn(clippy::pedantic)]
39#![allow(
40 clippy::missing_errors_doc,
41 clippy::must_use_candidate,
42 clippy::too_many_lines,
43 clippy::module_name_repetitions
44)]
45
46pub mod checks;
47pub mod cli;
48pub mod context;
49pub mod finding;
50pub mod output;