fix(cosh-ng): swap chunks_exact for as_chunks - #2742
Conversation
Clippy 1.98 on stable rolls the new chunks_exact_to_as_chunks lint onto pre-existing decode_hex code, turning the fast-checks job on #2708 red. as_chunks::<2>().0.iter() is semantics-preserving: same full chunks, same dropped tail remainder as chunks_exact(2). Fixes: 1a93589 ("feat(cosh-ng): [core,shell] add audit log") Assisted-by: Qoder Signed-off-by: Jiangtian Feng <jiangtianf97@163.com>
Code Review: fix(cosh-ng): swap chunks_exact for as_chunksVerdict: LGTM ✅ Correctness变更语义等价,分析如下:
变换是纯机械性的 clippy 建议替换,无逻辑变更。 观察(非阻塞)
总结单文件、单函数、机械性 lint 修复,风险极低。验证充分(PR 描述中列出了等价性测试)。LGTM。 |
|
Thanks for the thorough review and the LGTM! Confirming the follow-up plan for the non-blocking observations:
It is being prepared right now and should land shortly. One small ask: you are one of the requested reviewers, and the branch ruleset requires an approval before this PR can merge — would you mind converting your verbal LGTM into a formal review approval when convenient? No rush, just so the PR does not sit idle on that requirement. Thanks! |
Why
Clippy 1.98 (rolling stable toolchain) ships the new
chunks_exact_to_as_chunkslint. It fires on pre-existingdecode_hexcode incosh-platform, turning the fast-checks job red on PRs that run stable clippy (e.g. #2708).What changed
Swapped
.chunks_exact(2)for.as_chunks::<2>().0.iter()indecode_hex— the exact form clippy suggests. Semantics-preserving: both iterate full 2-byte chunks and drop the tail remainder; the length-parity check above guarantees the remainder is always empty here.Related issue
no-issue: pre-existing code flagged by a new clippy lint, not a user-visible bug. Unblocks the #2708 fast-checks job. Attribution:
Fixes: 1a935895a391e9714e000fab00c3602a6580cd79("feat(cosh-ng): [core,shell] add audit log") in the commit body per repo convention.User / Agent impact
None. Internal API-equivalent refactor of a private hex decoder.
Risk and compatibility
Low risk:
as_chunksstabilized in Rust 1.88 and cosh-ng CI pins 1.89, so the pinned-toolchain job compiles unchanged.Validation
cargo clippy -p cosh-platform --all-targets -- -D warningsfails atquery.rs:629; post-fix exit 0RUSTUP_TOOLCHAIN=1.89.0):cargo clippy -p cosh-platform --all-targets -- -D warningsclean;cargo test -p cosh-platform311 passed / 0 failedcargo fmt --all --checkclean under both 1.89 and stable 1.98decode_hexagree on all 484 hex-pair inputs plus 10 boundary inputs (empty, odd-length, non-hex)Documentation and rollback
No docs change. Rollback = revert the single commit.