Repository navigation
chore(clippy): make the release-profile lint pass and run it in CI - #1663
Merged
Merged
Conversation
FlorentinDUBOIS
requested review from
Wonshtrum and
llenotre
as code owners
September 28, 2026 16:01
FlorentinDUBOIS
force-pushed
the
fix/clippy-release-profile
branch
from
September 28, 2026 19:01
e78f8e1 to
a665d84
Compare
`cargo clippy --all-targets --release --locked -- -D warnings` failed on origin/main (b3f2c78). CI linted only the dev profile, where `debug_assertions` is on, so items used only by `#[cfg(debug_assertions)]` code or by a `debug!` call, which release builds compile out, were dead or redundant in release without anything reporting it. Each item is now gated or scoped by its real users, with no `allow`: - lib/src/protocol/mux/mod.rs: `HashMap` was imported at module level but used only by the `#[cfg(debug_assertions)]` backend_streams index check and by the test module. Both now import it themselves. - lib/src/protocol/mux/router.rs: the allocation test imported `DebugEvent` for its `#[cfg(debug_assertions)]` block only; the import moves into it. - lib/src/protocol/mux/debug.rs: `DEBUG_HISTORY_CAPACITY` is read only by the debug-build ring push and a debug-only test, and is now `#[cfg(debug_assertions)]`. - lib/src/protocol/mux/h2_header_reassembly.rs: `is_empty` is called by the debug-only `check_invariants` and by unit tests, and is now `#[cfg(any(debug_assertions, test))]`. - lib/src/protocol/mux/h2_stream_table.rs: `stream_last_activity_at` is read by `ConnectionH2::check_invariants` (debug only) and by unit tests, and is now `#[cfg(any(debug_assertions, test))]`. - bin/src/command/server.rs: with the toolchain CI lints on (1.93.1), the two `debug!` branches of `handle_finishing_task` are identical once the macro compiles out (`clippy::if_same_then_else`). They become one `debug!` that logs the same text. Every debug assertion stays active: the debug-only tests (`debug_history_keeps_the_newest_events_up_to_its_capacity`, the reassembly `*_panics_in_debug` tests, the stream-table tests) still run and pass in the dev profile. The `msrv-full` pipeline cell gains a `Lint (clippy, release profile)` step. `debug_assertions` does not depend on the crypto provider, so one cell is enough. The step deletes `target/release` right after the lint. Its check artifacts weigh 0.90 GB (`du -sb`, 1.93.1, the cell's flags, CARGO_INCREMENTAL=0). If they are kept, they add to the 5.46 GB `target/` the cell reaches once the sozu-e2e tests are built, and the runner pod exceeds its 8Gi ephemeral-storage limit: an earlier version of this change got the cell's pod evicted during `Test sozu-e2e`. With the deletion, the step peaks at 3.71 GB and the cell's peak does not change. Nothing else in the cell uses `target/release`, so rust-cache never stores it, and every run checks the dependencies again in release. That takes about 55 s, measured in CI and locally. `cargo test -p sozu-lib --release` still fails 6 tests, as on origin/main. They depend on debug-only behaviour (three `should_panic` tests on `debug_assert!`, three log-capture tests on `trace!`, which is compiled out of release builds). This change leaves them unchanged. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/clippy-release-profile
branch
from
September 28, 2026 19:15
a665d84 to
ab8f556
Compare
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
Clippy 1.98 and newer (`clippy::chunks_exact_to_as_chunks`) reject `chunks_exact` with a constant chunk size. `cargo +1.99.0 clippy --all-features --all-targets -- -D warnings` reported three hits on `origin/main` (8205812): - `lib/src/protocol/mux/h2.rs`: the `drain_window_updates_into` unit test, `chunks_exact(13)` - `e2e/src/mock/raw_h2_response_backend.rs`: the mock's SETTINGS parser, `chunks_exact(6)` - `e2e/src/tests/h2_window_update_tests.rs`: the test peer's SETTINGS parser, `chunks_exact(6)` Each now iterates `as_chunks::<N>().0`. `slice::as_chunks` is stable since Rust 1.88, below the 1.93.1 MSRV and pinned toolchain. It drops the remainder just as `chunks_exact` does, so the behaviour is the same. Only test and mock code changes. CHANGELOG entry added under Unreleased / Fixed, following the earlier `chore(clippy)` entry (#1663). ## Validation - `cargo +nightly fmt --all --check`: passes - `cargo +1.99.0 clippy --all-features --all-targets -- -D warnings`: passes (it failed with the 3 hits above before) - `cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings`: passes - `cargo +1.93.1 test -p sozu-lib --lib --all-features --locked`: 1568 passed - `cargo +1.93.1 test -p sozu-e2e --features opentelemetry,splice,simd --locked -- tests::h2_security_header_injection tests::h2_priority_rearm_tests tests::h2_window_update_tests`: 27 passed Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
cargo clippy --all-targets --release --locked -- -D warningsfails onmain(b3f2c78) with exit 101. CI lints only the dev profile, wheredebug_assertionsis on. Items used only by#[cfg(debug_assertions)]code, or by adebug!call (compiled out of release builds), are dead or redundant in release, and nothing reported them.Errors on
main(1.98.1):On 1.93.1, the toolchain CI lints with, there is one more:
Fix
Each item is now gated or scoped to the code that uses it. No
allowis added.HashMapimport (mux/mod.rs)backend_streamsindex check, andmod testsDebugEventimport (router allocation test)#[cfg(debug_assertions)]blockDEBUG_HISTORY_CAPACITY#[cfg(debug_assertions)]HeaderBlockAccumulator::is_emptycheck_invariants, unit tests#[cfg(any(debug_assertions, test))]H2StreamTable::stream_last_activity_atConnectionH2::check_invariants(debug-only), unit tests#[cfg(any(debug_assertions, test))]CommandHub::handle_finishing_taskdebug!branches that become identical oncedebug!compiles outdebug!with the same textBehaviour does not change, and every debug assertion stays active. In the dev profile, the debug-only tests still run and pass:
debug_history_keeps_the_newest_events_up_to_its_capacity, the reassembly*_panics_in_debugtests and the stream-table tests.CI
The
msrv-fullcell gains aLint (clippy, release profile)step.debug_assertionsdoes not depend on the crypto provider, so one cell is enough.Cost, measured locally on 1.93.1 with that cell's flags and a cold cache, after the dev clippy: 80 to 120 s and about 0.8 GB of release check artifacts. Once rust-cache holds those artifacts, only the workspace crates are checked again. For comparison, the existing dev clippy step took 32 s on run 36009186598.
Validation
cargo +nightly fmt --all -- --check: exit 0.cargo clippy --all-targets [--release] --locked -- -D warnings, with default features and with--no-default-features --features crypto-ring,opentelemetry,splice,simd: exit 0 for all four (1.98.1). The same commands on+1.93.1, plus themsrv-fullflags: exit 0.cargo build --locked: exit 0.cargo test --workspace --locked -- --skip tests::fuzz_tests:: --test-threads=8: exit 0, 2246 passed.check_doc_citations.pywith--self-test,--root .,--root . --base origin/mainand--audit --root .: exit 0 for all four.Pre-existing, not changed here
cargo test -p sozu-lib --release --lockedfails the same 6 tests onmain(b3f2c78) and on this branch:1321 passed; 6 failed. They depend on debug-only behaviour:h2_header_reassembly::tests::{begin_while_in_progress,append_while_idle,finish_while_idle}_panics_in_debugareshould_panictests ondebug_assert!;mux::router::tests::routing_runtime_logs_bound_method_authority_sni_and_certificate_namesandtls::tests::certificate_resolver_logs_redact_{fallback_sni,matching_sni_and_fingerprint}capturetrace!output, whichcommand/src/logging/logs.rs:1084compiles out withoutdebug_assertionsorlogs-trace.Making them release-aware means changing the tests, so it belongs in a separate change.
Signed-off-by: Florentin Dubois [email protected]