Skip to content

fix: silence pulsar warnings under no-compression feature sets#418

Open
merlimat wants to merge 1 commit into
masterfrom
fix/no-compression-warnings
Open

fix: silence pulsar warnings under no-compression feature sets#418
merlimat wants to merge 1 commit into
masterfrom
fix/no-compression-warnings

Conversation

@merlimat

Copy link
Copy Markdown
Collaborator

Problem

Building the pulsar crate without the compression feature — e.g.

cargo clippy -p pulsar --no-default-features --features tokio-runtime -- -D warnings

produces three warnings that are masked under the default feature set (which enables compression):

  • src/producer.rs — unused io::Write import
  • src/producer.rs — unnecessary mut on compress_message's message parameter
  • src/consumer/engine.rs — unnecessary mut on process_payload's payload parameter

CI stays green today because both clippy jobs enable compression, but the warnings surface for any downstream build that depends on pulsar with default-features = false and no compression features.

Fix

Gate the import and the two mut bindings on the individual compression sub-features (lz4/flate2/zstd/snap) that actually use them — rather than the umbrella compression feature — so the crate is warning-free across every feature combination, including single-sub-feature builds like --features lz4, without changing behavior under any feature.

io::Write is moved out of the module-level use block into the flate2/snap match arms (the only two that call write_all), matching the existing use std::io::Read; convention already used for decompression in engine.rs.

No behavior change: under a no-compression build the only reachable match arm moves the message/payload without mutating it, so the mut is genuinely unused there.

Verification

  • cargo clippy -p pulsar --no-default-features --features tokio-runtime -- -D warnings — now clean (previously 3 warnings)
  • cargo clippy -p pulsar --features telemetry -- -D warnings — clean (compression-on path)
  • cargo fmt --all --check — clean

Building the pulsar crate without the `compression` feature (e.g.
`--no-default-features --features tokio-runtime`) produces three warnings
that are masked under the default feature set, which enables `compression`:

  - unused `io::Write` import in producer.rs
  - unnecessary `mut` on compress_message's `message` parameter
  - unnecessary `mut` on process_payload's `payload` parameter

Gate the import and the `mut` bindings on the individual compression
sub-features (lz4/flate2/zstd/snap) that actually use them, so the crate
is warning-free across every feature combination -- including
single-sub-feature builds like `--features lz4` -- without changing
behavior under any feature. `io::Write` moves into the flate2/snap match
arms, matching the existing `use std::io::Read;` convention in engine.rs.
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