bnjbvr/cargo-machete

False positive

virtualritz opened this issue · 1 comments

I had cargo-machete spit out a dep as removable that actually isn't.

Check out this repo and run cargo-machete:

❯ cargo machete                               
Analyzing dependencies of crates in this directory...
cargo-machete found the following unused dependencies in /home/moritz/code/crates/truck:
truck-stepio -- /home/moritz/code/crates/truck/truck-stepio/Cargo.toml:
        truck-geotrait
Done!

Stripping truck-geotrait from truck-stepio/Cargo.toml will break the build with a bunch of #derive's not being found.

Hi! Thanks for opening an issue. Turns out this is one case of that can't be handled with cargo-machete: the dependency's usage is hidden behind a procedural macro, and machete scans text, so it can't see it. This is a "known" behavior of machete (see blog post announcement for details), and you can filter the false positive with a Cargo.toml annotation as indicated in the readme.