Skip to content

refactor(encoding): split match_generator monolith + separate tests from production#445

Merged
polaz merged 14 commits into
mainfrom
refactor/#441-extract-level-config
Jun 23, 2026
Merged

refactor(encoding): split match_generator monolith + separate tests from production#445
polaz merged 14 commits into
mainfrom
refactor/#441-extract-level-config

Conversation

@polaz

@polaz polaz commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Two related refactors, no production logic changes (compress/decompress output is byte-identical; the suite runs the same 824 cases throughout).

1. Split the match_generator.rs monolith (closes #441)

The ~13k-line driver is broken into an orchestrator plus per-concern modules:

Module Concern
match_generator/mod.rs driver orchestrator
encoding/levels/config.rs level table, resolvers, estimators
encoding/hc/priceset.rs per-CPU price-set SIMD kernels
encoding/hc/generator.rs HcMatchGenerator + chain matcher
encoding/hc/optimal.rs optimal-parse DP + body macros
match_generator/dict_prime.rs dictionary prime / CDict-equivalent snapshot lifecycle

dict_prime is a child module so it reaches the driver's private, invariant-bearing snapshot state (primed / reset_shape / PrimedKey) directly, with zero field-visibility widening; the Matcher trait surface forwards to it via thin #[inline] delegations.

2. Separate test code from production across the crate

Every inline test module and module-scope #[test] is relocated into a sibling test file, leaving production sources with code only plus a #[cfg(test)] mod ...; declaration. Covers ~75 files across zstd and cli. Test-support items that are methods/fields on production types (test-only accessors over private state) intentionally stay with their type.

Testing

  • cargo nextest run -p structured-zstd --features dict_builder — 824 passed
  • cargo nextest run -p structured-zstd-cli — 22 passed
  • cargo clippy --tests + cargo fmt clean
  • cargo check --workspace --tests clean
  • x86_64-apple-darwin cross-checked for the arch-gated tests (row tag-mask, reverse-bit-reader BMI2 helper) that the local aarch64 build compiles out

Closes #441

Summary by CodeRabbit

  • Tests

    • Expanded and reorganized unit test coverage across the CLI and core library, including formatting helpers, argument parsing behavior, and extensive decoding/encoding/dictionary edge cases.
    • Added new targeted regression tests to validate byte-accurate operations, error messages, and boundary conditions.
  • Refactor

    • Moved large in-file test implementations into dedicated test modules to improve maintainability and keep production logic unchanged.

polaz added 10 commits June 23, 2026 11:25
Move the per-level tuning config out of match_generator.rs into a dedicated
levels/config.rs: the HcConfig / RowConfig / DfastConfig / FastConfig knobs,
LevelParams + LEVEL_TABLE, the public-parameter overrides, the source-size
tiering, and the workspace estimators.

Pure mechanical move with no behaviour change: the code is relocated verbatim
(only the relative `super::` paths rewritten to absolute `crate::encoding::`
for the deeper module, and the resolution API widened to pub(crate)), so the
compressed output stays byte-identical. match_generator.rs drops 1119 lines
(13125 -> 12006). Consumers (frame_compressor, dfast, row) and the public
re-export of the workspace estimators now source the API from levels::config.

Part of #441.
Move the optimal parser's per-CPU-tier price-set kernels
(priceset_range_nonabort_{scalar,avx2,neon,sse41,simd128} plus their
cached-price / improved-mask helpers) out of match_generator.rs into
hc/priceset.rs. Verbatim move (kernels unchanged; only the opt-parser type
imports pulled in and the nonabort entry points widened to pub(crate)), so the
output is byte-identical. match_generator.rs: 12006 -> 11306.

Part of #441.
Move the HashChain / binary-tree match generator out of match_generator.rs into
hc/generator.rs: the HcMatchGenerator storage + methods, the btlazy2 cost
helpers, the optimal-plan body macros, and the build_optimal_plan driver. The
cross-module macros (bt_insert_*, hash3_candidate, for_each_repcode) now resolve
through hc::generator; their consumers (match_table::storage, hc) are repointed.

Verbatim move (only relative paths rewritten to absolute and the driver-facing
surface widened to pub(crate)), so the output is byte-identical. The small
HcBackend enum stays in match_generator (its impl moved). match_generator.rs:
11306 -> 7438.

Part of #441.
Move the binary-tree optimal parser out of hc/generator.rs into hc/optimal.rs:
the build_optimal_plan DP + its per-CPU-tier kernels, the candidate-collection /
price-set body macros, and the btlazy2 cost helpers, as a second
`impl HcMatchGenerator` block over the same matcher. Both files are hc/
submodules so no path rewrite was needed; output is byte-identical.

The DP body macros reference opt types unqualified, which rustc's unused-import
lint cannot see (so it false-flags every such import) -- handled by a documented
module-level suppression in optimal.rs; generator.rs's now-redundant (qualified)
imports were removed by hand. hc/generator.rs: 3918 -> 1691.

Part of #441.
Convert match_generator.rs into a directory module and move the seven
dictionary entry points (resident check + reapply, prime, snapshot
restore/capture, invalidate, entropy seed) out of the driver's main
`Matcher` impl into a `dict_prime` child module.

The snapshot path reads/writes the driver's most invariant-critical
private state (`primed`, `reset_shape`, the `PrimedKey` snapshot identity
that guards against restoring a mismatched matcher shape and emitting an
undecodable match). A child module reaches those private fields directly,
so the concern relocates with zero field widening -- encapsulation stays
intact. The trait surface keeps thin `#[inline]` forwarders to the child's
inherent `*_impl` helpers, so output is byte-identical.

match_generator/mod.rs: 7438 -> 7000.

Part of #441.
Relocate the ~4.9k lines of unit / round-trip tests (parse x search
matrix, per-level parameter resolution, greedy/lazy/optimal round-trips,
dictionary priming) out of the driver module body into a dedicated
`tests` submodule file. Production code stays in mod.rs; the test file is
`#[cfg(test)] mod tests;`.

match_generator/mod.rs: 7000 -> 2063 (production only).

Part of #441.
Relocate every inline `#[cfg(test)] mod tests { ... }` block across the
crate into a sibling `tests.rs` submodule, leaving each source file with
production code only plus a `#[cfg(test)] mod tests;` declaration. Test
bodies are moved verbatim (rustfmt re-indents; string literals untouched).

Relative `include_bytes!` paths in the moved dictionary tests gain one
`../` level to keep resolving to `zstd/dict_tests` from the deeper file
location.

No production logic changes; the full suite still runs the same 824 cases.
Separate the remaining inline test code that was not wrapped in a
`mod tests { ... }` block (so the earlier sweep did not catch it) into
sibling `tests.rs` submodules:

- fse, huff0 (mod + encoder): bare module-scope `#[test]` tail blocks.
- bit_reader_reverse: the `mod test` block plus the two `#[cfg(test)]`
  helper fns that only its tests used.
- sequence_section_decoder: module-scope tests plus the two nested
  `#[cfg(test)] mod` blocks; `super::` paths gain one level for the
  deeper nesting.
- hc/generator, hc/priceset: test fns left behind by the match-generator
  split. The `#[cfg(test)]` `start_matching` driver method stays with the
  struct (it reaches private fields); only the test cases move.

Two production helpers (`distribute_weights` / `redistribute_weights`,
called from `legacy_distributed_weights`) that sat among the encoder
tests are kept in production. Relative `include_bytes!` paths adjusted
for the deeper file locations. Suite unchanged at 824 cases; x86_64 +
BMI2 build cross-checked for the gated bit-reader helper.
Extract the `#[cfg(test)] mod <name>_tests { ... }` blocks (which the
first sweep skipped because they are not named `tests`) into sibling
files declared `#[cfg(test)] mod <name>_tests;`. A named module relocated
to its own same-named file keeps its parent, so `super::` paths are
unchanged and the bodies move verbatim.

Covers compress_bound / hc / tag_mask / neon_tag_mask / ldm_helper /
extend_with_repcode / bt_pair_index_wrap / stream_abs_headroom / storage
/ zerocopy_robustness / burst_gate / frame_inspection / inline_helper /
portable_helper tests across the encoding and decoding trees. Suite
unchanged at 824 cases; x86_64 build cross-checked for the arch-gated
tag-mask tests.
Relocate the inline `#[cfg(test)] mod tests` blocks in `progress` and
the binary root into sibling `tests.rs` files (the crate root's submodule
lands at `src/tests.rs`). Production code only in the source files; 22
cli tests unchanged.
@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown

Too many files changed for review. (148 files found, 100 file limit)

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (6)
  • zstd/src/encoding/match_generator/mod.rs
  • zstd/src/encoding/match_generator/tests.rs
  • zstd/src/fse/mod.rs
  • zstd/src/fse/tests.rs
  • zstd/src/huff0/huff0_encoder.rs
  • zstd/src/huff0/huff0_encoder/tests.rs
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 30c5a137-eb57-41c3-8474-695e65bde4b9

📥 Commits

Reviewing files that changed from the base of the PR and between 373a45d and a91cd1c.

📒 Files selected for processing (6)
  • zstd/src/encoding/match_generator/mod.rs
  • zstd/src/encoding/match_generator/tests.rs
  • zstd/src/fse/mod.rs
  • zstd/src/fse/tests.rs
  • zstd/src/huff0/huff0_encoder.rs
  • zstd/src/huff0/huff0_encoder/tests.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR moves inline tests into separate modules across CLI, decoding, dictionary, and encoding code, and adds the HC generator module plus related matcher tests and wiring.

Changes

CLI and codec test extraction

Layer / File(s) Summary
CLI and bit I/O tests
cli/src/main.rs, cli/src/tests.rs, cli/src/progress.rs, cli/src/progress/tests.rs, zstd/src/bit_io/..., zstd/src/cpu_kernel*
Inline CLI, bit-reader, bit-writer, and CPU-kernel tests move into dedicated test files, with added coverage for parsing, formatting, bit operations, and kernel selection.
Decoder unit test split
zstd/src/decoding/block_decoder*, .../buffer_backend*, .../decode_buffer*, .../dictionary*, .../errors*, .../sequence_execution*, .../sequence_section_decoder*
Decoder internals now use external test modules, with new tests for block-state errors, backend overflow handling, repeat behavior, dictionary decoding, error strings, and sequence-stream setup.
Decoder runtime regressions
zstd/src/decoding/exec_sequence_inline*, .../flat_buf*, .../frame_decoder/tests.rs, .../frame_inspection_tests.rs, .../literals_section_decoder/*, .../ringbuffer*, .../simd_copy*, .../streaming_decoder*, .../user_slice_buf*
Additional decoder coverage validates copy helpers, buffer implementations, frame inspection and resume flows, literals decoding robustness, streaming read behavior, and backend-specific execution paths.
Dictionary and encoding tests
zstd/src/dictionary/*, zstd/src/encoding/block_header*, zstd/src/encoding/blocks/compressed*, zstd/src/encoding/bt/*, zstd/src/encoding/compress_bound_tests.rs, zstd/src/encoding/cparams*, zstd/src/encoding/dfast/*, zstd/src/encoding/dict_attach*, zstd/src/encoding/fastpath/*, zstd/src/encoding/frame_header*
Dictionary and encoder modules move tests into standalone files and add coverage for training APIs, headers, compressed-block heuristics, LDM helpers, repcode extension, fastpath dispatch, and serialization boundaries.

HC generator extraction

Layer / File(s) Summary
HC module extraction and wiring
zstd/src/encoding/hc/mod.rs, zstd/src/encoding/hc/generator.rs
The HC module exports new submodules, adds the extracted generator implementation and borrowed-window helpers, and rewires architecture-specific repcode probes to the new generator macro body.
HC matcher and generator validation
zstd/src/encoding/hc/generator/tests.rs, zstd/src/encoding/hc/hc_tests.rs
New dedicated HC tests validate matcher internals, generated-sequence round trips, backend routing, exact-match regressions, and cross-slice greedy behavior.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~100 minutes

Poem

🐇 I tucked the tests in burrows neat,
and split a matcher from its seat.
Through bits and frames I hopped with care,
left tidy modules everywhere.
Now carrots of coverage softly gleam.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring the match_generator module into per-concern modules and separating test code from production across ~75 files.
Linked Issues check ✅ Passed The PR fully addresses issue #441 requirements: match_generator.rs is split into modules (hc/generator, hc/optimal, hc/priceset, levels/config, dict_prime), tests are separated from production across ~75 files, byte-identity is maintained, and all tests pass.
Out of Scope Changes check ✅ Passed All changes are in-scope: test extraction/relocation, module split for match_generator, and related support refactoring. No unrelated features or logic changes are introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#441-extract-level-config

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (10)
cli/src/progress/tests.rs (1)

1-31: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix rustfmt violations to unblock CI

Line 1 onward in this file is currently failing cargo fmt --check. Please run cargo fmt --all (or format this file) before merge.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/progress/tests.rs` around lines 1 - 31, The test file
cli/src/progress/tests.rs is failing cargo fmt --check due to formatting
violations. Run cargo fmt --all or cargo fmt on this specific file to
automatically apply the correct Rust formatting standards to the
human_readable_filesize and human_readable_duration test functions and any other
formatting issues in the file.

Source: Pipeline failures

zstd/src/encoding/compress_bound_tests.rs (1)

1-32: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Apply rustfmt to this test file.

cargo fmt --check reports a diff here, so CI will stay failing until this file is formatted.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/encoding/compress_bound_tests.rs` around lines 1 - 32, The test file
compress_bound_tests.rs does not conform to Rust's standard formatting rules as
reported by cargo fmt. Run the Rust formatter on this file to automatically fix
any formatting issues. This applies to all test functions in the file including
matches_upstream_formula_below_threshold, drops_margin_at_and_above_threshold,
saturates_instead_of_wrapping, and always_fits_real_compressed_output, as well
as the imports and overall code structure. Use cargo fmt to apply the standard
formatting rules and resolve the CI failure.

Source: Pipeline failures

zstd/src/encoding/dfast/extend_with_repcode_tests.rs (1)

1-414: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Format this extracted dfast test module with rustfmt.

The lint job reports a cargo fmt --check diff in this file, so this is currently blocking a clean CI pass.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/encoding/dfast/extend_with_repcode_tests.rs` around lines 1 - 414,
The test file extend_with_repcode_tests.rs is not formatted according to Rust's
standard formatting rules, which is causing the cargo fmt --check to fail. Run
cargo fmt on this file to automatically apply the standard Rust formatting
conventions. This will fix all formatting issues and allow the CI to pass
without any manual code changes needed, only the formatter output.

Source: Pipeline failures

zstd/src/encoding/bt/ldm_helper_tests.rs (1)

1-333: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Run cargo fmt on this extracted test module before merge.

CI is failing cargo fmt --check for this file, so the lint gate is currently red.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/encoding/bt/ldm_helper_tests.rs` around lines 1 - 333, The test file
ldm_helper_tests.rs is not formatted according to Rust's standard code style and
is failing the cargo fmt --check lint gate in CI. Run cargo fmt on this file to
automatically fix all formatting issues and ensure the code complies with the
formatting standards required for merge.

Source: Pipeline failures

zstd/src/encoding/hc/hc_tests.rs (1)

1-187: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Apply rustfmt for this test module to unblock CI.

cargo fmt --check is failing on this file in CI; please run cargo fmt --all and commit the formatting-only update.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/encoding/hc/hc_tests.rs` around lines 1 - 187, The hc_tests.rs file
has formatting inconsistencies that are failing the rustfmt checks in CI. Run
cargo fmt --all from the repository root to automatically reformat all files
including the test functions
chain_candidates_returns_sentinels_when_suffix_too_short,
chain_candidates_terminates_on_self_loop_with_in_range_pick,
hash_chain_candidate_picks_longest_forward_over_shorter_with_backward_room, and
hash_chain_candidate_forward_ties_keep_first_visited, then commit the
formatting-only changes.

Source: Pipeline failures

zstd/src/decoding/literals_section_decoder/burst_gate_tests.rs (1)

1-256: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Run rustfmt on this file to unblock CI.

cargo fmt --check is failing for this file, so this PR cannot merge until formatting is applied.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/decoding/literals_section_decoder/burst_gate_tests.rs` around lines
1 - 256, The file burst_gate_tests.rs contains formatting violations that are
preventing the CI checks from passing. Run rustfmt on this file to automatically
apply the correct Rust formatting standards. You can do this by executing the
command to format the file, which will fix all whitespace, indentation, and
other style issues throughout the test module.

Source: Pipeline failures

zstd/src/decoding/literals_section_decoder/zerocopy_robustness_tests.rs (1)

1-132: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Format this test file with rustfmt.

The lint pipeline reports a formatting diff here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/decoding/literals_section_decoder/zerocopy_robustness_tests.rs`
around lines 1 - 132, The test file zerocopy_robustness_tests.rs has formatting
issues detected by the lint pipeline. Run rustfmt on this file to apply standard
Rust formatting rules and resolve all formatting inconsistencies throughout the
entire module, including the helper functions like raw_section, rle_section, and
fresh_scratch as well as all test functions like
raw_truncated_source_returns_error_no_panic,
rle_empty_source_returns_error_no_panic,
compressed_truncated_source_returns_error_no_panic, and
rle_view_excludes_pre_existing_target_bytes.

Source: Pipeline failures

zstd/src/decoding/exec_sequence_inline/inline_helper_tests.rs (1)

1-87: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Run rustfmt on this new test module.

CI shows cargo fmt --check failing for this file, so this PR stays red until formatting is applied.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/decoding/exec_sequence_inline/inline_helper_tests.rs` around lines 1
- 87, The test module in inline_helper_tests.rs is not properly formatted
according to Rust's standard formatting rules, causing cargo fmt --check to
fail. Run rustfmt on the inline_helper_tests.rs file to automatically apply the
correct formatting to all test functions (copy16_copies_exactly_16_bytes,
wildcopy_no_overlap_short_length_overshoots,
wildcopy_no_overlap_length_above_16_uses_multiple_iters,
wildcopy_overlap_8byte_stride_rle_expansion_offset_8,
overlap_copy8_offset_ge_8_does_plain_copy, and
overlap_copy8_offset_lt_8_spreads_source) and ensure CI passes.

Source: Pipeline failures

zstd/src/decoding/exec_sequence_inline/portable_helper_tests.rs (1)

1-90: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Apply rustfmt to this file before merge.

cargo fmt --check is failing on this module in CI.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/decoding/exec_sequence_inline/portable_helper_tests.rs` around lines
1 - 90, The file portable_helper_tests.rs does not comply with Rust formatting
standards as indicated by the failing cargo fmt check in CI. Run cargo fmt on
this file to automatically apply the correct formatting conventions and ensure
all code style issues are resolved before merging.

Source: Pipeline failures

zstd/src/decoding/frame_inspection_tests.rs (1)

1-202: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Run rustfmt for this file to unblock CI.

CI reports this file would be reformatted (cargo fmt --check failure). Please format it before merge.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@zstd/src/decoding/frame_inspection_tests.rs` around lines 1 - 202, The file
has formatting issues that cause CI to fail the `cargo fmt --check` validation.
Run `cargo fmt` on the frame_inspection_tests.rs file to automatically reformat
it according to Rust style standards, which will resolve the CI formatting
failure.

Source: Pipeline failures

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/src/tests.rs`:
- Around line 1-219: The cli/src/tests.rs file has formatting issues detected by
CI. Run cargo fmt --all from the project root to automatically apply the Rust
formatting standards to all files, including this test file. This will ensure
all formatting violations are corrected to pass the linting checks.

In `@zstd/src/decoding/frame_decoder/tests.rs`:
- Around line 2150-2152: The test at line 2150 uses a runtime-relative path
"./dict_tests/dictionary" which depends on the current working directory when
the test runs, making it fragile and test harness-dependent. Instead of using
std::fs::read with a relative path to load the dictionary fixture, identify the
compile-time fixture loading strategy used elsewhere in this test file (likely
using include_bytes! or similar compile-time macros) and apply the same approach
to obtain the raw dictionary data for the Dictionary::decode_dict call. This
ensures the fixture is embedded at compile-time and independent of runtime
working directory.

---

Outside diff comments:
In `@cli/src/progress/tests.rs`:
- Around line 1-31: The test file cli/src/progress/tests.rs is failing cargo fmt
--check due to formatting violations. Run cargo fmt --all or cargo fmt on this
specific file to automatically apply the correct Rust formatting standards to
the human_readable_filesize and human_readable_duration test functions and any
other formatting issues in the file.

In `@zstd/src/decoding/exec_sequence_inline/inline_helper_tests.rs`:
- Around line 1-87: The test module in inline_helper_tests.rs is not properly
formatted according to Rust's standard formatting rules, causing cargo fmt
--check to fail. Run rustfmt on the inline_helper_tests.rs file to automatically
apply the correct formatting to all test functions
(copy16_copies_exactly_16_bytes, wildcopy_no_overlap_short_length_overshoots,
wildcopy_no_overlap_length_above_16_uses_multiple_iters,
wildcopy_overlap_8byte_stride_rle_expansion_offset_8,
overlap_copy8_offset_ge_8_does_plain_copy, and
overlap_copy8_offset_lt_8_spreads_source) and ensure CI passes.

In `@zstd/src/decoding/exec_sequence_inline/portable_helper_tests.rs`:
- Around line 1-90: The file portable_helper_tests.rs does not comply with Rust
formatting standards as indicated by the failing cargo fmt check in CI. Run
cargo fmt on this file to automatically apply the correct formatting conventions
and ensure all code style issues are resolved before merging.

In `@zstd/src/decoding/frame_inspection_tests.rs`:
- Around line 1-202: The file has formatting issues that cause CI to fail the
`cargo fmt --check` validation. Run `cargo fmt` on the frame_inspection_tests.rs
file to automatically reformat it according to Rust style standards, which will
resolve the CI formatting failure.

In `@zstd/src/decoding/literals_section_decoder/burst_gate_tests.rs`:
- Around line 1-256: The file burst_gate_tests.rs contains formatting violations
that are preventing the CI checks from passing. Run rustfmt on this file to
automatically apply the correct Rust formatting standards. You can do this by
executing the command to format the file, which will fix all whitespace,
indentation, and other style issues throughout the test module.

In `@zstd/src/decoding/literals_section_decoder/zerocopy_robustness_tests.rs`:
- Around line 1-132: The test file zerocopy_robustness_tests.rs has formatting
issues detected by the lint pipeline. Run rustfmt on this file to apply standard
Rust formatting rules and resolve all formatting inconsistencies throughout the
entire module, including the helper functions like raw_section, rle_section, and
fresh_scratch as well as all test functions like
raw_truncated_source_returns_error_no_panic,
rle_empty_source_returns_error_no_panic,
compressed_truncated_source_returns_error_no_panic, and
rle_view_excludes_pre_existing_target_bytes.

In `@zstd/src/encoding/bt/ldm_helper_tests.rs`:
- Around line 1-333: The test file ldm_helper_tests.rs is not formatted
according to Rust's standard code style and is failing the cargo fmt --check
lint gate in CI. Run cargo fmt on this file to automatically fix all formatting
issues and ensure the code complies with the formatting standards required for
merge.

In `@zstd/src/encoding/compress_bound_tests.rs`:
- Around line 1-32: The test file compress_bound_tests.rs does not conform to
Rust's standard formatting rules as reported by cargo fmt. Run the Rust
formatter on this file to automatically fix any formatting issues. This applies
to all test functions in the file including
matches_upstream_formula_below_threshold, drops_margin_at_and_above_threshold,
saturates_instead_of_wrapping, and always_fits_real_compressed_output, as well
as the imports and overall code structure. Use cargo fmt to apply the standard
formatting rules and resolve the CI failure.

In `@zstd/src/encoding/dfast/extend_with_repcode_tests.rs`:
- Around line 1-414: The test file extend_with_repcode_tests.rs is not formatted
according to Rust's standard formatting rules, which is causing the cargo fmt
--check to fail. Run cargo fmt on this file to automatically apply the standard
Rust formatting conventions. This will fix all formatting issues and allow the
CI to pass without any manual code changes needed, only the formatter output.

In `@zstd/src/encoding/hc/hc_tests.rs`:
- Around line 1-187: The hc_tests.rs file has formatting inconsistencies that
are failing the rustfmt checks in CI. Run cargo fmt --all from the repository
root to automatically reformat all files including the test functions
chain_candidates_returns_sentinels_when_suffix_too_short,
chain_candidates_terminates_on_self_loop_with_in_range_pick,
hash_chain_candidate_picks_longest_forward_over_shorter_with_backward_room, and
hash_chain_candidate_forward_ties_keep_first_visited, then commit the
formatting-only changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9dc1eba6-bf05-42a6-b382-4c899adb3c91

📥 Commits

Reviewing files that changed from the base of the PR and between f7c4843 and 162e883.

📒 Files selected for processing (148)
  • cli/src/main.rs
  • cli/src/progress.rs
  • cli/src/progress/tests.rs
  • cli/src/tests.rs
  • zstd/src/bit_io/bit_reader_reverse.rs
  • zstd/src/bit_io/bit_reader_reverse/tests.rs
  • zstd/src/bit_io/bit_writer.rs
  • zstd/src/bit_io/bit_writer/tests.rs
  • zstd/src/cpu_kernel.rs
  • zstd/src/cpu_kernel/tests.rs
  • zstd/src/decoding/block_decoder.rs
  • zstd/src/decoding/block_decoder/tests.rs
  • zstd/src/decoding/buffer_backend.rs
  • zstd/src/decoding/buffer_backend/tests.rs
  • zstd/src/decoding/decode_buffer.rs
  • zstd/src/decoding/decode_buffer/tests.rs
  • zstd/src/decoding/dictionary.rs
  • zstd/src/decoding/dictionary/tests.rs
  • zstd/src/decoding/errors.rs
  • zstd/src/decoding/errors/tests.rs
  • zstd/src/decoding/exec_sequence_inline.rs
  • zstd/src/decoding/exec_sequence_inline/inline_helper_tests.rs
  • zstd/src/decoding/exec_sequence_inline/portable_helper_tests.rs
  • zstd/src/decoding/flat_buf.rs
  • zstd/src/decoding/flat_buf/tests.rs
  • zstd/src/decoding/frame_decoder.rs
  • zstd/src/decoding/frame_decoder/tests.rs
  • zstd/src/decoding/frame_inspection_tests.rs
  • zstd/src/decoding/literals_section_decoder.rs
  • zstd/src/decoding/literals_section_decoder/burst_gate_tests.rs
  • zstd/src/decoding/literals_section_decoder/zerocopy_robustness_tests.rs
  • zstd/src/decoding/mod.rs
  • zstd/src/decoding/ringbuffer.rs
  • zstd/src/decoding/ringbuffer/tests.rs
  • zstd/src/decoding/scratch.rs
  • zstd/src/decoding/scratch/tests.rs
  • zstd/src/decoding/sequence_execution.rs
  • zstd/src/decoding/sequence_execution/tests.rs
  • zstd/src/decoding/sequence_section_decoder.rs
  • zstd/src/decoding/sequence_section_decoder/tests.rs
  • zstd/src/decoding/simd_copy.rs
  • zstd/src/decoding/simd_copy/tests.rs
  • zstd/src/decoding/streaming_decoder.rs
  • zstd/src/decoding/streaming_decoder/tests.rs
  • zstd/src/decoding/user_slice_buf.rs
  • zstd/src/decoding/user_slice_buf/tests.rs
  • zstd/src/dictionary/fastcover.rs
  • zstd/src/dictionary/fastcover/tests.rs
  • zstd/src/dictionary/frequency.rs
  • zstd/src/dictionary/frequency/tests.rs
  • zstd/src/dictionary/mod.rs
  • zstd/src/dictionary/reservoir.rs
  • zstd/src/dictionary/reservoir/tests.rs
  • zstd/src/dictionary/tests.rs
  • zstd/src/encoding/block_header.rs
  • zstd/src/encoding/block_header/tests.rs
  • zstd/src/encoding/blocks/compressed.rs
  • zstd/src/encoding/blocks/compressed/tests.rs
  • zstd/src/encoding/bt/ldm_helper_tests.rs
  • zstd/src/encoding/bt/mod.rs
  • zstd/src/encoding/compress_bound_tests.rs
  • zstd/src/encoding/cparams.rs
  • zstd/src/encoding/cparams/tests.rs
  • zstd/src/encoding/dfast/extend_with_repcode_tests.rs
  • zstd/src/encoding/dfast/mod.rs
  • zstd/src/encoding/dict_attach.rs
  • zstd/src/encoding/dict_attach/tests.rs
  • zstd/src/encoding/fastpath/mod.rs
  • zstd/src/encoding/fastpath/neon.rs
  • zstd/src/encoding/fastpath/neon/tests.rs
  • zstd/src/encoding/fastpath/scalar.rs
  • zstd/src/encoding/fastpath/scalar/tests.rs
  • zstd/src/encoding/fastpath/simd128.rs
  • zstd/src/encoding/fastpath/simd128/tests.rs
  • zstd/src/encoding/fastpath/tests.rs
  • zstd/src/encoding/frame_compressor.rs
  • zstd/src/encoding/frame_compressor/tests.rs
  • zstd/src/encoding/frame_header.rs
  • zstd/src/encoding/frame_header/tests.rs
  • zstd/src/encoding/hc/generator.rs
  • zstd/src/encoding/hc/generator/tests.rs
  • zstd/src/encoding/hc/hc_tests.rs
  • zstd/src/encoding/hc/mod.rs
  • zstd/src/encoding/hc/optimal.rs
  • zstd/src/encoding/hc/priceset.rs
  • zstd/src/encoding/hc/priceset/tests.rs
  • zstd/src/encoding/incompressible.rs
  • zstd/src/encoding/incompressible/tests.rs
  • zstd/src/encoding/ldm/gear_hash.rs
  • zstd/src/encoding/ldm/gear_hash/tests.rs
  • zstd/src/encoding/ldm/mod.rs
  • zstd/src/encoding/ldm/params.rs
  • zstd/src/encoding/ldm/params/tests.rs
  • zstd/src/encoding/ldm/search.rs
  • zstd/src/encoding/ldm/search/tests.rs
  • zstd/src/encoding/ldm/table.rs
  • zstd/src/encoding/ldm/table/tests.rs
  • zstd/src/encoding/ldm/tests.rs
  • zstd/src/encoding/levels/config.rs
  • zstd/src/encoding/levels/fastest.rs
  • zstd/src/encoding/levels/fastest/tests.rs
  • zstd/src/encoding/levels/mod.rs
  • zstd/src/encoding/match_generator.rs
  • zstd/src/encoding/match_generator/dict_prime.rs
  • zstd/src/encoding/match_generator/mod.rs
  • zstd/src/encoding/match_generator/tests.rs
  • zstd/src/encoding/match_table/storage.rs
  • zstd/src/encoding/match_table/storage/bt_pair_index_wrap_tests.rs
  • zstd/src/encoding/match_table/storage/storage_tests.rs
  • zstd/src/encoding/match_table/storage/stream_abs_headroom_tests.rs
  • zstd/src/encoding/mod.rs
  • zstd/src/encoding/parameters.rs
  • zstd/src/encoding/parameters/tests.rs
  • zstd/src/encoding/row/mod.rs
  • zstd/src/encoding/row/neon_tag_mask_tests.rs
  • zstd/src/encoding/row/tag_mask_tests.rs
  • zstd/src/encoding/sequence_capture.rs
  • zstd/src/encoding/sequence_capture/tests.rs
  • zstd/src/encoding/simple/fast_kernel/count.rs
  • zstd/src/encoding/simple/fast_kernel/count/tests.rs
  • zstd/src/encoding/simple/fast_kernel/hash_table.rs
  • zstd/src/encoding/simple/fast_kernel/hash_table/tests.rs
  • zstd/src/encoding/simple/fast_kernel/kernel.rs
  • zstd/src/encoding/simple/fast_kernel/kernel/tests.rs
  • zstd/src/encoding/simple/fast_matcher.rs
  • zstd/src/encoding/simple/fast_matcher/tests.rs
  • zstd/src/encoding/strategy.rs
  • zstd/src/encoding/strategy/tests.rs
  • zstd/src/encoding/streaming_encoder.rs
  • zstd/src/encoding/streaming_encoder/tests.rs
  • zstd/src/encoding/util.rs
  • zstd/src/encoding/util/tests.rs
  • zstd/src/fse/fse_decoder.rs
  • zstd/src/fse/fse_decoder/tests.rs
  • zstd/src/fse/mod.rs
  • zstd/src/fse/tests.rs
  • zstd/src/histogram.rs
  • zstd/src/histogram/tests.rs
  • zstd/src/huff0/huf_cstream.rs
  • zstd/src/huff0/huf_cstream/tests.rs
  • zstd/src/huff0/huff0_decoder.rs
  • zstd/src/huff0/huff0_decoder/tests.rs
  • zstd/src/huff0/huff0_encoder.rs
  • zstd/src/huff0/huff0_encoder/tests.rs
  • zstd/src/huff0/mod.rs
  • zstd/src/huff0/tests.rs
  • zstd/src/skippable.rs
  • zstd/src/skippable/tests.rs

Comment thread cli/src/tests.rs Outdated
Comment thread zstd/src/decoding/frame_decoder/tests.rs Outdated
polaz added 2 commits June 23, 2026 14:30
Replace the lone CWD-relative `std::fs::read("./dict_tests/dictionary")`
with the `include_bytes!("../../../dict_tests/dictionary")` the rest of
the file already uses, so the test no longer depends on the harness
working directory.
The `#[cfg(feature = "bench_internals")]` white-box capture helpers
(`huf_weight_description_for_test`, `huf_encode4x_for_test`,
`level22_block_ranges` / `merge_block_delimiters` /
`collect_level22_sequences[_with_delimiters]`) are bench facade reached
from the crate-root `bench_internals` surface, not test cases. The test
sweep had swept them into the `tests` submodules, so the
`bench_internals` clippy build could no longer resolve them. Move them
back to `huff0_encoder` / `match_generator` production (restoring the
`super::cost_model` paths the deeper nesting had rewritten).
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.69466% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
zstd/src/encoding/hc/generator.rs 90.34% 25 Missing ⚠️
zstd/src/encoding/hc/mod.rs 33.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

`fse::round_trip` and its `check_tables` helper are gated
`#[cfg(any(test, feature = "fuzz_exports"))]` and consumed by the `fse`
fuzz target through the crate's public surface, not test cases. The test
sweep moved them into `fse/tests.rs` (compiled only under `test`), so the
`fuzz_exports` build could no longer resolve `round_trip` and the
encoder's `into_table` / `encode` went dead. Move both back to
`fse/mod.rs`.
@polaz polaz merged commit bbd74c9 into main Jun 23, 2026
27 checks passed
@polaz polaz deleted the refactor/#441-extract-level-config branch June 23, 2026 12:12
This was referenced Jun 23, 2026
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.

refactor(encoding): split match_generator.rs monolith into per-concern modules

1 participant