Fix Clippy warnings in fs (#8696)

This PR fixes various Clippy warnings in the `fs` crate.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-01 23:22:22 -05:00 committed by GitHub
parent 486f0ae454
commit 26fdd149e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 24 deletions

View File

@ -376,10 +376,10 @@ impl Fs for RealFs {
} }
fn open_repo(&self, dotgit_path: &Path) -> Option<Arc<Mutex<dyn GitRepository>>> { fn open_repo(&self, dotgit_path: &Path) -> Option<Arc<Mutex<dyn GitRepository>>> {
LibGitRepository::open(&dotgit_path) LibGitRepository::open(dotgit_path)
.log_err() .log_err()
.and_then::<Arc<Mutex<dyn GitRepository>>, _>(|libgit_repository| { .map::<Arc<Mutex<dyn GitRepository>>, _>(|libgit_repository| {
Some(Arc::new(Mutex::new(libgit_repository))) Arc::new(Mutex::new(libgit_repository))
}) })
} }
@ -474,15 +474,15 @@ enum FakeFsEntry {
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
impl FakeFsState { impl FakeFsState {
fn read_path<'a>(&'a self, target: &Path) -> Result<Arc<Mutex<FakeFsEntry>>> { fn read_path(&self, target: &Path) -> Result<Arc<Mutex<FakeFsEntry>>> {
Ok(self Ok(self
.try_read_path(target, true) .try_read_path(target, true)
.ok_or_else(|| anyhow!("path does not exist: {}", target.display()))? .ok_or_else(|| anyhow!("path does not exist: {}", target.display()))?
.0) .0)
} }
fn try_read_path<'a>( fn try_read_path(
&'a self, &self,
target: &Path, target: &Path,
follow_symlink: bool, follow_symlink: bool,
) -> Option<(Arc<Mutex<FakeFsEntry>>, PathBuf)> { ) -> Option<(Arc<Mutex<FakeFsEntry>>, PathBuf)> {
@ -625,7 +625,7 @@ impl FakeFs {
} }
}) })
.unwrap(); .unwrap();
state.emit_event(&[path]); state.emit_event([path]);
} }
fn write_file_internal(&self, path: impl AsRef<Path>, content: Vec<u8>) -> Result<()> { fn write_file_internal(&self, path: impl AsRef<Path>, content: Vec<u8>) -> Result<()> {
@ -651,7 +651,7 @@ impl FakeFs {
} }
Ok(()) Ok(())
})?; })?;
state.emit_event(&[path]); state.emit_event([path]);
Ok(()) Ok(())
} }
@ -785,7 +785,7 @@ impl FakeFs {
state.worktree_statuses.extend( state.worktree_statuses.extend(
statuses statuses
.iter() .iter()
.map(|(path, content)| ((**path).into(), content.clone())), .map(|(path, content)| ((**path).into(), *content)),
); );
}); });
self.state.lock().emit_event( self.state.lock().emit_event(
@ -805,7 +805,7 @@ impl FakeFs {
state.worktree_statuses.extend( state.worktree_statuses.extend(
statuses statuses
.iter() .iter()
.map(|(path, content)| ((**path).into(), content.clone())), .map(|(path, content)| ((**path).into(), *content)),
); );
}); });
} }
@ -990,7 +990,7 @@ impl Fs for FakeFs {
} }
Ok(()) Ok(())
})?; })?;
state.emit_event(&[path]); state.emit_event([path]);
Ok(()) Ok(())
} }

View File

@ -363,19 +363,19 @@ impl GitFileStatus {
) -> Option<GitFileStatus> { ) -> Option<GitFileStatus> {
if prefer_other { if prefer_other {
return other; return other;
} else { }
match (this, other) {
(Some(GitFileStatus::Conflict), _) | (_, Some(GitFileStatus::Conflict)) => { match (this, other) {
Some(GitFileStatus::Conflict) (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,
} }
(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<RepoPath> for RepoPathDescendants<'a> { impl<'a> MapSeekTarget<RepoPath> for RepoPathDescendants<'a> {
fn cmp_cursor(&self, key: &RepoPath) -> Ordering { fn cmp_cursor(&self, key: &RepoPath) -> Ordering {
if key.starts_with(&self.0) { if key.starts_with(self.0) {
Ordering::Greater Ordering::Greater
} else { } else {
self.0.cmp(key) self.0.cmp(key)