fix(cosh-ng): swap remaining chunks_exact uses - #2756
Conversation
Clippy 1.98 raises chunks_exact_to_as_chunks on the two remaining chunks_exact(2) sites; swap both to as_chunks::<2>().0.iter(), the exact form clippy suggests (follow-up to alibaba#2742). Fixes: c818e11 ("fix(cosh-ng): [core] confine read tools") Fixes: 8d4d74c ("feat(cosh-ng): add shell prompt recommendations") Assisted-by: Qoder Signed-off-by: Jiangtian Feng <jiangtianf97@163.com>
There was a problem hiding this comment.
本次修改主要是将若干 chunks_exact(2) 换成 as_chunks::<2>().0.iter() 以满足新 clippy lint 要求,作用范围仅在 cosh-core 和 cosh-shell 内部,不涉及对外行为。
我重点核对了:
decode_utf16_bytes/decode_hex对奇数字节尾部的处理是否保持一致;- PR 描述与实际 diff 是否完全一致,避免遗漏
chunks_exact(2)站点; - MSRV 及 clippy lint 行为与使用的
as_chunks写法是否兼容。
🤖 Generated by Qoder • View workflow run
Code Review — PR #2756结论:LGTM ✅ — 未发现阻塞问题语义等价性验证Site 1 —
语义完全等价。 Site 2 —
语义完全等价。 MSRV 兼容性
Out-of-scope 站点PR 描述正确记录了以下已知未修复的
这些不是本 PR 的范围,且当前 CI pinned toolchains 不携带该 lint。 P0 / P1 未发现变更最小化、目标明确、语义等价,测试覆盖充分(cosh-core 124 passed, cosh-shell 1347 passed)。 |
code-reviewer-check: 审核通过 ✅已回读
未发现遗漏或误判,建议合并。 |
Review Check: LGTM ✅code-reviewer 的 review 结论经逐项代码回读验证,全部正确:
结论:可以合并,无阻塞问题。 |
KaiLongZhou
left a comment
There was a problem hiding this comment.
LGTM — review check passed. Semantic equivalence, MSRV compatibility, scope completeness, and commit quality all verified against source code.
Why
Clippy 1.98 (rolling stable) ships the new
chunks_exact_to_as_chunkslint. Beyond thedecode_hexsite fixed in #2742, the same lint fires on two morechunks_exact(2)sites. This PR delivers the follow-up promised in the #2742 review discussion (KaiLongZhou's non-blocking observations).What changed
Swapped
.chunks_exact(2)for.as_chunks::<2>().0.iter()(the exact form clippy suggests) in:cosh-core/src/tool/grep.rs—decode_utf16_bytes: both forms iterate full 2-byte units and drop the tail remainder; the odd tail is handled separately viahas_partial_unit, unchanged.cosh-shell/src/recommendation/personal_crypto.rs— test-onlydecode_hexhelper;std::str::from_utf8(pair)accepts the&[u8; 2]items via unsize coercion.Note on the other half of the promised follow-up: the MSRV alignment (observation 1) is already done — 77c4e8b ("feat(cosh-ng): [gateway] add ACP v1 foundation") set
rust-version = "1.88"on main, matching the 1.88.0 pinned CI jobs, so no Cargo.toml change is needed here.Related issue
no-issue: pre-existing code flagged by a new clippy lint, not a user-visible bug. Attribution per repo convention in the commit body:
Fixes: c818e11876a3 ("fix(cosh-ng): [core] confine read tools")andFixes: 8d4d74c12e70 ("feat(cosh-ng): add shell prompt recommendations").User / Agent impact
None. Semantics-preserving internal refactor; no public API, CLI, or behavior change.
Risk and compatibility
Low risk:
as_chunksstabilized in Rust 1.88; cosh-ng CI pins 1.88.0 (integration/release-build) and 1.97.1 (fast checks) — neither toolchain carries this lint, so the pinned jobs compile and lint unchanged.Validation
-p cosh-core -p cosh-shell --all-targets --keep-going):grep.rs:511andpersonal_crypto.rs:259RUSTUP_TOOLCHAIN=1.89.0:cargo clippy -p cosh-core -p cosh-shell --all-targets -- -D warnings— exit 0RUSTUP_TOOLCHAIN=1.88.0:cargo check -p cosh-core -p cosh-shell— exit 0 (MSRV floor confirmed; the two pre-existing fs2unlock()future-incompat warnings inextension/are unrelated to this change)cargo test -p cosh-core --lib— 124 passed / 0 failed;cargo test -p cosh-shell --lib— 1347 passed / 0 failedcargo fmt --all -- --checkwith both 1.89.0 and stable 1.98 — cleanpersonal_crypto.rs:66(SHA256_BLOCK_BYTES) and:172(chunks_exact(4)) also trip the same lint on clippy 1.98; they are not thechunks_exact(2)sites called out in the review and the pinned CI toolchains do not carry the lint. Left for a later pass if fast checks ever move to a lint-carrying toolchain (same forquery.rs, owned by fix(cosh-ng): swap chunks_exact for as_chunks #2742).Documentation and rollback
None. Revert the single commit to restore the previous form.