cargo-edit icon indicating copy to clipboard operation
cargo-edit copied to clipboard

RFC: `cargo rm --unused`

Open Xuanwo opened this issue 5 years ago • 2 comments

I would like to add a new flag unused under cargo rm which will remove all unused dependences from Cargo.toml.

Any idea for that?

Xuanwo avatar Aug 10 '20 03:08 Xuanwo

Is there currently some way to get metadata about unused crates? Without external proper tooling I would probably classify this as quite time consuming to implement with little value gained when considering the time it took to implement.

I know that cargo-udeps is a thing but sadly they do not provide a library API to take advantage of their code analysis. Maybe tapping into rustc warnings can be done (https://github.com/rust-lang/rust/pull/72342).

mainrs avatar Aug 16 '20 21:08 mainrs

Maybe we can use librustc_metadata directly?

Xuanwo avatar Aug 17 '20 02:08 Xuanwo

cargo udeps is an existing tool for doing this. Seeing as there are still caveats to how it works, I think more work should be put into that before integrating its behavior into cargo rm especially with https://github.com/killercup/cargo-edit/issues/682

epage avatar Sep 01 '22 20:09 epage