Tooling to find and remove unused derives?
⚓ Rust 📅 2025-12-17 👤 surdeus 👁️ 1Do we have any tooling to find and remove unused derived impls?
I've accumulated many unused derived impls in my project and they're causing problems in a few ways:
-
Adding new fields/variants can often cause issues because e.g. the type derives
Hashbut the new field's type doesn't.When this happens the first thing I try is removing the
Hashderive. Often I'm able to remove it. It would be great if I could solve this problem automatically. -
Because there's no direct link from a trait implementation to how use sites, when I look at a type and it derives e.g.
OrdI often can't immediately tell why it implements it and whether it needs to implement it.If I refactor the code and stop using a derived trait implementation I don't get any warnings so the derive line stays, causing confusion later on.
A tool to remove all unused derives in a package would be really useful. Does something like this already exist?
(My project is not a library, but for libraries maybe it could only do it if it doesn't affect public API.)
1 post - 1 participant
🏷️ Rust_feed