Skip to content

Commit 4023e14

Browse files
committed
docs(ldm): align staleness check wording + scope docs.rs feature set
Three doc/metadata corrections across the LDM surface: 1. `bt::BtMatcher::prepare_ldm_candidates` (bt/mod.rs:354) and `ldm::LdmProducer::generate_into` (ldm/mod.rs:167, plus the regression-test doc at ldm/mod.rs:589) all described the staleness check as `entry.offset <= history_abs_start`. The actual implementation since commit e1932b2 is an inclusive lower bound: `find_best_match` rejects entries with `match_abs < lowest_index_abs` so entries at exactly `lowest_index_abs == history_abs_start` survive. Updated the three doc sites to describe the inclusive filter, pointing at `ldm::search::FindBestMatchInputs::lowest_index_abs` for the canonical definition. 2. `[package.metadata.docs.rs] all-features = true` would also enable `rustc-dep-of-std` (libstd-build-only — swaps in `rustc-std-workspace-*` core/alloc), `bench_internals` (widens the public API for benches), and `fuzz_exports` (widens it for fuzz targets). None of those should appear on docs.rs. Replaced with explicit `features = ["std", "hash", "dict_builder"]` so the published documentation covers exactly the public surface. 472 / 472 lib tests pass under default features AND `--no-default-features`. 11 / 11 doctests pass. `cargo doc --lib --features dict_builder,std,hash` builds without warnings. `cargo clippy --lib --tests -- -D warnings` clean in both feature configs.
1 parent 0777817 commit 4023e14

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

zstd/Cargo.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ readme = "README.md"
1717
keywords = ["zstd", "zstandard", "decompression", "compression", "pure-rust"]
1818
categories = ["compression"]
1919

20-
# docs.rs builds the crate with all features enabled so feature-gated items
21-
# (e.g. the `dictionary` module behind `dict_builder`) appear in the published
22-
# documentation. The `--cfg docsrs` flag activates the `#[cfg_attr(docsrs,
23-
# doc(cfg(...)))]` annotations that render feature badges on each item.
20+
# docs.rs builds the crate with the public feature set so feature-gated
21+
# items (e.g. the `dictionary` module behind `dict_builder`) appear in the
22+
# published documentation. We list the public features explicitly rather
23+
# than using `all-features = true` because the manifest also exposes
24+
# `rustc-dep-of-std` (libstd-build-only — swaps in `rustc-std-workspace-*`
25+
# crates), `bench_internals` (widens the API surface for benches), and
26+
# `fuzz_exports` (widens it for fuzz targets); none of these should appear
27+
# on docs.rs. The `--cfg docsrs` flag activates the
28+
# `#[cfg_attr(docsrs, doc(cfg(...)))]` annotations that render feature
29+
# badges on each item.
2430
[package.metadata.docs.rs]
25-
all-features = true
31+
features = ["std", "hash", "dict_builder"]
2632
rustdoc-args = ["--cfg", "docsrs"]
2733

2834
[dependencies]

zstd/src/encoding/bt/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ impl BtMatcher {
351351
/// coordinates** (so its bucket-table entries remain valid
352352
/// across window evictions — entries inserted by an earlier
353353
/// view of the frame are filtered by the staleness check
354-
/// `entry.offset <= history_abs_start`). The caller is
355-
/// expected to pass:
354+
/// `entry.offset < history_abs_start`, i.e. inclusive lower
355+
/// bound: entries at exactly `history_abs_start` survive,
356+
/// see `ldm::search::FindBestMatchInputs::lowest_index_abs`).
357+
/// The caller is expected to pass:
356358
///
357359
/// * `live_history` — the contiguous *live* slice of the
358360
/// per-frame `MatchTable::history` (`&history[history_start..]`).

zstd/src/encoding/ldm/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ impl LdmProducer {
164164
/// **absolute stream coordinates** so the bucket table stays
165165
/// valid across window evictions: after a slide,
166166
/// `history_abs_start` advances and any entry inserted by an
167-
/// earlier window is filtered by the `entry.offset <=
168-
/// lowest_index_abs` staleness check in
169-
/// [`find_best_match`].
167+
/// earlier window is filtered by the inclusive lower-bound
168+
/// staleness check `entry.offset < lowest_index_abs` in
169+
/// [`find_best_match`] (entries at exactly
170+
/// `lowest_index_abs == history_abs_start` survive).
170171
///
171172
/// Implements the donor pipeline from
172173
/// `ZSTD_ldm_generateSequences_internal`
@@ -586,8 +587,10 @@ mod tests {
586587
/// entries from call 1 must remain reachable: their
587588
/// absolute offsets still point at the SAME bytes
588589
/// (now further left in the live slice), and the
589-
/// staleness check `entry.offset <= history_abs_start`
590-
/// keeps them in-window.
590+
/// inclusive lower-bound staleness check
591+
/// `entry.offset < history_abs_start` keeps them
592+
/// in-window (entries at exactly `history_abs_start`
593+
/// survive).
591594
///
592595
/// If the producer had stored slice-relative indices
593596
/// instead, call 2 would either miss the long-range match

0 commit comments

Comments
 (0)