Skip to content

style(lint): replace constant-size chunks_exact with as_chunks - #277

Merged
LeadcodeDev merged 1 commit into
mainfrom
fix/clippy-chunks-exact
Sep 22, 2026
Merged

LeadcodeDev merged 1 commit into
mainfrom
fix/clippy-chunks-exact

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

What

Replaces all 32 constant-size chunks_exact calls in the workspace with as_chunks::<N>().0.iter().

Why this is not part of the audit chantier

main is already red for this, and was before any of the remediation work existed — its last CI run, on fix(crates): ship the README with every published crate (#219), failed on the same job. A newer stable clippy on the GitHub runner added chunks_exact_to_as_chunks, and the workspace has 32 call sites that predate all current work. Every open pull request inherits the failure, which is why this lands on its own rather than inside any of them.

The local toolchain here is clippy 0.1.97 (2026-07-14), which does not carry the lint yet — that is why the chantier's own verification passed locally while CI did not.

Not a pure substitution

as_chunks yields &[T; N] where chunks_exact yielded &[T], so two sites needed real edits rather than a rename:

  • crates/rustmotion-core/src/engine/transition.rs — an assertion compared the chunk against an array literal; it now dereferences.
  • crates/rustmotion-components/tests/caption_presets.rs — a predicate takes &[u8]; the call site now passes p.as_slice().

The array type is the better one regardless: it is what makes the chunk length visible to the compiler instead of a runtime invariant.

Verification

Completeness here is checkable rather than argued — the lint fires on chunks_exact with a literal size, and none remain in the workspace, so it has nothing left to fire on. That grep is the verification, since the local clippy predates the lint.

  • cargo check --workspace --all-targets — clean, verified on a fresh checkout of this branch alone
  • cargo fmt --all --check — clean
  • cargo test --workspace — all green
  • cargo clippy --workspace --all-targets -- -D warnings — clean on the local (older) toolchain

Tracking

No issue exists for this; it was found by a CI failure on an unrelated pull request rather than reported. Opening one for a mechanical lint fix that is already resolved here seemed like ceremony — say the word if you would rather have the paper trail.

A newer stable clippy adds `chunks_exact_to_as_chunks`, which fires on every
`chunks_exact` call whose size is a literal. The workspace has 32 of them
across 20 files, so the clippy job fails on every branch — main included. Its
last run, from before this work existed, was already red for the same reason.

The replacement is clippy's own suggestion, `as_chunks::<N>().0.iter()`. It is
not a pure substitution: the iterator now yields `&[T; N]` rather than `&[T]`,
so two sites needed real edits — an assertion comparing against an array
literal, and a predicate taking `&[u8]`. The array type is the better one
anyway; it is what makes the chunk length visible to the compiler.

Completeness is checkable rather than argued: no `chunks_exact` with a literal
size remains in the workspace, so the lint has nothing left to fire on. The
local toolchain predates this lint, so that grep is the verification, not a
local clippy run.
@LeadcodeDev LeadcodeDev added the bug Something isn't working label Sep 22, 2026
@LeadcodeDev LeadcodeDev self-assigned this Sep 22, 2026
@LeadcodeDev
LeadcodeDev merged commit 22914ea into main Sep 22, 2026
3 checks passed
@LeadcodeDev
LeadcodeDev deleted the fix/clippy-chunks-exact branch September 22, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant