diff rust/hg-core/src/revlog/nodemap.rs @ 51118:532e74ad3ff6

rust: run a clippy pass with the latest stable version Our current version of clippy is older than the latest stable. The newest version has new lints that are moslty good advice, so let's apply them ahead of time. This has the added benefit of reducing the noise for developpers like myself that use clippy as an IDE helper, as well as being more prepared for a future clippy upgrade.
author Rapha?l Gom?s <rgomes@octobus.net>
date Mon, 06 Nov 2023 11:06:08 +0100
parents 12c308c55e53
children 198674d830d6
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/nodemap.rs	Mon Nov 06 11:02:18 2023 +0100
+++ b/rust/hg-core/src/revlog/nodemap.rs	Mon Nov 06 11:06:08 2023 +0100
@@ -656,7 +656,7 @@
 
 impl fmt::Debug for NodeTree {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let readonly: &[Block] = &*self.readonly;
+        let readonly: &[Block] = &self.readonly;
         write!(
             f,
             "readonly: {:?}, growable: {:?}, root: {:?}",
@@ -668,7 +668,7 @@
 impl Default for NodeTree {
     /// Create a fully mutable empty NodeTree
     fn default() -> Self {
-        NodeTree::new(Box::new(Vec::new()))
+        NodeTree::new(Box::<Vec<_>>::default())
     }
 }
 
@@ -775,7 +775,7 @@
     /// strings for test data, and brings actual hash size independency.
     #[cfg(test)]
     fn pad_node(hex: &str) -> Node {
-        Node::from_hex(&hex_pad_right(hex)).unwrap()
+        Node::from_hex(hex_pad_right(hex)).unwrap()
     }
 
     /// Pad hexadecimal Node prefix with zeros on the right, then insert
@@ -824,7 +824,7 @@
             nt.find_node(&idx, idx.get(&1.into()).unwrap())?,
             Some(R!(1))
         );
-        let unknown = Node::from_hex(&hex_pad_right("3d")).unwrap();
+        let unknown = Node::from_hex(hex_pad_right("3d")).unwrap();
         assert_eq!(nt.find_node(&idx, &unknown)?, None);
         Ok(())
     }
@@ -900,7 +900,7 @@
             hex: &str,
         ) -> Result<(), NodeMapError> {
             let node = pad_node(hex);
-            return self.insert_node(rev, node);
+            self.insert_node(rev, node)
         }
 
         fn find_hex(
@@ -931,6 +931,12 @@
         }
     }
 
+    impl Default for TestNtIndex {
+        fn default() -> Self {
+            Self::new()
+        }
+    }
+
     #[test]
     fn test_insert_full_mutable() -> Result<(), NodeMapError> {
         let mut idx = TestNtIndex::new();
@@ -1003,7 +1009,7 @@
         let mut node1_hex = hex_pad_right("444444");
         node1_hex.pop();
         node1_hex.push('5');
-        let node0 = Node::from_hex(&node0_hex).unwrap();
+        let node0 = Node::from_hex(node0_hex).unwrap();
         let node1 = Node::from_hex(&node1_hex).unwrap();
 
         idx.insert(0.into(), node0);