🦀
Rust で 未使用の dependencies を探す
これって使ってたんだっけ?消していいんだっけ?となったときの解決法
使うもの
手順
インストール
cargo install cargo-udeps --locked
# nightly がいるらしいので入れる
rustup install nightly
実行
cargo +nightly udeps
Checking rpassword v5.0.1
Checking repng v0.2.2
Checking app v0.1.0 (/workspace)
Finished dev [unoptimized + debuginfo] target(s) in 1.88s
info: Loading save analysis from "/workspace/target/debug/deps/save-analysis/app-0c8c08d5e5865373.json"
unused dependencies:
`app v0.1.0 (/workspace)`
└─── dependencies
├─── "repng"
├─── "rpassword"
├─── "sha2"
└─── "whoami"
Note: These dependencies might be used by other targets.
To find dependencies that are not used by any target, enable `--all-targets`.
Note: They might be false-positive.
For example, `cargo-udeps` cannot detect usage of crates that are only used in doc-tests.
To ignore some dependencies, write `package.metadata.cargo-udeps.ignore` in Cargo.toml.
今回は、これらが不要なものとして検出された。
├─── "repng"
├─── "rpassword"
├─── "sha2"
└─── "whoami"
Discussion