From c82e39d0eb7346dc6a5a2d5b7994aaee79e43478 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Sat, 7 Nov 2026 09:19:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20Windows=20=E4=B8=8A=20clippy=20?= =?UTF-8?q?=E6=8A=A5=20discover.rs=20=E4=B8=A4=E4=B8=AA=20cfg(unix)=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=AF=BC=E5=85=A5=E6=9C=AA=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 这两个 Termux 扫描用例挂着 `#[cfg(unix)]`,但它们的 `use`(`standard_roots_in`、 `platform::paths::MapEnv`)写在 mod tests 顶部没跟着 gate: - Termux/Linux 上 cfg(unix) 成立 → 有用例 → 导入有使用者 → clippy 干净(作者本机 475 测试 通过是真的); - Windows 上那两个用例不编译 → 导入无使用者 → `-D warnings` 直接判错 (`unused import` ×2,`could not compile unlucky-core (lib test)`)。 把两个 `use` 同样 gate 成 `#[cfg(unix)]`。代价是这两个用例在 Windows 上不编译不执行, 覆盖由 Linux CI 承担(它们断言的本来就是 Unix 路径)。 --- crates/core/src/game/java/discover.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/core/src/game/java/discover.rs b/crates/core/src/game/java/discover.rs index 7cc2700..bfd9d01 100644 --- a/crates/core/src/game/java/discover.rs +++ b/crates/core/src/game/java/discover.rs @@ -225,8 +225,13 @@ pub fn path_key(path: &Path) -> String { #[cfg(test)] mod tests { - use super::{dedupe, parse_java_home, path_key, standard_roots, standard_roots_in}; + use super::{dedupe, parse_java_home, path_key, standard_roots}; use crate::game::java::probe::{JavaOrigin, JavaRuntime}; + // 这两个只有 Termux 扫描的两个测试用,而那两个测试是 `cfg(unix)`——导入必须同样 gate, + // 否则 Windows 上不编译测试、导入就成了未使用(`-D warnings` 直接判错)。 + #[cfg(unix)] + use super::standard_roots_in; + #[cfg(unix)] use crate::platform::paths::MapEnv; fn runtime(path: &str, origin: JavaOrigin) -> JavaRuntime {