From 21f5bf8b15baba42b1c1b1cbaacd74773430fe2b Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Tue, 9 Aug 2022 21:05:38 -0700 Subject: [PATCH] cleanup: fix some things reported by clippy 1.63 --- lib/src/conflicts.rs | 2 +- lib/src/revset.rs | 7 +------ lib/src/working_copy.rs | 4 ++-- lib/src/workspace.rs | 4 ++-- lib/tests/test_merge_trees.rs | 2 +- src/commands.rs | 4 ++-- 6 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index 28310d537..617a07b7e 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -179,7 +179,7 @@ pub fn materialize_conflict( } let min_diff_index = diffs .iter() - .position_min_by_key(|diff| diff_size(*diff)) + .position_min_by_key(|diff| diff_size(diff)) .unwrap(); output.write_all(CONFLICT_MINUS_LINE)?; output.write_all(CONFLICT_PLUS_LINE)?; diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 131b7325f..87c152d8e 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -992,12 +992,7 @@ impl<'revset, 'repo> Iterator for FilterRevsetIterator<'revset, 'repo> { type Item = IndexEntry<'repo>; fn next(&mut self) -> Option { - for entry in &mut self.iter { - if (self.predicate)(&entry) { - return Some(entry); - } - } - None + self.iter.find(self.predicate) } } diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index 53c561d44..7821b6c58 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -836,7 +836,7 @@ impl TreeState { panic!("unexpected tree entry in diff at {:?}", path); } }; - self.file_states.insert(path.clone(), file_state); + self.file_states.insert(path, file_state); stats.added_files += 1; } Diff::Modified( @@ -875,7 +875,7 @@ impl TreeState { } }; - self.file_states.insert(path.clone(), file_state); + self.file_states.insert(path, file_state); stats.updated_files += 1; } } diff --git a/lib/src/workspace.rs b/lib/src/workspace.rs index e5a5425ee..47c80579b 100644 --- a/lib/src/workspace.rs +++ b/lib/src/workspace.rs @@ -27,13 +27,13 @@ use crate::repo::{ReadonlyRepo, RepoLoader}; use crate::settings::UserSettings; use crate::working_copy::WorkingCopy; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum WorkspaceInitError { #[error("The destination repo ({0}) already exists")] DestinationExists(PathBuf), } -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum WorkspaceLoadError { #[error("The repo appears to no longer be at {0}")] RepoDoesNotExist(PathBuf), diff --git a/lib/tests/test_merge_trees.rs b/lib/tests/test_merge_trees.rs index 414df5f24..4101ad2f7 100644 --- a/lib/tests/test_merge_trees.rs +++ b/lib/tests/test_merge_trees.rs @@ -59,7 +59,7 @@ fn test_same_type(use_git: bool) { if contents != "_" { testutils::write_normal_file( &mut tree_builder, - &RepoPath::from_internal_string(*path), + &RepoPath::from_internal_string(path), contents, ); } diff --git a/src/commands.rs b/src/commands.rs index 79d2a3772..1a3a0c7d1 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -536,10 +536,10 @@ impl WorkspaceCommandHelper { ))), Some(commit) => { if iter.next().is_some() { - return Err(CommandError::UserError(format!( + Err(CommandError::UserError(format!( "Revset \"{}\" resolved to more than one revision", revision_str - ))); + ))) } else { Ok(commit?) }