From a22255bd51d8fd9579164dcfcf4394701212a9f0 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Fri, 28 Jul 2023 18:59:41 -0700 Subject: [PATCH] Fix `cargo +nightly clippy` warnings --- lib/src/commit.rs | 2 +- lib/src/operation.rs | 4 ++-- src/cli_util.rs | 19 ++++++++----------- src/commands/git.rs | 4 ++-- src/commands/mod.rs | 2 +- src/merge_tools.rs | 18 +++++++++--------- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/lib/src/commit.rs b/lib/src/commit.rs index d701e97dd..80fb5c9d3 100644 --- a/lib/src/commit.rs +++ b/lib/src/commit.rs @@ -55,7 +55,7 @@ impl Ord for Commit { impl PartialOrd for Commit { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.id.cmp(&other.id)) + Some(self.cmp(other)) } } diff --git a/lib/src/operation.rs b/lib/src/operation.rs index c9c3cb1c5..be545fe55 100644 --- a/lib/src/operation.rs +++ b/lib/src/operation.rs @@ -53,7 +53,7 @@ impl Ord for Operation { impl PartialOrd for Operation { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.id.cmp(&other.id)) + Some(self.cmp(other)) } } @@ -133,7 +133,7 @@ impl Ord for View { impl PartialOrd for View { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.id.cmp(&other.id)) + Some(self.cmp(other)) } } diff --git a/src/cli_util.rs b/src/cli_util.rs index 849933af0..8d169e112 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -1341,7 +1341,7 @@ impl WorkspaceCommandTransaction<'_> { pub fn run_mergetool( &self, - ui: &mut Ui, + ui: &Ui, tree: &Tree, repo_path: &RepoPath, ) -> Result { @@ -1353,7 +1353,7 @@ impl WorkspaceCommandTransaction<'_> { pub fn edit_diff( &self, - ui: &mut Ui, + ui: &Ui, left_tree: &Tree, right_tree: &Tree, instructions: &str, @@ -1372,7 +1372,7 @@ impl WorkspaceCommandTransaction<'_> { pub fn select_diff( &self, - ui: &mut Ui, + ui: &Ui, left_tree: &Tree, right_tree: &Tree, instructions: &str, @@ -1598,10 +1598,7 @@ pub fn print_checkout_stats(ui: &mut Ui, stats: CheckoutStats) -> Result<(), std Ok(()) } -pub fn print_failed_git_export( - ui: &mut Ui, - failed_branches: &[RefName], -) -> Result<(), std::io::Error> { +pub fn print_failed_git_export(ui: &Ui, failed_branches: &[RefName]) -> Result<(), std::io::Error> { if !failed_branches.is_empty() { writeln!(ui.warning(), "Failed to export some branches:")?; let mut formatter = ui.stderr_formatter(); @@ -1737,7 +1734,7 @@ fn resolve_single_op_from_store( } fn load_revset_aliases( - ui: &mut Ui, + ui: &Ui, layered_configs: &LayeredConfigs, ) -> Result { const TABLE_KEY: &str = "revset-aliases"; @@ -1852,7 +1849,7 @@ pub fn update_working_copy( } fn load_template_aliases( - ui: &mut Ui, + ui: &Ui, layered_configs: &LayeredConfigs, ) -> Result { const TABLE_KEY: &str = "template-aliases"; @@ -2257,7 +2254,7 @@ impl ValueParserFactory for RevisionArg { } fn resolve_default_command( - ui: &mut Ui, + ui: &Ui, config: &config::Config, app: &Command, mut string_args: Vec, @@ -2395,7 +2392,7 @@ fn handle_early_args( } pub fn expand_args( - ui: &mut Ui, + ui: &Ui, app: &Command, args_os: ArgsOs, config: &config::Config, diff --git a/src/commands/git.rs b/src/commands/git.rs index d6c91d39a..fb9ad1f4c 100644 --- a/src/commands/git.rs +++ b/src/commands/git.rs @@ -326,7 +326,7 @@ fn get_single_remote(git_repo: &git2::Repository) -> Result, Comm const DEFAULT_REMOTE: &str = "origin"; fn get_default_fetch_remotes( - ui: &mut Ui, + ui: &Ui, command: &CommandHelper, git_repo: &git2::Repository, ) -> Result, CommandError> { @@ -915,7 +915,7 @@ fn cmd_git_push( } fn get_default_push_remote( - ui: &mut Ui, + ui: &Ui, command: &CommandHelper, git_repo: &git2::Repository, ) -> Result { diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 6af9cadaf..2cd0dbf3c 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1010,7 +1010,7 @@ struct UtilMangenArgs {} #[derive(clap::Args, Clone, Debug)] struct UtilConfigSchemaArgs {} -fn add_to_git_exclude(ui: &mut Ui, git_repo: &git2::Repository) -> Result<(), CommandError> { +fn add_to_git_exclude(ui: &Ui, git_repo: &git2::Repository) -> Result<(), CommandError> { let exclude_file_path = git_repo.path().join("info").join("exclude"); if exclude_file_path.exists() { match fs::OpenOptions::new() diff --git a/src/merge_tools.rs b/src/merge_tools.rs index 5beb99521..374759ace 100644 --- a/src/merge_tools.rs +++ b/src/merge_tools.rs @@ -153,7 +153,7 @@ fn set_readonly_recursively(path: &Path) -> Result<(), std::io::Error> { // TODO: Rearrange the functions. This should be on the bottom, options should // be on the top. pub fn run_mergetool( - ui: &mut Ui, + ui: &Ui, tree: &Tree, repo_path: &RepoPath, settings: &UserSettings, @@ -296,7 +296,7 @@ fn interpolate_variables>( } pub fn edit_diff( - ui: &mut Ui, + ui: &Ui, left_tree: &Tree, right_tree: &Tree, instructions: &str, @@ -464,7 +464,7 @@ fn get_tool_config(settings: &UserSettings, name: &str) -> Result Result { let args = editor_args_from_settings(ui, settings, "ui.diff-editor")?; @@ -477,7 +477,7 @@ fn get_diff_editor_from_settings( } fn get_merge_tool_from_settings( - ui: &mut Ui, + ui: &Ui, settings: &UserSettings, ) -> Result { let args = editor_args_from_settings(ui, settings, "ui.merge-editor")?; @@ -498,7 +498,7 @@ fn get_merge_tool_from_settings( /// Finds the appropriate tool for diff editing or merges fn editor_args_from_settings( - ui: &mut Ui, + ui: &Ui, settings: &UserSettings, key: &str, ) -> Result { @@ -533,9 +533,9 @@ mod tests { fn test_get_diff_editor() { let get = |text| { let config = config_from_string(text); - let mut ui = Ui::with_config(&config).unwrap(); + let ui = Ui::with_config(&config).unwrap(); let settings = UserSettings::from_config(config); - get_diff_editor_from_settings(&mut ui, &settings) + get_diff_editor_from_settings(&ui, &settings) }; // Default @@ -663,9 +663,9 @@ mod tests { fn test_get_merge_tool() { let get = |text| { let config = config_from_string(text); - let mut ui = Ui::with_config(&config).unwrap(); + let ui = Ui::with_config(&config).unwrap(); let settings = UserSettings::from_config(config); - get_merge_tool_from_settings(&mut ui, &settings) + get_merge_tool_from_settings(&ui, &settings) }; // Default