I appreciate the care rustc expresses in helping me find dead code. In particular, I love this warning:
warning: unused import: `std::io` --> src/lib.rs:3:5 | 3 | use std::io; | ^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
However, more than once now I've cleaned up a bunch of unused imports, verified that tests still pass, and then shipped the code - without noticing that in the process I had removed the last reference to some crate from
Cargo.toml. I realize that Rust's linker is smart enough to leave all of that code out, but it still increases build time for clean builds, and it still means keeping up with CVEs, bug reports, and point releases on code that's not actually being used any more.
Is there a way to get Cargo to warn when a library is no longer used in the project it's building?