Repository navigation
style(lint): replace constant-size chunks_exact with as_chunks - #277
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces all 32 constant-size
chunks_exactcalls in the workspace withas_chunks::<N>().0.iter().Why this is not part of the audit chantier
mainis already red for this, and was before any of the remediation work existed — its last CI run, onfix(crates): ship the README with every published crate (#219), failed on the same job. A newer stable clippy on the GitHub runner addedchunks_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_chunksyields&[T; N]wherechunks_exactyielded&[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 passesp.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_exactwith 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 alonecargo fmt --all --check— cleancargo test --workspace— all greencargo clippy --workspace --all-targets -- -D warnings— clean on the local (older) toolchainTracking
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.