bnjbvr / cargo-machete

Remove unused Rust dependencies with this one weird trick!
MIT License
784 stars 28 forks source link

False positives for multi-dep single `use` statements #91

Closed Billy-Sheppard closed 1 month ago

Billy-Sheppard commented 1 year ago

Not sure if this is a known drawback of this crate, but my project has a rustfmt.toml that collapses all imports into one use/pub use {} block. This seems to cause all the crates to be returned as false positives.

pub use {async_trait, futures, reqwest};
cargo-machete found the following unused dependencies in /var/home/...
my_crate -- /var/home/ ... /Cargo.toml:
        async_trait
        futures
        reqwest
bnjbvr commented 1 year ago

Thanks for opening an issue; that looks like a real bug (in general, cargo-machete should give too many unused dependencies, not too few). Probably the regular expressions would need to be tweaked, if you feel like investigating that using the helper project, that could be fun and fixing that would be useful!