#cargo-subcommand #cargo #lang

app cargo-machete

Find unused dependencies with this one weird trick!

6 releases

Uses new Rust 2021

0.3.1 Jun 12, 2022
0.3.0 May 9, 2022
0.2.0 Apr 26, 2022
0.1.2 Apr 9, 2022
0.1.0 Nov 13, 2021

#96 in Cargo plugins

Download history 10/week @ 2022-04-20 92/week @ 2022-04-27 72/week @ 2022-05-04 303/week @ 2022-05-11 188/week @ 2022-05-18 158/week @ 2022-05-25 239/week @ 2022-06-01 342/week @ 2022-06-08 197/week @ 2022-06-15 188/week @ 2022-06-22 186/week @ 2022-06-29 143/week @ 2022-07-06 111/week @ 2022-07-13 144/week @ 2022-07-20 137/week @ 2022-07-27 178/week @ 2022-08-03

583 downloads per month

MIT license

27KB
633 lines

cargo-machete

Remove unused Rust dependencies with this one weird trick!

build status matrix chat supported rustc stable

Introduction

cargo-machete is a Cargo tool that detects unused dependencies in Rust projects, in a fast (yet imprecise) way.

See also the blog post for a detailed writeup.

Installation

Install cargo-machete with cargo:

cargo install cargo-machete

Example

Run cargo-machete in a directory that contains one or more Rust projects (using Cargo for dependency management):

cd my-directory && cargo machete

# alternatively

cargo machete /absolute/path/to/my/directory

To ignore a certain set of dependencies in a crate, add package.metadata.cargo-machete to Cargo.toml, and specify an ignored array:

For example:

[dependencies]
prost = "0.10" # Used in code generated by build.rs output, which cargo-machete cannot check

[package.metadata.cargo-machete]
ignored = ["prost"]

If there are too many false positives, consider using the --with-metadata CLI flag, which will call cargo metadata --all-features to find final dependency names, more accurate dependencies per build type, etc. ⚠ This may modify the Cargo.lock files in your projects.

Contributing

Contributor Covenant

We welcome community contributions to this project.

License

MIT license.

Dependencies

~12MB
~306K SLoC