Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,23 @@ jobs:
with:
cache-on-failure: true

# The `clippy` job runs on Linux only, so it compiles the `cfg(unix)` side
# of every platform conditional and never sees the `cfg(windows)` side.
# Windows-gated code was therefore outside the warnings-as-errors gate
# entirely — not merely under-linted — so a lint could land there and no
# check in the set could fail. This mirrors the two invocations the Linux
# `clippy` job runs; the second is separate because the `e2e` target sets
# `test = false`, so `--all-targets` does not build it.
#
# Runs before the build so a lint failure costs seconds rather than the
# full build/test/package cycle, matching why this job `needs: clippy`.
- name: Clippy (Windows targets)
if: needs.changes.outputs.heavy == 'true'
shell: pwsh
run: |
cargo clippy --locked --workspace --all-targets -- -D warnings
cargo clippy --locked -p e2e-cucumber --test e2e -- -D warnings

- name: Build
if: needs.changes.outputs.heavy == 'true'
shell: pwsh
Expand Down
4 changes: 4 additions & 0 deletions apps/rocm/src/dash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,10 @@ const fn should_spawn_daemon(args: &ResolvedArgs) -> bool {
/// listening, so `rocm dash` works without a separate `rocm daemon` terminal.
/// Returns the task handle + socket to clean up on exit, or `None` when an
/// existing daemon was found (we connect to it instead).
// One function with `#[cfg]` blocks inside, not a cfg-split pair: the unix
// body awaits, the Windows body does not. Callers `.await` this either way,
// so dropping `async` off unix would not compile.
#[allow(clippy::unused_async)]
async fn maybe_spawn_embedded_daemon(
connect: &str,
config: &RocmCliConfig,
Expand Down
8 changes: 8 additions & 0 deletions apps/rocm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,10 @@ fn reset_sigpipe() {
}

#[cfg(not(unix))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn reset_sigpipe() {}

/// Run `f` with SIGPIPE temporarily ignored, restoring the previous
Expand Down Expand Up @@ -3488,6 +3492,10 @@ impl PrivilegeEscalation {
///
/// Only ever called on the production path; every plan builder takes the
/// escalation as a parameter so both branches are testable on any host.
// `running_as_root()` is a non-const syscall on unix and a trivial
// constant off it, so Clippy sees this as const-able only on Windows.
// Making it `const` would stop the unix build compiling.
#[allow(clippy::missing_const_for_fn)]
fn detect() -> Self {
if rocm_core::openmpi::running_as_root() {
Self::AlreadyRoot
Expand Down
4 changes: 4 additions & 0 deletions apps/rocm/src/remote/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ fn control_socket_path() -> Option<String> {
/// warnings at best. Returning `None` keeps the argument builder honest instead
/// of emitting options the platform ignores.
#[cfg(not(unix))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn control_socket_path() -> Option<String> {
None
}
Expand Down
8 changes: 8 additions & 0 deletions apps/rocmd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2824,6 +2824,10 @@ fn descendant_pids_for_roots(root_pids: &[u32]) -> Result<Vec<u32>> {
}

#[cfg(not(unix))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn descendant_pids_for_roots(_root_pids: &[u32]) -> Result<Vec<u32>> {
Ok(Vec::new())
}
Expand Down Expand Up @@ -2970,6 +2974,10 @@ fn force_terminate_remaining_processes(pids: &[u32]) -> Result<Vec<u32>> {
}

#[cfg(not(unix))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn force_terminate_remaining_processes(_pids: &[u32]) -> Result<Vec<u32>> {
Ok(Vec::new())
}
Expand Down
4 changes: 4 additions & 0 deletions crates/rocm-core/src/disk_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ fn mount_owns_path(path: &Path, mount_point: &Path) -> bool {
}

#[cfg(not(unix))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn mount_owns_path(_path: &Path, _mount_point: &Path) -> bool {
true
}
Expand Down
4 changes: 4 additions & 0 deletions crates/rocm-core/src/examine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,10 @@ fn filesystem_size(path: &str) -> Option<(u64, u64)> {
}

#[cfg(not(target_os = "linux"))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn filesystem_size(_path: &str) -> Option<(u64, u64)> {
None
}
Expand Down
29 changes: 18 additions & 11 deletions crates/rocm-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ pub fn spawn_hidden_console_with_log(
current_process,
source,
current_process,
&mut stdout_handle,
&raw mut stdout_handle,
0,
1,
DUPLICATE_SAME_ACCESS,
Expand All @@ -1241,7 +1241,7 @@ pub fn spawn_hidden_console_with_log(
current_process,
source,
current_process,
&mut stderr_handle,
&raw mut stderr_handle,
0,
1,
DUPLICATE_SAME_ACCESS,
Expand Down Expand Up @@ -1291,7 +1291,7 @@ pub fn wait_for_process_exit(pid: u32) -> Result<u32> {
unsafe {
WaitForSingleObject(handle, INFINITE);
let mut exit_code = 0;
if GetExitCodeProcess(handle, &mut exit_code) == 0 {
if GetExitCodeProcess(handle, &raw mut exit_code) == 0 {
CloseHandle(handle);
bail!(
"failed to read process {pid} exit code: {}",
Expand Down Expand Up @@ -1474,7 +1474,7 @@ pub fn process_is_running(pid: u32) -> bool {
return false;
}
let mut exit_code = 0;
let ok = unsafe { GetExitCodeProcess(handle, &mut exit_code) != 0 };
let ok = unsafe { GetExitCodeProcess(handle, &raw mut exit_code) != 0 };
unsafe {
CloseHandle(handle);
}
Expand Down Expand Up @@ -1570,6 +1570,10 @@ pub fn detach_command_session(command: &mut Command) {
}

#[cfg(not(unix))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
pub fn detach_command_session(_command: &mut Command) {}

#[cfg(windows)]
Expand Down Expand Up @@ -1613,12 +1617,12 @@ fn spawn_windows_no_inherit(
command_line.as_mut_ptr(),
null(),
null(),
if std_handles.is_some() { 1 } else { 0 },
i32::from(std_handles.is_some()),
creation_flags,
environment.as_mut_ptr().cast(),
null(),
&startup_info,
&mut process_info,
&raw const startup_info,
&raw mut process_info,
)
};
if created == 0 {
Expand Down Expand Up @@ -2058,12 +2062,12 @@ struct WindowsDisplayAdapter {

impl WindowsExamineInventory {
#[cfg(windows)]
fn is_empty(&self) -> bool {
const fn is_empty(&self) -> bool {
self.cpu_model.is_none() && self.system_ram_gib.is_none() && self.displays.is_empty()
}

#[cfg(windows)]
fn merge_missing_from(&mut self, mut other: WindowsExamineInventory) {
fn merge_missing_from(&mut self, mut other: Self) {
if self.cpu_model.is_none() {
self.cpu_model = other.cpu_model.take();
}
Expand Down Expand Up @@ -3453,8 +3457,7 @@ fn append_windows_probe_diagnostics(
result
.program
.as_ref()
.map(|path| path.display().to_string())
.unwrap_or_else(|| program.to_owned()),
.map_or_else(|| program.to_owned(), |path| path.display().to_string()),
args.join(" ")
);
if let Some(error) = result.error.as_deref() {
Expand Down Expand Up @@ -5205,6 +5208,10 @@ fn probe_usable_amd_gpu_indices() -> Option<Vec<u32>> {
}

#[cfg(not(target_os = "linux"))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn probe_usable_amd_gpu_indices() -> Option<Vec<u32>> {
None
}
Expand Down
8 changes: 8 additions & 0 deletions crates/rocm-core/src/proc_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ pub fn process_start_ticks(pid: u32) -> Option<u64> {

#[cfg(not(target_os = "linux"))]
#[must_use]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
pub fn process_start_ticks(_pid: u32) -> Option<u64> {
None
}
Expand All @@ -332,6 +336,10 @@ fn process_has_exited(pid: u32) -> bool {
}

#[cfg(not(target_os = "linux"))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn process_has_exited(_pid: u32) -> bool {
false
}
Expand Down
6 changes: 6 additions & 0 deletions crates/rocm-core/src/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ fn find_binary_in(dir: &Path, name: &str) -> Option<PathBuf> {
None
}

// Off unix the body is a no-op, so Clippy's nursery `missing_const_for_fn`
// fires there — but this is one function with `#[cfg]` blocks inside, not a
// cfg-split pair, and the unix arm calls `set_permissions`, which is not
// const. Making it `const` to satisfy the Windows lint would stop the unix
// build compiling.
#[allow(clippy::missing_const_for_fn)]
fn make_executable(path: &Path) -> Result<()> {
#[cfg(unix)]
{
Expand Down
3 changes: 3 additions & 0 deletions crates/rocm-dash-daemon/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ async fn run_unix(path: PathBuf, opts: RunnerOptions) -> anyhow::Result<()> {
}

#[cfg(windows)]
// Mirrors the signature of the `cfg(unix)` arm, which callers `.await`;
// dropping `async` here would not compile on Windows.
#[allow(clippy::unused_async)]
async fn run_unix(_path: PathBuf, _opts: RunnerOptions) -> anyhow::Result<()> {
Err(anyhow!(
"rocm-dash daemon requires Unix domain sockets; not supported on Windows yet"
Expand Down
6 changes: 4 additions & 2 deletions crates/rocm-dash-tui/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ async fn connect_and_run(connect: &str, tx: UnboundedSender<ClientMsg>) -> anyho
}

#[cfg(windows)]
// Mirrors the signature of the `cfg(unix)` arm, which callers `.await`;
// dropping `async` here would not compile on Windows.
#[allow(clippy::unused_async)]
async fn connect_and_run(connect: &str, _tx: UnboundedSender<ClientMsg>) -> anyhow::Result<()> {
Err(anyhow!(
"rocm-dash TUI requires Unix domain sockets; not supported on Windows yet (connect={})",
connect
"rocm-dash TUI requires Unix domain sockets; not supported on Windows yet (connect={connect})"
))
}
4 changes: 4 additions & 0 deletions tests/e2e-cucumber/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ fn probe_amd_gpu_count() -> Option<usize> {
/// Off Linux the product's own probe returns `None` too, so the count is
/// unknown and every `@requires-multi-gpu` scenario resolves to skip.
#[cfg(not(target_os = "linux"))]
// Platform stub. The `cfg` sibling calls non-const code, so making only this
// arm `const` would give the two platforms different signatures and push
// `missing_const_for_fn` onto every caller in turn.
#[allow(clippy::missing_const_for_fn)]
fn probe_amd_gpu_count() -> Option<usize> {
None
}
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e-cucumber/tests/e2e/lifecycle_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ fn which_ok(name: &str) -> bool {
.arg("-Command")
.arg("exit 0")
.status()
.map(|s| s.success())
.unwrap_or(false)
.is_ok_and(|s| s.success())
}

/// Capture the current Windows user PATH (registry `HKCU\Environment\Path`).
Expand Down
Loading