From 0bbe345ad637305d84015dafe51a70fe623f72c9 Mon Sep 17 00:00:00 2001 From: Weidong Cui Date: Mon, 6 Apr 2026 21:19:41 -0700 Subject: [PATCH] Add trace_fs feature gate for conditional DebugLogProvider bound Add trace_fs feature to litebox Cargo.toml. When enabled (without lock_tracing), RawSyncPrimitivesProvider additionally requires DebugLogProvider, allowing filesystem tracing code to log through the platform's debug output. --- litebox/Cargo.toml | 1 + litebox/src/sync/mod.rs | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/litebox/Cargo.toml b/litebox/Cargo.toml index 9a8b2e401..8d3e59eed 100644 --- a/litebox/Cargo.toml +++ b/litebox/Cargo.toml @@ -31,6 +31,7 @@ windows-sys = { version = "0.60.2", features = [ [features] lock_tracing = ["dep:arrayvec", "spin/mutex"] +trace_fs = [] panic_on_unclosed_fd_drop = [] enforce_singleton_litebox_instance = [] diff --git a/litebox/src/sync/mod.rs b/litebox/src/sync/mod.rs index 0778d6d15..54ba89945 100644 --- a/litebox/src/sync/mod.rs +++ b/litebox/src/sync/mod.rs @@ -29,15 +29,33 @@ pub use rwlock::{ MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, RwLockWriteGuard, }; -#[cfg(not(feature = "lock_tracing"))] +#[cfg(not(any(feature = "lock_tracing", feature = "trace_fs")))] /// A convenience name for specific requirements from the platform pub trait RawSyncPrimitivesProvider: platform::RawMutexProvider + Sync + 'static {} -#[cfg(not(feature = "lock_tracing"))] +#[cfg(not(any(feature = "lock_tracing", feature = "trace_fs")))] impl RawSyncPrimitivesProvider for Platform where Platform: platform::RawMutexProvider + Sync + 'static { } +// When `trace_fs` is enabled, filesystem tracing code logs through +// `DebugLogProvider`. Since the platform type is threaded through +// `RawSyncPrimitivesProvider` in fs-related contexts, the bound is added here +// so it is available wherever the platform is used. `lock_tracing` already +// includes `DebugLogProvider`, so this branch only applies when `trace_fs` is +// enabled without `lock_tracing`. +#[cfg(all(feature = "trace_fs", not(feature = "lock_tracing")))] +/// A convenience name for specific requirements from the platform +pub trait RawSyncPrimitivesProvider: + platform::RawMutexProvider + platform::DebugLogProvider + Sync + 'static +{ +} +#[cfg(all(feature = "trace_fs", not(feature = "lock_tracing")))] +impl RawSyncPrimitivesProvider for Platform where + Platform: platform::RawMutexProvider + platform::DebugLogProvider + Sync + 'static +{ +} + #[cfg(feature = "lock_tracing")] /// A convenience name for specific requirements from the platform pub trait RawSyncPrimitivesProvider: