Skip to main content

Crate cargo_ensure_no_default_features

Crate cargo_ensure_no_default_features 

Source
Expand description

A cargo sub-command that ensures every dependency in a Cargo.toml file is declared with default-features = false.

Enabling default features by accident pulls in code you never asked for, which inflates build times, binary size, and the dependency surface that must be audited. This tool makes that mistake a build break instead of a silent regression.

If both [workspace.dependencies] and [dependencies] are present in the same manifest, both sections are checked. Dependencies that use workspace = true are skipped, since they inherit their settings from the workspace.

§Usage

Run this command in a cargo workspace or crate directory:

cargo ensure-no-default-features

The --manifest-path option lets you specify an explicit Cargo.toml file to check. Without this option, it defaults to the Cargo.toml in the current directory.

The --exceptions (-e) option lets you specify a comma-separated list of dependencies to exclude from the default-features check. This is useful for dependencies that you explicitly want to have default features enabled.

cargo ensure-no-default-features --manifest-path path/to/Cargo.toml --exceptions serde,tokio

§Installation

cargo install cargo-ensure-no-default-features

§Example Output

When offending dependencies are found:

Found 1 dependencies without default-features = false:

  - 'serde': missing default-features = false

When everything checks out:

All required dependencies have default-features = false

The tool exits with code 0 if all dependencies are well-formed, or code 1 otherwise.

Functions§

run
Main entry point for the library, called from the binary crate.