fix sleep_inhibitor lints under --all-features clippy

The `sleep_inhibitor` feature pulled in 20 pedantic/nightly lints that
CI (default features) never exercised. Narrow all `pub` items in the
module to `pub(crate)`/`pub(super)`, replace the `use
super::iokit_bindings::*` wildcard with explicit imports, use `&raw
mut` for FFI pointer borrows, drop the always-`Some` wrapping in
`DummySleepInhibitor::acquire`, and bring `crate::sleep_inhibitor`
into scope at the three call sites so they don't trip
`clippy::absolute_paths`.

Verified: `cargo +nightly-2026-04-14 clippy --workspace --all-targets
--all-features -- -D warnings` clean, `cargo nextest run --workspace
--all-features` 4563 tests passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-04-23 22:45:07 -04:00
parent 906868c30c
commit e65d9a92e2
No known key found for this signature in database
7 changed files with 32 additions and 24 deletions

View file

@ -21,6 +21,8 @@ use serde::Deserialize;
use crate::args::ExecArgs;
use crate::command_context::CommandContext;
#[cfg(feature = "sleep_inhibitor")]
use crate::sleep_inhibitor;
use crate::{server_client, user_config};
struct AuthenticatedFabroServerAdapter {
@ -277,7 +279,7 @@ pub(crate) async fn execute(mut args: ExecArgs, ctx: &CommandContext) -> AnyResu
let cli = &ctx.user_settings().cli;
#[cfg(feature = "sleep_inhibitor")]
let _sleep_guard = crate::sleep_inhibitor::guard(cli.exec.prevent_idle_sleep);
let _sleep_guard = sleep_inhibitor::guard(cli.exec.prevent_idle_sleep);
let provider_str = cli
.exec
.model

View file

@ -4,6 +4,8 @@ use fabro_util::terminal::Styles;
use crate::args::RunArgs;
use crate::command_context::CommandContext;
use crate::shared::print_json_pretty;
#[cfg(feature = "sleep_inhibitor")]
use crate::sleep_inhibitor;
pub(crate) async fn execute(mut args: RunArgs, base_ctx: &CommandContext) -> Result<()> {
let styles: &'static Styles = Box::leak(Box::new(Styles::detect_stderr()));
@ -25,7 +27,7 @@ pub(crate) async fn execute(mut args: RunArgs, base_ctx: &CommandContext) -> Res
}
#[cfg(feature = "sleep_inhibitor")]
let _sleep_guard = crate::sleep_inhibitor::guard(prevent_idle_sleep);
let _sleep_guard = sleep_inhibitor::guard(prevent_idle_sleep);
#[cfg(not(feature = "sleep_inhibitor"))]
let _ = prevent_idle_sleep;

View file

@ -4,6 +4,8 @@ use fabro_util::terminal::Styles;
use crate::args::{AttachArgs, RunCommands, RunWorkerArgs, StartArgs};
use crate::command_context::CommandContext;
use crate::shared::print_json_pretty;
#[cfg(feature = "sleep_inhibitor")]
use crate::sleep_inhibitor;
pub(crate) mod attach;
pub(crate) mod command;
@ -106,7 +108,7 @@ pub(crate) async fn dispatch(
#[cfg(feature = "sleep_inhibitor")]
let _sleep_guard = {
let ctx = base_ctx.with_target(&args.server)?;
crate::sleep_inhibitor::guard(ctx.user_settings().cli.exec.prevent_idle_sleep)
sleep_inhibitor::guard(ctx.user_settings().cli.exec.prevent_idle_sleep)
};
Box::pin(resume::resume_command(args, styles, base_ctx)).await
}

View file

@ -3,9 +3,9 @@ use tracing::debug;
pub(crate) struct DummySleepInhibitor;
impl DummySleepInhibitor {
pub(crate) fn acquire() -> Option<Self> {
pub(crate) fn acquire() -> Self {
debug!("Sleep inhibitor: using dummy backend (no-op)");
Some(DummySleepInhibitor)
Self
}
}

View file

@ -4,37 +4,37 @@
reason = "FFI bindings preserve IOKit naming and include symbols referenced only on macOS."
)]
use core_foundation::string::CFString;
use core_foundation::string::{CFString, CFStringRef};
// IOKit power management assertion types
pub type IOPMAssertionID = u32;
pub const kIOPMAssertionIDInvalid: IOPMAssertionID = 0;
pub(super) type IOPMAssertionID = u32;
pub(super) const kIOPMAssertionIDInvalid: IOPMAssertionID = 0;
// IOReturn type
pub type IOReturn = i32;
pub const kIOReturnSuccess: IOReturn = 0;
pub(super) type IOReturn = i32;
pub(super) const kIOReturnSuccess: IOReturn = 0;
#[link(name = "IOKit", kind = "framework")]
extern "C" {
pub fn IOPMAssertionCreateWithName(
assertion_type: core_foundation::string::CFStringRef,
pub(super) fn IOPMAssertionCreateWithName(
assertion_type: CFStringRef,
assertion_level: u32,
reason_for_activity: core_foundation::string::CFStringRef,
reason_for_activity: CFStringRef,
assertion_id: *mut IOPMAssertionID,
) -> IOReturn;
pub fn IOPMAssertionRelease(assertion_id: IOPMAssertionID) -> IOReturn;
pub(super) fn IOPMAssertionRelease(assertion_id: IOPMAssertionID) -> IOReturn;
}
// Assertion level
pub const kIOPMAssertionLevelOn: u32 = 255;
pub(super) const kIOPMAssertionLevelOn: u32 = 255;
/// Create the CFString for "PreventUserIdleSystemSleep".
pub fn prevent_idle_sleep_type() -> CFString {
pub(super) fn prevent_idle_sleep_type() -> CFString {
CFString::new("PreventUserIdleSystemSleep")
}
/// Create a CFString reason.
pub fn assertion_reason() -> CFString {
pub(super) fn assertion_reason() -> CFString {
CFString::new("Fabro workflow running")
}

View file

@ -6,7 +6,10 @@
use core_foundation::base::TCFType;
use tracing::{debug, warn};
use super::iokit_bindings::*;
use super::iokit_bindings::{
IOPMAssertionCreateWithName, IOPMAssertionID, IOPMAssertionRelease, assertion_reason,
kIOPMAssertionIDInvalid, kIOPMAssertionLevelOn, kIOReturnSuccess, prevent_idle_sleep_type,
};
pub(crate) struct MacOSSleepInhibitor {
assertion_id: IOPMAssertionID,
@ -23,7 +26,7 @@ impl MacOSSleepInhibitor {
assertion_type.as_concrete_TypeRef(),
kIOPMAssertionLevelOn,
reason.as_concrete_TypeRef(),
&mut assertion_id,
&raw mut assertion_id,
)
};

View file

@ -16,7 +16,7 @@ mod dummy;
use tracing::debug;
/// RAII guard that prevents idle system sleep while held.
pub struct SleepInhibitorGuard {
pub(crate) struct SleepInhibitorGuard {
_inner: InnerGuard,
}
@ -39,7 +39,7 @@ enum InnerGuard {
/// If `enabled` is `true`, attempts to acquire a platform-specific sleep
/// inhibitor. Falls back to a dummy (no-op) backend if the platform backend
/// is unavailable.
pub fn guard(enabled: bool) -> Option<SleepInhibitorGuard> {
pub(crate) fn guard(enabled: bool) -> Option<SleepInhibitorGuard> {
if !enabled {
debug!("Sleep inhibitor: disabled by configuration");
return None;
@ -63,9 +63,8 @@ pub fn guard(enabled: bool) -> Option<SleepInhibitorGuard> {
}
}
// Fallback to dummy
dummy::DummySleepInhibitor::acquire().map(|inner| SleepInhibitorGuard {
_inner: InnerGuard::Dummy(inner),
Some(SleepInhibitorGuard {
_inner: InnerGuard::Dummy(dummy::DummySleepInhibitor::acquire()),
})
}