From 16a04b53a20d042fb69bd125c03a373ef68f751a Mon Sep 17 00:00:00 2001 From: J Robert Ray Date: Mon, 13 Jan 2025 18:15:21 -0800 Subject: [PATCH] Switch from allowing dead code to cfg(unix) Signed-off-by: J Robert Ray --- crates/spfs/src/bootstrap.rs | 12 ++++-------- crates/spfs/src/repeating_timeout.rs | 3 +-- crates/spfs/src/resolve.rs | 15 +++++---------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/crates/spfs/src/bootstrap.rs b/crates/spfs/src/bootstrap.rs index 7a2bfdf23..3d769ec7e 100644 --- a/crates/spfs/src/bootstrap.rs +++ b/crates/spfs/src/bootstrap.rs @@ -18,8 +18,7 @@ mod bootstrap_test; /// Environment variable used to store the original value of HOME /// when launching through certain shells (tcsh). -// Allow: not used on Windows. -#[allow(dead_code)] +#[cfg(unix)] const SPFS_ORIGINAL_HOME: &str = "SPFS_ORIGINAL_HOME"; /// The environment variable used to store the message @@ -277,8 +276,7 @@ pub(crate) fn build_spfs_remove_durable_command( }) } -// Allow: not used on Windows. -#[allow(dead_code)] +#[cfg(unix)] pub(crate) fn build_spfs_remount_command(rt: &runtime::Runtime) -> Result { let exe = match which_spfs("enter") { None => return Err(Error::MissingBinary("spfs-enter")), @@ -300,8 +298,7 @@ pub(crate) fn build_spfs_remount_command(rt: &runtime::Runtime) -> Result Result { let exe = match which_spfs("enter") { None => return Err(Error::MissingBinary("spfs-enter")), @@ -323,8 +320,7 @@ pub(crate) fn build_spfs_exit_command(rt: &runtime::Runtime) -> Result }) } -// Allow: not used on Windows. -#[allow(dead_code)] +#[cfg(unix)] pub(crate) fn build_spfs_change_to_durable_command(rt: &runtime::Runtime) -> Result { let exe = match which_spfs("enter") { None => return Err(Error::MissingBinary("spfs-enter")), diff --git a/crates/spfs/src/repeating_timeout.rs b/crates/spfs/src/repeating_timeout.rs index 7c8b80935..f1a40f52e 100644 --- a/crates/spfs/src/repeating_timeout.rs +++ b/crates/spfs/src/repeating_timeout.rs @@ -33,9 +33,8 @@ pin_project! { #[derive(Debug, PartialEq, Eq)] pub struct Elapsed(()); +#[cfg(unix)] impl RepeatingTimeout { - // Allow: not used on Windows. - #[allow(dead_code)] pub(super) fn new(stream: S, duration: Duration) -> Self { let next = Instant::now() + duration; let deadline = tokio::time::sleep_until(next); diff --git a/crates/spfs/src/resolve.rs b/crates/spfs/src/resolve.rs index a511da339..623ec1c5c 100644 --- a/crates/spfs/src/resolve.rs +++ b/crates/spfs/src/resolve.rs @@ -33,8 +33,7 @@ pub struct RenderResult { /// /// The return value is defined only if the spfs-render output could be parsed /// successfully into a [`RenderResult`]. -// Allow: not used on Windows. -#[allow(dead_code)] +#[cfg(unix)] async fn render_via_subcommand( spec: tracking::EnvSpec, kept_runtime: bool, @@ -207,8 +206,7 @@ pub async fn compute_object_manifest( /// If `skip_runtime_save` is true, the runtime will not be saved, even if /// the `flattened_layers` property is modified. Only pass true here if the /// runtime is unconditionally saved shortly after calling this function. -// Allow: not used on Windows. -#[allow(dead_code)] +#[cfg(unix)] pub(crate) async fn resolve_overlay_dirs( runtime: &mut runtime::Runtime, repo: R, @@ -228,8 +226,7 @@ where impl ResolvedManifest { /// Iterate over all the "existing" manifests contained within this /// manifest. - // Allow: not used on Windows. - #[allow(dead_code)] + #[cfg(unix)] fn existing(self) -> impl Iterator { // Find all the `Existing` manifests in this recursive structure, // returning them in an order based on their original order, to @@ -249,8 +246,7 @@ where result.into_iter().map(|(_, m)| m) } - // Allow: not used on Windows. - #[allow(dead_code)] + #[cfg(unix)] fn manifest(&self) -> &graph::Manifest { match self { ResolvedManifest::Existing { manifest, .. } => manifest, @@ -362,8 +358,7 @@ where /// If `skip_runtime_save` is true, the runtime will not be saved, even if /// the `flattened_layers` property is modified. Only pass true here if the /// runtime is unconditionally saved shortly after calling this function. -// Allow: not used on Windows. -#[allow(dead_code)] +#[cfg(unix)] pub(crate) async fn resolve_and_render_overlay_dirs( runtime: &mut runtime::Runtime, skip_runtime_save: bool,