Skip to content

chore(clippy): make the release-profile lint pass and run it in CI - #1663

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
fix/clippy-release-profile
Sep 28, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
fix/clippy-release-profile

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Problem

cargo clippy --all-targets --release --locked -- -D warnings fails on main (b3f2c78) with exit 101. CI lints only the dev profile, where debug_assertions is on. Items used only by #[cfg(debug_assertions)] code, or by a debug! call (compiled out of release builds), are dead or redundant in release, and nothing reported them.

Errors on main (1.98.1):

error: unused import: `HashMap`                         --> lib/src/protocol/mux/mod.rs:20:29
error: unused import: `protocol::mux::DebugEvent`       --> lib/src/protocol/mux/router.rs:3400:21
error: constant `DEBUG_HISTORY_CAPACITY` is never used  --> lib/src/protocol/mux/debug.rs:18:18
error: method `is_empty` is never used                  --> lib/src/protocol/mux/h2_header_reassembly.rs:161:19
error: method `stream_last_activity_at` is never used   --> lib/src/protocol/mux/h2_stream_table.rs:377:19

On 1.93.1, the toolchain CI lints with, there is one more:

error: this `if` has identical blocks (clippy::if_same_then_else) --> bin/src/command/server.rs:1010:22

Fix

Each item is now gated or scoped to the code that uses it. No allow is added.

Item Real users Change
HashMap import (mux/mod.rs) the debug-only backend_streams index check, and mod tests each imports it itself
DebugEvent import (router allocation test) its #[cfg(debug_assertions)] block the import moves into the block
DEBUG_HISTORY_CAPACITY debug-build ring push, debug-only test #[cfg(debug_assertions)]
HeaderBlockAccumulator::is_empty debug-only check_invariants, unit tests #[cfg(any(debug_assertions, test))]
H2StreamTable::stream_last_activity_at ConnectionH2::check_invariants (debug-only), unit tests #[cfg(any(debug_assertions, test))]
CommandHub::handle_finishing_task two debug! branches that become identical once debug! compiles out one debug! with the same text

Behaviour 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_debug tests and the stream-table tests.

CI

The msrv-full cell gains a Lint (clippy, release profile) step. debug_assertions does 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 the msrv-full flags: 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.py with --self-test, --root ., --root . --base origin/main and --audit --root .: exit 0 for all four.

Pre-existing, not changed here

cargo test -p sozu-lib --release --locked fails the same 6 tests on main (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_debug are should_panic tests on debug_assert!;
  • mux::router::tests::routing_runtime_logs_bound_method_authority_sni_and_certificate_names and tls::tests::certificate_resolver_logs_redact_{fallback_sni,matching_sni_and_fingerprint} capture trace! output, which command/src/logging/logs.rs:1084 compiles out without debug_assertions or logs-trace.

Making them release-aware means changing the tests, so it belongs in a separate change.

Signed-off-by: Florentin Dubois [email protected]

`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
FlorentinDUBOIS force-pushed the fix/clippy-release-profile branch from a665d84 to ab8f556 Compare September 28, 2026 19:15
@FlorentinDUBOIS
FlorentinDUBOIS merged commit e247f26 into main Sep 28, 2026
28 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the fix/clippy-release-profile branch September 28, 2026 20:17
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant