From 27610e45bb850a90cc0ae725679049d3c991cc4f Mon Sep 17 00:00:00 2001 From: Michael Cuevas Date: Fri, 31 Jan 2025 19:25:36 -0800 Subject: [PATCH] fix unused import warning on Windows Summary: # This diff Makes some imports unix-only so that we can avoid some warnings during build time on Windows. # Context in_the_context Reviewed By: muirdm Differential Revision: D68838999 fbshipit-source-id: 620d5a0967ce681f945594f4b8384e1a2bb4cee9 --- eden/scm/lib/util/src/path.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/eden/scm/lib/util/src/path.rs b/eden/scm/lib/util/src/path.rs index bf8eb9cb9f31c..dbfab3fbe4dc6 100644 --- a/eden/scm/lib/util/src/path.rs +++ b/eden/scm/lib/util/src/path.rs @@ -8,7 +8,6 @@ //! Path-related utilities. use std::borrow::Cow; -use std::collections::HashSet; use std::env; use std::ffi::OsStr; use std::fs; @@ -22,8 +21,6 @@ use std::path::Component; use std::path::Path; use std::path::PathBuf; -use anyhow::bail; -use anyhow::Context; use fn_error_context::context; use crate::errors::IOContext; @@ -357,6 +354,8 @@ fn add_stat_context>( ) -> anyhow::Result { use std::os::unix::fs::MetadataExt; + use anyhow::Context; + let res = res.map_err(Into::into); if let Some(path) = path { @@ -381,6 +380,10 @@ fn add_stat_context>( /// Propagates unexpected errors like permission errors. #[cfg(unix)] fn resolve_symlinks(path: &Path) -> anyhow::Result { + use std::collections::HashSet; + + use anyhow::bail; + use anyhow::Context; fn inner(path: PathBuf, seen: &mut HashSet) -> anyhow::Result { if seen.contains(&path) { bail!("symlink cycle containing {:?}", path); @@ -420,6 +423,7 @@ fn resolve_symlinks(path: &Path) -> anyhow::Result { #[context("creating dir {:?} with mode 0o{:o}", path, mode)] fn create_dir_with_mode(path: &Path, mode: u32) -> anyhow::Result<()> { use anyhow::anyhow; + use anyhow::Context; let path = resolve_symlinks(path)?;