Tooling to find and remove unused derives?

⚓ Rust    📅 2025-12-17    👤 surdeus    👁️ 9      

surdeus

Warning

This post was published 50 days ago. The information described in this article may have changed.

Do 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 Hash but the new field's type doesn't.

    When this happens the first thing I try is removing the Hash derive. 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. Ord I 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

Read full topic

🏷️ Rust_feed