bnjbvr / cargo-machete

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

--with-metadata false positive with build-dependencies #119

Closed trinity-1686a closed 7 months ago

trinity-1686a commented 8 months ago

thanks for making that tool. I'm currently trying to trim unused dependencies, and it has been a great help

running cargo machete --with-metadata on a project with build dependencies doesn't seem to consider anything used inside build.rs

bnjbvr commented 7 months ago

Thanks! I suppose you're asking for something similar to https://github.com/bnjbvr/cargo-machete/issues/100? It's not specific to --with-metadata, we don't handle build.rs / build-dependencies at all, as of now. So I'll close as a duplicate. (Please reopen or let me know if you were asking for something different.)

trinity-1686a commented 7 months ago

I think it's the opposite in a way, without --with-metadata it doesn't optimize, and with --with-metadata it optimizes "too much", suggesting to remove used dependencies. For instance in https://github.com/quickwit-oss/quickwit/ , --with-metadata suggest removing quickwit_codegen from ./quickwit-ingest/Cargo.toml, where it appears only as a [build-dependencies], and is used in the build.rs.

If it's not supported for now, this issue only half-make-sense anyway.