From 2b92e4cbf3bfc4208534859053aa1e840f84e14b Mon Sep 17 00:00:00 2001 From: user Date: Fri, 28 Aug 2026 05:33:19 +0800 Subject: [PATCH] fix(cli): gate unix-only dispatch/daemon symbols Three dead_code/unused_imports warnings fire in CLI builds on Windows because the symbols' only production consumers live behind unix gates while their own definitions are unconditional: - dispatch/runner.rs: the std::time::Duration import is consumed only inside cfg(unix) code paths (the unix process-group wait and a unix-only test case), so gate the import with #[cfg(unix)]. - dispatch/runner.rs: arguments_match_action is called from the target_os = linux/macos service paths (both imply unix) and from the platform-agnostic unit tests, so gate it with #[cfg(any(unix, test))] to keep it available to tests on every platform. - daemon/service.rs: run_command is only called from macOS launchd and systemd service management paths, all of which are unix-only, so gate it with #[cfg(unix)]. All three changes are pure cfg attribute additions that mirror the real consumer surfaces: no behavior changes on any platform, no test removals, and no assertions weakened. Linux and macOS builds keep every symbol exactly as before. Test: cargo check --locked -p bitfun-cli (0 errors, 0 warnings on Windows) Test: cargo test --locked -p bitfun-cli dispatch::runner (7 passed, 0 failed) AI: AI-assisted change, lightly tested; the unix-side compilation is left to the repository CI platform matrix. --- src/apps/cli/src/daemon/service.rs | 1 + src/apps/cli/src/dispatch/runner.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/apps/cli/src/daemon/service.rs b/src/apps/cli/src/daemon/service.rs index 67591c330c..79a4a7dd28 100644 --- a/src/apps/cli/src/daemon/service.rs +++ b/src/apps/cli/src/daemon/service.rs @@ -85,6 +85,7 @@ fn render_launch_agent(executable: &Path) -> String { ) } +#[cfg(unix)] fn run_command(program: &str, args: &[&str]) -> Result { std::process::Command::new(program) .args(args) diff --git a/src/apps/cli/src/dispatch/runner.rs b/src/apps/cli/src/dispatch/runner.rs index 537783eef3..6248ea52b9 100644 --- a/src/apps/cli/src/dispatch/runner.rs +++ b/src/apps/cli/src/dispatch/runner.rs @@ -1,4 +1,5 @@ use std::process::{Command, Stdio}; +#[cfg(unix)] use std::time::Duration; use anyhow::{anyhow, bail, Context, Result}; @@ -334,6 +335,7 @@ fn process_matches_action(_pid: u32, _action: &str, _job_id: &str) -> bool { false } +#[cfg(any(unix, test))] fn arguments_match_action(args: &[String], action: &str, job_id: &str) -> bool { args.windows(4).any(|window| { window[0] == "dispatch"