X0026 machete-unused-deps¶
Rule: No crate declares a dependency its sources never use.
| Code | X0026 (stable, never reused) |
| Id | machete-unused-deps |
| Category | machete |
| Source | cargo-machete (run as an executable) |
| Fix | by hand |
| Needs | cargo-machete installed |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | warn |
an unused dependency costs build time, audit and lockfile churn for nothing |
| small-workspace | warn |
an unused dependency costs build time, audit and lockfile churn for nothing |
| medium | warn |
an unused dependency costs build time, audit and lockfile churn for nothing |
| big | deny |
an unused dependency in a big graph costs every build; false positives are listed in the manifest |
| ai | off | |
| embedded | off | |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Why¶
A dependency nobody uses still costs its build time, its audit and its place in the lockfile. cargo-machete finds dependencies whose name never appears in the crate's sources; it is fast and imprecise (a crate used only through a macro or under another name looks unused).
How to fix¶
Remove the dependency from the crate's Cargo.toml. A false positive is listed in the crate's manifest, so cargo-machete skips it:
Configure¶
Allow one finding in the code with // spirit-level: allow(machete-unused-deps) <reason> (waivers); the code works there too, as in [lints.X0026].