Skip to content

fix(pdf): satisfy clippy::chunks_exact_to_as_chunks so CI is green again - #118

Merged
0xMassi merged 1 commit into
mainfrom
fix/clippy-chunks-exact
Aug 26, 2026
Merged

fix(pdf): satisfy clippy::chunks_exact_to_as_chunks so CI is green again#118
0xMassi merged 1 commit into
mainfrom
fix/clippy-chunks-exact

Conversation

@0xMassi

@0xMassi 0xMassi commented Aug 25, 2026

Copy link
Copy Markdown
Owner

CI on main is currently red, and it blocks every open PR.

Rust 1.98 (2026-08-18) added clippy::chunks_exact_to_as_chunks, on by default. It fires on pre-existing code in webclaw-pdf, and CI runs cargo clippy --all -- -D warnings against dtolnay/rust-toolchain@stable.

Nothing pushed to main between 2026-08-16 and that release, so no run surfaced it until an external PR was re-checked. Because CI is now a required status check, this blocks PRs that have nothing to do with PDF decoding.

Reproduced on unmodified main after rustup update stable:

warning: using `chunks_exact` with a constant chunk size
  --> crates/webclaw-pdf/src/lib.rs:147:14
  help: consider using `as_chunks` instead: `as_chunks::<2>().0.iter()`

The change

The UTF-16BE branch of the PDF string decoder now uses as_chunks::<2>(), which yields [u8; 2] directly. u16::from_be_bytes takes that array, so the [c[0], c[1]] reconstruction and its bounds checks go away.

Behaviour is identical: as_chunks splits on the same boundary as chunks_exact and discards the same trailing remainder, which for a UTF-16BE payload is an odd trailing byte already being dropped.

Verified on rust 1.98

clippy --all -D warnings, fmt --check --all, test --workspace, doc --no-deps --workspace, and both wasm32 checks all pass.

One note

This raises the effective floor to a toolchain with as_chunks stabilised. No crate declares rust-version and CI always uses latest stable, so nothing in-repo breaks. Worth knowing if an MSRV is ever pinned.

Why this change was needed:
Rust 1.98 (2026-08-18) added clippy::chunks_exact_to_as_chunks, on by
default. It fires on pre-existing code in webclaw-pdf, and CI runs
`cargo clippy --all -- -D warnings` with dtolnay/rust-toolchain@stable, so
every job that lints now fails.

Nothing pushed to main between 2026-08-16 and the toolchain release, so no
run surfaced it until an external PR was re-checked. Since CI is now a
required status check on main, this blocked every open PR in the repo, none
of which had anything to do with PDF decoding.

Reproduced on unmodified main after `rustup update stable`:
  warning: using `chunks_exact` with a constant chunk size
    --> crates/webclaw-pdf/src/lib.rs:147:14
    help: consider using `as_chunks` instead: `as_chunks::<2>().0.iter()`

What changed:
- The UTF-16BE branch of the PDF string decoder now uses `as_chunks::<2>()`,
  which yields `[u8; 2]` directly. `u16::from_be_bytes` takes that array, so
  the `[c[0], c[1]]` reconstruction and its bounds checks go away.

Behaviour is identical: `as_chunks` splits on the same boundary as
`chunks_exact` and discards the same trailing remainder, which for a
UTF-16BE payload is an odd trailing byte we were already dropping.

Problem solved:
`cargo clippy --all -- -D warnings` passes on rust 1.98. Verified with the
full CI set on 1.98: clippy, fmt, test --workspace, doc, and both wasm32
checks.

Note this raises the effective floor to a toolchain with `as_chunks`
stabilised. No crate declares rust-version, and CI always uses latest
stable, so nothing in-repo breaks; worth knowing if an MSRV is ever pinned.
@0xMassi
0xMassi merged commit 0ba90de into main Aug 26, 2026
4 checks passed
@0xMassi
0xMassi deleted the fix/clippy-chunks-exact branch August 26, 2026 08:16
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