Skip to content

chore(clippy): clear chunks_exact_to_as_chunks in niubash-runtime (#450 parallel batch) - #485

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/450-chunks-exact-to-as-chunks
Oct 21, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/450-chunks-exact-to-as-chunks

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Parallel batch per #450: clears one lint category in niubash-runtime.

  • Category: clippy::chunks_exact_to_as_chunks
  • All 6 warning sites are in crates/niubash-runtime/src/logo.rs (render_logo / render_logo_to_string pixel decoders): buf.chunks_exact(N) → buf.as_chunks::<N>().0.iter(). Identical semantics — as_chunks().0 yields exactly the full chunks and drops the remainder, same as chunks_exact.
  • Also refreshes the root Cargo.lock: current rubash master no longer depends on sha2, and the stale lock made --locked builds fail.

Sibling batches: #469 (needless_borrow), #476 (cloned_ref_to_slice_refs) — untouched here.

Counts

Basis: rustc 1.99.0 stable, cargo clippy -p niubash-runtime --all-targets (JSON diagnostics, same counting method as the tracking total).

Lint Before After
clippy::chunks_exact_to_as_chunks 12 0
All clippy warnings 163 151

Test plan

  • cargo clippy -p niubash-runtime --all-targets — category 12 → 0, total 163 → 151, no new warnings
  • cargo fmt --check -p niubash-runtime — clean
  • cargo test -p niubash-runtime --lib --locked — 567 passed, 0 failed

Refs #450

Generated with Devin

@caomengxuan666

Copy link
Copy Markdown
Member Author

CR(本轮不合并)

logo.rs 的 lint 本体全部达标(见下),但 Cargo.lock 那个 hunk 是反的,正是本 PR CI 全红的直接原因(7 个 job 全部 cannot update the lock file ... because --locked was passed)。

机制

PR 描述的前提「current rubash master no longer depends on sha2」方向反了:当前 rubash master 恰恰新加了 sha2 = "0.10"(root Cargo.toml,build.rs 测试编译用的 dev-dependency,46-53 行注释写明)。而 niubash 仓的解出路径不是普通 git 依赖:

  • 根 Cargo.toml 常驻 [patch."https://github.com/unixwin/rubash.git"] rubash = { path = "../rubash" };
  • CI(ci.yml Checkout rubash path dependency 步)显式 git clone --depth 1 unixwin/rubash ../rubash——CI 上 patch 解到新鲜 rubash master,manifest 带 sha2,所以 lock 里 rubash deps 数组的 "sha2" 必须在(9f4621a 加的就是它);PR 把它删了 → resolve 要写回 → --locked 炸,7 个 job 全红。

本地为什么会看着没事(坑位留档):本地若 ../rubash 兄弟目录是一个 sha2 加入之前的旧检出,patch 解出的 manifest 不带 sha2,cargo build --locked 同样绿的——本地绿/CI 红的分叉就是这么来的(本轮两侧都复现了)。判据以 CI 的「clone 最新 master」为准。

修法

删掉 Cargo.lock hunk,只留 logo.rs,push 即可。lint 实质本轮已按 #469/#476 同口径验全(rustc 1.99.0 stable,-p niubash-runtime --all-targets JSON 计数):

项 master 基线 本 PR
clippy::chunks_exact_to_as_chunks 12 0
总 clippy warnings 163 151(163−12,严丝合缝)
clippy::needless_borrow 0 0
cloned_ref_to_slice_refs 0 0
其余 39 个类别 — 逐类别零变化

删 hunk 后 CI 预期只剩 master 既有的 cargo test --workspace --locked 在 -p niubash --test console_window_gate 的红(master tip 060717b 的 push run 同样红在那一格,与本批无关、不由本 PR 背)——该基线问题建议在 #450 主票里单独记。

… parallel batch)

Replace buf.chunks_exact(N) with buf.as_chunks::<N>().0.iter() in the
logo pixel decoders; identical full-chunk semantics, remainder still
dropped.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666
caomengxuan666 force-pushed the fix/450-chunks-exact-to-as-chunks branch from 99a476a to 273841c Compare October 21, 2026 01:50
@caomengxuan666

Copy link
Copy Markdown
Member Author

按评审意见返工(对应评论 6305878150):

  • 丢弃了 Cargo.lock hunk(git checkout origin/master -- Cargo.lock)——"sha2" 行恢复为 master 9f4621a 的状态。之前那句「sha2 is no longer a rubash dependency」前提方向反了:当前 rubash master 恰恰新加了 sha2 = "0.10" dev-dependency,CI Checkout rubash path dependency 步 clone 新鲜 master 后 --locked resolve 需要该条目。commit message 中的错误断言也一并修正。
  • PR 现在只含 logo.rs 的 chunks_exact(N) → as_chunks::<N>().0.iter() lint 修复,语义不变(满块迭代,尾部余数同样丢弃)。
  • 已 --force-with-lease 推送 273841c。

Generated with Devin

@caomengxuan666
caomengxuan666 merged commit 378948f into master Oct 21, 2026
8 of 9 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

终审:通过,合并

Cargo.lock hunk 去除后的返工验收四项全过(head 273841c7):

  1. diff 只剩 logo.rs — master...head 仅 crates/niubash-runtime/src/logo.rs(6 处 chunks_exact(N) → as_chunks::<N>().0.iter(),机械改写、余量丢弃语义与 chunks_exact 一致);返工 commit 本身单文件。Cargo.lock 与 master(8dd8407)cmp 逐字节一致。
  2. chunks_exact_to_as_chunks = 0 — cargo clippy -p niubash-runtime --all-targets,rustc/clippy 1.99.0(与口径一致):该 lint 0 报。
  3. 其余类别零变化 — 与 master 同命令全类别 tally 逐行 diff,唯一差异即 chunks_exact_to_as_chunks 1→0;needless_borrow(exact)0、cloned_ref_to_slice_refs 0 保持。
  4. runtime 测试绿 — cargo test -p niubash-runtime --lib --locked:567 passed / 0 failed。

CI:build-and-test 红点为 console_window_gate 已知 flake(detached_builtin_only_session_allocates_zero_conhosts,tests/console_window_gate.rs:382),其余单测面在该 job 内全 ok;cross-check ×2、cross-target ×4、smoke 全 pass —— 按容忍口径放行。另注:base 落后 master(#484 已并),但本 PR diff 与之零交集,MERGEABLE。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant