fix(stdlib): use as_chunks in hex_to_bytes to unbreak clippy on Rust 1.98 - #719
Conversation
Rust 1.98.0 (released 2026-08-18) promotes `clippy::chunks_exact_to_as_chunks` into the default lint set. Both CI lanes run `-D warnings`, so the single `chunks_exact(2)` call in `hex_to_bytes` became a hard compile error and took down the nightly Windows build (run 33235732094) and CI on main (run 33173832824). No behaviour change. The length guard above the call already rejects odd-length input, so `as_chunks::<2>()`'s remainder half is always empty and discarding it drops nothing. Each pair now arrives as `&[u8; 2]` instead of a runtime-length slice, which is what the lint is asking for; byte-oriented decoding (and therefore the multi-byte-safety property the doc comment describes) is unchanged. `slice::as_chunks` is stable since 1.88.0, comfortably under the crate's 1.94 MSRV.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesCrypto decoding
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This localized change updates hex decoding to satisfy the newer Clippy lint without changing behavior; the existing validation remains in place and the relevant checks pass. No actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes a new Clippy lint failure on Rust 1.98 by updating hex_to_bytes in the stdlib crypto module to use slice::as_chunks::<2>() instead of chunks_exact(2), keeping behavior the same while satisfying the newer lint.
Changes:
- Replace
chunks_exact(2)withas_chunks::<2>().0.iter()inhex_to_bytes. - Add an inline comment explaining why discarding the remainder from
as_chunksis sound given the existing even-length guard.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
CI has settled on this branch: 19 pass, 1 skip ( The check that matters is One caveat worth stating plainly rather than glossing: PR CI runs clippy on Ubuntu only (the long-standing structural gap — Windows clippy executes solely in the nightly), so the Windows clippy step that actually broke run 33235732094 is not directly re-proven here. I consider the risk negligible — the lint fires on plain Merging this should also turn PR #717 green (its red is the same inherited lint) and restore a trustworthy rollup on #716. Posted by the WFL repo warden (automated triage pass). |
|
Follow-up automated pass (09:0x UTC) — I went back and bounded the Windows-clippy caveat I flagged on this PR earlier, and the news is good for merging. The nightly's Windows clippy hit exactly one lint, and it is the one this PR fixes. Pulling the full job log for the failed nightly (run 33235732094, job
What the log does not prove, stated plainly: because the lib failed, clippy never reached the Verification note: the sandbox toolchain used to check this is Net: this PR is green (18 pass / 2 skip / 0 fail), Posted by the WFL repo warden (automated triage pass). |
Summary
The nightly build and CI on
mainare both red. This is a one-line fix for a single new clippy lint.Root cause: toolchain drift, not a code regression. Rust 1.98.0 shipped on 2026-08-18 and promoted
clippy::chunks_exact_to_as_chunksinto the default lint set. Both CI lanes pindtolnay/rust-toolchain@stableand run clippy with-D warnings, so the singlechunks_exact(2)call insrc/stdlib/crypto.rs(hex_to_bytes) turned into a hard compile error the moment either lane next ran.Failing runs:
Build WFL for Windowsfailed at step 8Run clippyafter 93s;Create or Update Nightly Releaseskipped, so no nightly artifacts were published for 2026-08-29.main) and 33173861966 —Build, Test, Clippyfailed atRun Clippy, same lint.Why it surfaced only now
maindid not move between 2026-08-14 and 2026-08-28. Every scheduled nightly in that window took the designedshould_build=falseno-change skip, so clippy did not actually execute against the tree after Rust 1.98 landed on 08-18. Merging #718 on 08-28 was simply the first thing to exercise the lint. The repo read green for ten days while already being broken — worth a look separately from this PR (see below).What changed
src/stdlib/crypto.rsonly —chunks_exact(2)→as_chunks::<2>().0.iter(), plus a comment explaining why discarding the remainder half is sound.No behaviour change. The
is_multiple_of(2)guard directly above already rejects odd-length input, soas_chunks::<2>()'s remainder is always empty and discarding it drops nothing. Each pair now arrives as&[u8; 2]rather than a runtime-length slice — decoding stays byte-oriented, so the multi-byte-safety property the doc comment describes is untouched.slice::as_chunksis stable since 1.88.0, comfortably under the crate'srust-version = "1.94"MSRV (verified against the 1.98.0 stdlib source, not from memory).Verification
Run locally on rustc 1.98.0 (88d9e12ae 2026-08-18) — the same toolchain
@stableresolves to in CI. Reproduced the failure first, then confirmed the fix:cargo clippy --lib -- -D warnings(pre-fix)cargo clippy --all-targets --all-features -- -D warningsci.ymlgate verbatimcargo fmt --all -- --checkcargo test --libBecause
hex_to_bytesdecodes untrusted key material, I also proved the two implementations are observably identical rather than assuming it: a differential harness compared old vs. new over 18,327 inputs — every valid 1- and 2-byte UTF-8 string, plus multi-byte characters (é,日本,a日), odd lengths, empty input, non-hex bytes, embedded NULs, and 64-byte keys. Zero mismatches.Per
testing.md§risk classes this is R0 CI mechanics: the existing clippy gate is the failing-first test, so no manufactured Red→Green test is included. The differential harness was verification scaffolding and is deliberately not committed.Not fixed here, worth deciding
A no-change nightly skip means a toolchain-drift break stays invisible until someone merges. A cheap mitigation would be having the nightly still run fmt/clippy/test when
should_build=false, and only skip the expensive packaging and release steps — that would have caught this on 08-19 instead of 08-29. Happy to open that separately if you want it; I did not bundle a workflow change into a lint fix.Posted by the WFL repo warden (automated triage pass). I do not merge — this needs a human.
Summary by CodeRabbit