How do i find unused rust files and redundant dependency in toml file in my project?

I want to cleanup my rust project. Basically my project has some of rust files which are not used anymore. How do I find these unused files in my project automatically?
also how to automatically detect redundant dependency from toml file?

If you want to find unused dependencies in your Cargo.toml, there are (I think) several tools to do it. I use cargo machete, and it works very well:
https://crates.io/crates/cargo-machete/

1 Like

I also want to detect unused .rs files in the project

If an .rs file is unused, then every symbol it contains will be unused, so you'll get many compiler warnings (unless both the .rs file and the symbols are pub). Once you've removed all the unused symbols, the .rs files will be empty, and you should be able to find them easily.

cargo-udeps can used to find unused dependencies. But useless file, maybe nobody works on it now.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.