From 26fdd149e1bfb2cbb5d795269c7ba0fd76fed149 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Fri, 1 Mar 2024 23:22:22 -0500 Subject: [PATCH] Fix Clippy warnings in `fs` (#8696) This PR fixes various Clippy warnings in the `fs` crate. Release Notes: - N/A --- crates/fs/src/fs.rs | 22 +++++++++++----------- crates/fs/src/repository.rs | 26 +++++++++++++------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 87264d26e2..968ab68389 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -376,10 +376,10 @@ impl Fs for RealFs { } fn open_repo(&self, dotgit_path: &Path) -> Option>> { - LibGitRepository::open(&dotgit_path) + LibGitRepository::open(dotgit_path) .log_err() - .and_then::>, _>(|libgit_repository| { - Some(Arc::new(Mutex::new(libgit_repository))) + .map::>, _>(|libgit_repository| { + Arc::new(Mutex::new(libgit_repository)) }) } @@ -474,15 +474,15 @@ enum FakeFsEntry { #[cfg(any(test, feature = "test-support"))] impl FakeFsState { - fn read_path<'a>(&'a self, target: &Path) -> Result>> { + fn read_path(&self, target: &Path) -> Result>> { Ok(self .try_read_path(target, true) .ok_or_else(|| anyhow!("path does not exist: {}", target.display()))? .0) } - fn try_read_path<'a>( - &'a self, + fn try_read_path( + &self, target: &Path, follow_symlink: bool, ) -> Option<(Arc>, PathBuf)> { @@ -625,7 +625,7 @@ impl FakeFs { } }) .unwrap(); - state.emit_event(&[path]); + state.emit_event([path]); } fn write_file_internal(&self, path: impl AsRef, content: Vec) -> Result<()> { @@ -651,7 +651,7 @@ impl FakeFs { } Ok(()) })?; - state.emit_event(&[path]); + state.emit_event([path]); Ok(()) } @@ -785,7 +785,7 @@ impl FakeFs { state.worktree_statuses.extend( statuses .iter() - .map(|(path, content)| ((**path).into(), content.clone())), + .map(|(path, content)| ((**path).into(), *content)), ); }); self.state.lock().emit_event( @@ -805,7 +805,7 @@ impl FakeFs { state.worktree_statuses.extend( statuses .iter() - .map(|(path, content)| ((**path).into(), content.clone())), + .map(|(path, content)| ((**path).into(), *content)), ); }); } @@ -990,7 +990,7 @@ impl Fs for FakeFs { } Ok(()) })?; - state.emit_event(&[path]); + state.emit_event([path]); Ok(()) } diff --git a/crates/fs/src/repository.rs b/crates/fs/src/repository.rs index 66dd0503cf..ae69025f0a 100644 --- a/crates/fs/src/repository.rs +++ b/crates/fs/src/repository.rs @@ -363,19 +363,19 @@ impl GitFileStatus { ) -> Option { if prefer_other { return other; - } else { - match (this, other) { - (Some(GitFileStatus::Conflict), _) | (_, Some(GitFileStatus::Conflict)) => { - Some(GitFileStatus::Conflict) - } - (Some(GitFileStatus::Modified), _) | (_, Some(GitFileStatus::Modified)) => { - Some(GitFileStatus::Modified) - } - (Some(GitFileStatus::Added), _) | (_, Some(GitFileStatus::Added)) => { - Some(GitFileStatus::Added) - } - _ => None, + } + + match (this, other) { + (Some(GitFileStatus::Conflict), _) | (_, Some(GitFileStatus::Conflict)) => { + Some(GitFileStatus::Conflict) } + (Some(GitFileStatus::Modified), _) | (_, Some(GitFileStatus::Modified)) => { + Some(GitFileStatus::Modified) + } + (Some(GitFileStatus::Added), _) | (_, Some(GitFileStatus::Added)) => { + Some(GitFileStatus::Added) + } + _ => None, } } } @@ -428,7 +428,7 @@ pub struct RepoPathDescendants<'a>(pub &'a Path); impl<'a> MapSeekTarget for RepoPathDescendants<'a> { fn cmp_cursor(&self, key: &RepoPath) -> Ordering { - if key.starts_with(&self.0) { + if key.starts_with(self.0) { Ordering::Greater } else { self.0.cmp(key)