From 150243e0b66af9ed48d5c4ac4abc9975fb20a131 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Wed, 11 Nov 2026 22:35:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20listing()=20=E4=B8=8E=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E8=B0=83=E7=94=A8=E7=82=B9=E5=90=8C=20gate=20#[cfg(wi?= =?UTF-8?q?ndows)]=EF=BC=8C=E6=B6=88=E6=8E=89=20Linux=20=E4=B8=8A=E7=9A=84?= =?UTF-8?q?=20dead=5Fcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 的 clippy (ubuntu-latest) 退出码 101 的唯一首因: error: function `listing` is never used --> crates/core/tests/adopt/surface_cases.rs:147:4 note: `-D dead-code` implied by `-D warnings` `listing()` 的 4 处调用(43/65/69/73 行)全部落在 `#[cfg(windows)]` 的 `a_junction_on_the_instances_dir_must_not_write_into_the_game_root` 里,helper 本身没 gate ⇒ Linux 上调用点整块编掉,helper 变死代码;Windows 上跑不出来(本地一直绿的原因)。 最小改法:只给 helper 加 `#[cfg(windows)]`,与调用点对齐(同仓既有写法见 tests/launch/watchdog_cases.rs 的 `chatty_lines()`)。不删用例、不改断言、不给整个 mod 加 cfg、不用 #[allow(dead_code)] 静音。 验证:Linux 容器 ull-linux-check:bookworm 上 cargo clippy --workspace --all-targets -- -D warnings;Windows 上 cargo clippy -p unlucky-core --all-targets -- -D warnings 且 adopt 测试清单仍有那条 junction 用例(4 处调用仍在编)。 --- crates/core/tests/adopt/surface_cases.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/core/tests/adopt/surface_cases.rs b/crates/core/tests/adopt/surface_cases.rs index 0e14eac..15dd7dd 100644 --- a/crates/core/tests/adopt/surface_cases.rs +++ b/crates/core/tests/adopt/surface_cases.rs @@ -144,6 +144,11 @@ fn a_truly_missing_versions_dir_stays_empty() { } /// 目录里直接子项的名字(排序后,用于「有没有新增」的判据)。 +/// +/// cfg 必须与唯一的调用点(`a_junction_on_the_instances_dir_must_not_write_into_the_game_root`) +/// 对齐:那条用例是 `#[cfg(windows)]`(目录联接夹具只在 Windows 上建得出来),Linux 上调用点 +/// 整块编掉,未 gate 的 helper 就成了 `dead_code`(CI 的 `-D warnings` 会让 clippy 退出 101)。 +#[cfg(windows)] fn listing(dir: &std::path::Path) -> Vec { let mut names: Vec = std::fs::read_dir(dir) .expect("读目录")