changeset 50004:fba29deebfe7

rust-clippy: fix remaining warnings in `rhg` All of these are simple changes that for the most part are clear improvements and the rest are at most equivalent.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 09 Jan 2023 19:32:35 +0100
parents e98fd81bb151
children 136aa80aa8b2
files rust/rhg/src/color.rs rust/rhg/src/main.rs
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/rust/rhg/src/color.rs	Mon Jan 09 19:18:43 2023 +0100
+++ b/rust/rhg/src/color.rs	Mon Jan 09 19:32:35 2023 +0100
@@ -205,16 +205,14 @@
             return Err(HgError::unsupported("debug color mode"));
         }
         let auto = enabled == b"auto";
-        let always;
-        if !auto {
+        let always = if !auto {
             let enabled_bool = config.get_bool(b"ui", b"color")?;
             if !enabled_bool {
                 return Ok(None);
             }
-            always = enabled == b"always"
-                || *origin == ConfigOrigin::CommandLineColor
+            enabled == b"always" || *origin == ConfigOrigin::CommandLineColor
         } else {
-            always = false
+            false
         };
         let formatted = always
             || (std::env::var_os("TERM").unwrap_or_default() != "dumb"
--- a/rust/rhg/src/main.rs	Mon Jan 09 19:18:43 2023 +0100
+++ b/rust/rhg/src/main.rs	Mon Jan 09 19:32:35 2023 +0100
@@ -284,7 +284,8 @@
                     }
                 }
             };
-            config_val.or(Some(get_path_from_bytes(&repo_arg).to_path_buf()))
+            config_val
+                .or_else(|| Some(get_path_from_bytes(&repo_arg).to_path_buf()))
         }
     };
 
@@ -424,7 +425,7 @@
         };
         let executable_path = get_path_from_bytes(executable);
         let this_executable = args.next().expect("exepcted argv[0] to exist");
-        if executable_path == &PathBuf::from(this_executable) {
+        if executable_path == *this_executable {
             // Avoid spawning infinitely many processes until resource
             // exhaustion.
             let _ = ui.write_stderr(&format_bytes!(
@@ -739,6 +740,7 @@
 }
 
 /// Array of tuples of (auto upgrade conf, feature conf, local requirement)
+#[allow(clippy::type_complexity)]
 const AUTO_UPGRADES: &[((&str, &str), (&str, &str), &str)] = &[
     (
         ("format", "use-share-safe.automatic-upgrade-of-mismatching-repositories"),