Dealing with "warn: unused" warnings spam

  1. I’m currently getting 100+ “warning: unused” warnings from ~16K LOC codebase spread over 10-20 crates.

  2. When I first started using Rust, I took every warning seriously – but it made refactoring very slow, as the slightest change would resolve in adding or removing an import.

  3. After a while, I stopped caring about “warn: unused” warnings entirely.

  4. I’m now at the point while during a large recompile, it’s hard to find errors due to the “warning spam”

  5. How do others deal with this? 5a proactively remove unused imports? 5b disable “warn: unused”? 5c … some other technique?

While you’re dealing with too many warnings, it’s perfectly fine to #![allow(unused)]. That’s exactly what it’s there for: when the warnings cause more harm then good.

What I do for personal “clean” projects that are warning free are to allow a “messy working tree”, but to clean up the warnings at the “sync points”. So whenever I do a git commit, it should be free of warnings. Though I rarely do work without a git history anymore (it’s great for reverts), a similar idea still applies: before and after doing a “unit of work”, you clean up the warnings to give you a cleaner slate to work on.

3 Likes