How do I check/clippy everything?
⚓ Rust 📅 2025-09-24 👤 surdeus 👁️ 9Hey 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:
- What does
cargo clippyvs.cargo clippy --allor--workspacedo? Is--allor--workspaceimplied, or does a barecargo clippyinvocation do something different? - Probably answered above, and if so no need to belabor, but does bare
cargo clippyor--allimply any or all of--bins,--tests, and --examples`? - Is it the same across all commands? In this case I'm running
cargo fmtandcargo clippy, so I want to make sure all crates in the workspace plus their binaries/tests/examples are formatted and linted. - How do features fit into this? I can't necessarily always compile all my features everywhere, but I'm guessing
cargo fmtdoesn'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-featuresor if--all-featuresis implied in some/both of these commands.
Thanks!
4 posts - 4 participants
🏷️ Rust_feed