Skip to content

test: cfg-gate unix-only helpers in issue1794 test (Refs #3772) - #3775

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3772-issue1794-windows-dead-code
Nov 16, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3772-issue1794-windows-dead-code

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因

tests/issue1794_user_group_completion.rs 的四个 test fn 与 helper expected_candidates 皆 #[cfg(unix)],Windows 靶上整文件被 cfg 掉后,顶层 use std::path::PathBuf、use std::process::Command 与 fn rubash 失去全部引用,RUSTFLAGS="-D warnings" 下变硬错(unused import + dead code)。Command 之所以也要 gate:它只被 rubash 引用,rubash 一 gate 它就成了下一个 unused import。

修复

为两处 import 与 rubash helper 加 #[cfg(unix)](共 3 行)。unix 靶上属性为 no-op,无行为变化。

验证

  • Fail-first(X299-2607,基底 70e962b):RUSTFLAGS="-D warnings" cargo check --locked --test issue1794_user_group_completion 退出 101,恰为 issue 所述两错。
  • 修后 Windows 腿(X299):同命令退出 0,无 warning;touch 强制重检亦 0。
  • 修后 Linux 腿(VM):同命令退出 0,无 warning。
  • rustfmt --check 干净。详见车道 REPORT(工作区根,未入仓)。

本 PR 删除了什么

无。仅为 3 项加 #[cfg(unix)] 属性;无代码、无测试删除。

UNVERIFIED-BY-CAPTAIN

Root cause: all four test fns and `expected_candidates` in
tests/issue1794_user_group_completion.rs are #[cfg(unix)], so on a
Windows target the top-level `use std::path::PathBuf`,
`use std::process::Command` and `fn rubash` lose all uses and
`RUSTFLAGS="-D warnings"` turns the unused-import / dead-code lints
into hard errors. (Command becomes unused once `rubash` itself is
gated: it is only referenced from that helper.)

Fix: add #[cfg(unix)] to both imports and the `rubash` helper, so the
file is warning-free on all targets. No behaviour change on any
target; on unix the attributes are no-ops.

本 PR 删除了什么: 无(仅为 3 项加 #[cfg(unix)] 属性;无代码、无测试删除)。

UNVERIFIED-BY-CAPTAIN
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