Often, you built your crate for public consumption and publish it on crates.io. Then your entire public API is potentially usable. Sometimes however, crates are part of a multi-crate project and if some public item is not used by any other crate in that project, the code is dead. For this second case, I built warnalyzer [1]. It uses save-analysis info generated by rustc to find and print unused definitions (despite the name, it doesn't use rust-analyzer yet, but it's certainly on the radar[2]!). Note that this method is not perfect, as it generates false positives due to unimplemented features in my tool as well as bugs in rustc. Therefore, manual verification to the tool's output is needed.
In such a manual removal effort, I was able to remove 815 lines of unused code from the servo browser project: https://github.com/servo/servo/pull/23532