diff rust/hg-core/src/filepatterns.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 c112cc9effdc
children 406b413e3cf2
line wrap: on
line diff
--- a/rust/hg-core/src/filepatterns.rs	Mon Nov 06 11:02:18 2023 +0100
+++ b/rust/hg-core/src/filepatterns.rs	Mon Nov 06 11:06:08 2023 +0100
@@ -629,8 +629,7 @@
             normalize_path_bytes(&get_bytes_from_path(source));
 
         let source_root = get_path_from_bytes(&normalized_source);
-        let source_root =
-            source_root.parent().unwrap_or_else(|| source_root.deref());
+        let source_root = source_root.parent().unwrap_or(source_root);
 
         let path = source_root.join(get_path_from_bytes(pattern));
         let new_root = path.parent().unwrap_or_else(|| path.deref());
@@ -682,22 +681,21 @@
         assert_eq!(escape_pattern(untouched), untouched.to_vec());
         // All escape codes
         assert_eq!(
-            escape_pattern(br#"()[]{}?*+-|^$\\.&~#\t\n\r\v\f"#),
-            br#"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\\t\\n\\r\\v\\f"#
-                .to_vec()
+            escape_pattern(br"()[]{}?*+-|^$\\.&~#\t\n\r\v\f"),
+            br"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\\t\\n\\r\\v\\f".to_vec()
         );
     }
 
     #[test]
     fn glob_test() {
-        assert_eq!(glob_to_re(br#"?"#), br#"."#);
-        assert_eq!(glob_to_re(br#"*"#), br#"[^/]*"#);
-        assert_eq!(glob_to_re(br#"**"#), br#".*"#);
-        assert_eq!(glob_to_re(br#"**/a"#), br#"(?:.*/)?a"#);
-        assert_eq!(glob_to_re(br#"a/**/b"#), br#"a/(?:.*/)?b"#);
-        assert_eq!(glob_to_re(br#"[a*?!^][^b][!c]"#), br#"[a*?!^][\^b][^c]"#);
-        assert_eq!(glob_to_re(br#"{a,b}"#), br#"(?:a|b)"#);
-        assert_eq!(glob_to_re(br#".\*\?"#), br#"\.\*\?"#);
+        assert_eq!(glob_to_re(br"?"), br".");
+        assert_eq!(glob_to_re(br"*"), br"[^/]*");
+        assert_eq!(glob_to_re(br"**"), br".*");
+        assert_eq!(glob_to_re(br"**/a"), br"(?:.*/)?a");
+        assert_eq!(glob_to_re(br"a/**/b"), br"a/(?:.*/)?b");
+        assert_eq!(glob_to_re(br"[a*?!^][^b][!c]"), br"[a*?!^][\^b][^c]");
+        assert_eq!(glob_to_re(br"{a,b}"), br"(?:a|b)");
+        assert_eq!(glob_to_re(br".\*\?"), br"\.\*\?");
     }
 
     #[test]