Skip to content

fix(rust-core): 修复 Rust 1.100 clippy 新增的 lint,并固定 Rust 1.100.0 工具链 - #51

Merged
xiaoyumuxi merged 2 commits into
mainfrom
fix/rust-core-clippy-1-100
Nov 15, 2026
Merged

xiaoyumuxi merged 2 commits into
mainfrom
fix/rust-core-clippy-1-100

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

概要

#50 合入后,Rust Core 工作流第一次检查全部 crate,Linux 作业在 Lint 一步失败(run 43681201096)。原因是 CI 的 stable 工具链已经是 Rust 1.100.0,它的 clippy 新增或加强了几条 lint,命中了 7 处现有代码。这些代码以前没有 CI 跑过 clippy,所以一直没人发现。

本 PR 做两件事:

  1. 按 lint 的建议修改这 7 处代码,行为不变。
  2. 用 rust-toolchain.toml 把 Rust 固定到 1.100.0,以后新版本 clippy 新增的 lint 只会在主动升级时出现,不会让无关的 PR 失败。

改动一:修复 clippy 1.100 的 lint

文件 lint 改法
toolchain/src/paths.rs question_mark Windows 路径不是盘符开头时,用 strip_prefix("//")? 要求它是 UNC 路径,去掉了多余的 else { return None }
project-generators/src/archive.rs if 守卫返回布尔字面量 real_directory 改成一个布尔表达式;Windows reparse point 判断拆成 reparse_point,cfg 只留在调用 MetadataExt 的地方
lsp-client/src/client/capabilities.rs chunks_exact 用了常量块长 改用 as_chunks::<5>().0
git/src/diff_blocks.rs、git/src/configuration.rs 同上 改用 as_chunks::<3>().0
build/src/options.rs 只用键却遍历了整个 map 改用 stored.keys()
core/src/tests/build_systems.rs 无用的 format! 改用 root.to_string()

as_chunks 从 Rust 1.88 起稳定。原来的代码分块前已经检查长度能被整除,或者本来就丢弃不足一块的余数,as_chunks().0 的行为和它一致。

改动二:固定 Rust 1.100.0

文件 改动
rust-toolchain.toml(新增) channel = "1.100.0"。在仓库里运行 cargo 时,rustup 自动安装并使用这个版本
.github/workflows/rust-core.yml 3 处 dtolnay/rust-toolchain@stable 改为 @1.100.0
.github/workflows/plugins-verify.yml Rust SDK 的 fmt/clippy 和 SDK e2e 两处 @stable 改为 @1.100.0;SDK 最低版本测试仍是 @1.87 + cargo +1.87,注释同步
scripts/rust-core/affected-crates.mjs 及测试 rust-toolchain.toml 加入 EVERY_CRATE,改动它会选中全部 crate
CONTRIBUTING.md 新增“工具链 / Toolchain”一节:安装方式、额外目标装在固定版本上、升级步骤、Lithe-IDEA 同步升级、SDK 保持 1.87;选中规则清单补上 rust-toolchain.toml
shared/plugins/README.md SDK 检查说明里的“另用 stable 跑 fmt 和 clippy”改为固定版本

工作流和固定文件必须写同一个版本字符串:rustup 把 1.100 和 1.100.0 当成两个工具链,写得不一致时 CI 会另装一份没有 clippy、rustfmt 和 Windows 目标的工具链。dtolnay/rust-toolchain 内部一律用 rustc +<版本>,所以 @1.87 那一步不受固定文件影响。

对开发者的影响:已经用 rustup 的人第一次在仓库里运行 cargo 时会自动下载 1.100.0,之后 Core 会完整重新编译一次;用 Homebrew 等非 rustup 方式安装的 Rust 不读这个文件。Lithe-IDEA 构建 Core 时用它自己仓库根目录的 rust-toolchain.toml,那边另开 PR 同步固定到 1.100.0。

验证(本地 macOS)

  • Rust 1.100.0(与 CI 相同):
    • cargo clippy --workspace --all-targets --all-features -- -D warnings:通过。
    • cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings:通过。
    • cargo fmt --all --check:通过。
  • 默认工具链 1.96:受影响 crate 的 clippy 通过。
  • affected-crates.mjs 选出的 13 个 crate 测试全部通过:29 个测试套件,共 1347 个测试。
  • 改动的 6 个 crate 注释规范通过;verify-platform-tests.mjs 52 个 crate 通过;CI 脚本测试 16 个全部通过。
  • 固定工具链后:仓库根目录和 shared/plugins/sdk/rust 里 rustc -V 都是 1.100.0(rustup show active-toolchain 显示由 rust-toolchain.toml 覆盖);CI 脚本测试 16 个通过;affected-crates.mjs --base origin/main 在 Linux 上选中 --workspace;cargo fmt --all --check 和 verify-docs.mjs 通过。

验证(CI)

运行 范围 结果
43681996752(本 PR,Draft) 13 个受影响 crate,只跑 Linux Linux、Rust Core gate 通过;主机矩阵按 Draft 规则跳过
43681995497(在本分支手动运行) 全部 52 个 crate,加 macOS 和 Windows Linux、macOS、Windows、Rust Core gate 全部通过
43683734473(本 PR,ready,固定 1.100.0 之后的 bcad439) 改了 rust-toolchain.toml,按规则选中全部 crate Select crates、Linux、Windows、macOS、Rust Core gate 全部通过
43683734532(本 PR,Plugin SDKs,bcad439) Node、Java、Rust SDK,契约与文档,SDK 端到端 全部通过;Rust SDK 的 cargo +1.87 步骤不受固定文件影响

手动运行时,macOS 和 Windows 第一次在真实主机上跑平台测试:

  • Windows(-p lithe-platform -p lithe-platform-tests):lithe-platform 15 个单元测试,lithe-platform-tests 库 2 个,tests/platform 10 个,全部通过。refactor(platform): 平台规则改为数据,平台专属测试移到 lithe-platform-tests #48 合入时没有在 Windows 上实测,这次补上了。
  • macOS(-p lithe-platform -p lithe-remote -p lithe-platform-tests --features lithe-remote/server):tests/platform 9 个,lithe-remote 单元测试 56 个、集成测试 7 组,全部通过。

- 仓库根目录新增 rust-toolchain.toml,本地和 CI 都使用 1.100.0。
- rust-core.yml、plugins-verify.yml 的 dtolnay/rust-toolchain 从 @stable
  改为 @1.100.0,与固定文件写同一个版本字符串;SDK 的 @1.87 和
  cargo +1.87 保持不变。
- rust-toolchain.toml 加入 affected-crates.mjs 的 EVERY_CRATE,改动它会
  选中全部 crate。
- CONTRIBUTING.md 新增“工具链 / Toolchain”一节,说明安装方式、额外目标
  和升级步骤;shared/plugins/README.md 的 SDK 检查说明不再写 stable。
@xiaoyumuxi xiaoyumuxi changed the title fix(rust-core): 修复 Rust 1.100 clippy 新增的 lint,让 Rust Core CI 通过 fix(rust-core): 修复 Rust 1.100 clippy 新增的 lint,并固定 Rust 1.100.0 工具链 Nov 15, 2026
@xiaoyumuxi
xiaoyumuxi merged commit 67a911a into main Nov 15, 2026
10 checks passed
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