1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! `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::Finding`]s 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:
//!
//! ```no_run
//! use cargo_build_rx::{checks, context::ProjectContext};
//!
//! let ctx = ProjectContext::gather(None)?;
//! let findings = checks::run_checks(&ctx, &[], &[]);
//! println!("{} findings", findings.len());
//! # Ok::<(), anyhow::Error>(())
//! ```