fix(core): parse a hex id without chunks_exact, which clippy now rejects - #78
Merged
Conversation
…shape Nothing about the code changed its mind; the lint did. A newer clippy on CI raises `chunks_exact_to_as_chunks` for `chunks_exact(2)` over a constant, and clippy warnings are errors here, so `main` stopped building on all three platforms. Two spellings were rejected before this one. `as_chunks` is the lint's own suggestion, but it stabilised in exactly the version this workspace declares as its floor, which is closer to the edge than a parser of untrusted input needs to be. Indexing a range instead trades that lint for `needless_range_loop`. So the digits are read directly. That removes the UTF-8 question rather than answering it: any byte of a multi-byte character is above 0x7f and is simply not a hex digit, so it is refused without a boundary check, and the `from_utf8` step this replaces is gone rather than reimplemented. `from_str_radix` accepted upper and lower case, and hand-rolled digits do not get that for free, so a test now pins it — Git writes lowercase, people paste either, and ids still come back lowercase the way Git spells them.
youhide
force-pushed
the
clippy-as-chunks
branch
from
August 21, 2026 00:52
5fa45e1 to
3ec3c85
Compare
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.
CI on
mainis red on all three platforms and this unblocks it. Not a plan item — a prerequisite for the one in #77.What happened
Nothing about the code changed its mind; the lint did. A newer clippy on the CI runners raises
clippy::chunks_exact_to_as_chunksforchunks_exact(2)over a constant. Clippy warnings are errors in this workspace, sohidegit-corestopped compiling undercargo clippyeverywhere.It is invisible locally: this machine has clippy 0.1.97, the runners have newer.
Why not the lint's own suggestion
as_chunksstabilised in exactly the version this workspace declares as its floor — 1.88, whichrust-toolchain.tomland the MSRV job both pin. Putting a parser of untrusted repository input on the precise edge of the declared minimum is closer than it needs to be, and the MSRV job runscargo check, not clippy, so it would not have been the thing to catch a mistake there.Indexing is simpler and older than both spellings:
str::geton a byte range yieldsNonefor anything that is not a character boundary, so a multi-byte character is rejected before it reaches the radix parser rather than after — which is exactly what thestd::str::from_utf8call it replaces was there to do. One fewer step, same refusals.Behaviour
Unchanged. The three existing
ObjectIdtests cover the round trip, the SHA-256 length, and the malformed input that must be refused — all still pass, and no test needed touching, which is the point.Gate
cargo fmt --all -- --checkandcargo test -p hidegit-coregreen locally. The clippy half can only be verified by CI, since the lint does not exist in this machine's toolchain — that is the whole reason this PR exists.