Skip to content

M0001 default-features-off

Rule: Third-party dependencies are declared with default-features = false.

Code M0001 (stable, never reused)
Id default-features-off
Category dependencies
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small warn dependencies are added with default-features = false and only the features in use
small-workspace warn dependencies are added with default-features = false and only the features in use
medium warn dependencies are added with default-features = false and only the features in use
big deny feature creep in a big graph costs every build
ai off
embedded off
ui off
egui off
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
allow list of strings [] crates whose default features are wanted

Why

Default features turn on what a crate's author thought most users want: often TLS backends, bundled C libraries, async runtimes. Taking only the features in use keeps the build small and pure Rust.

How to fix

Write default-features = false and list the features the code uses. In a workspace the finding points at [workspace.dependencies] when the member inherits the dependency. Crates whose defaults are wanted go in the parameter allow.

Configure

[lints.default-features-off]
level = "deny"
allow = []
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(default-features-off) <reason> (waivers); the code works there too, as in [lints.M0001].