How do I check/clippy everything?

⚓ Rust    📅 2025-09-24    👤 surdeus    👁️ 9      

surdeus

Warning

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

Hey folks,

I don't know if I'm over-thinking this but it's not clear to me so figured I'd ask. I'm working on a workspace project with a pre-commit hook I'd like to have run clippy and cargo fmt. It has various tests and examples. I sometimes find that clippy misses some things, and I think I may not be running it on all workspace components. My questions:

  1. What does cargo clippy vs. cargo clippy --all or --workspace do? Is --all or --workspace implied, or does a bare cargo clippy invocation do something different?
  2. Probably answered above, and if so no need to belabor, but does bare cargo clippy or --all imply any or all of --bins, --tests, and --examples`?
  3. Is it the same across all commands? In this case I'm running cargo fmt and cargo clippy, so I want to make sure all crates in the workspace plus their binaries/tests/examples are formatted and linted.
  4. How do features fit into this? I can't necessarily always compile all my features everywhere, but I'm guessing cargo fmt doesn't require compiling so could technically format a feature not compilable on a given platform? What about clippy? Can it do basic code analysis without compiling, or does it need to compile a feature to lint it? Wondering if my invocations need to be --workspace --all-features or if --all-features is implied in some/both of these commands.

Thanks!

4 posts - 4 participants

Read full topic

🏷️ Rust_feed