Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This took me some thinking and experimenting. Basically we want:
dead_code = deny
into the Cargo.toml.We already had
make validate-rust
which was intending to navigate this, but what was missing was the "deny extended set of warnings" so we got code committed to git main which hitunused_imports
.Clippy upstream docs recommend the
RUSTFLAGS = -Dwarnings
approach in e.g.https://doc.rust-lang.org/clippy/continuous_integration/github_actions.html but again I think this is a problem because it can break with updated Rust/clippy versions (unless you pin on those, but that becomes a pain in and of itself).
The problem also with doing
RUSTFLAGS = -Dwarnings
locally is it blows out the cargo cache.So here's the solution I came to: We run
cargo clippy -A clippy:all
, and then deny some specific clippy lints and the core Rust warnings we want (unused_imports
type things) at this stage. The advantage is this doesn't blow out the main Cargo cache, and I can easily reproduce locally exactly what CI would gate on.Also while we're here, add
make fix-rust
which is a handy way to use the existingclippy --fix
to locally fix things like unused imports as well as other machine-applicable things that are in e.g.clippy::suspicious
.