about summary refs log tree commit diff
path: root/tvix/store/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2022-12-29T11·23+0100
committerflokli <flokli@flokli.de>2022-12-29T12·07+0000
commit6ab8320f075e36f2328a86f5fcf7674844a0bd12 (patch)
treec7b339849519b4a4e8a067cdb387d1f42e71d0f7 /tvix/store/src
parentb0879917d4f4adbe4dac6bdf7f75d9e19f559114 (diff)
chore(tvix/store): address clippy warnings r/5533
The only warnings left are unused warnings, but that'll change once we
have a real implementation, and not just tests.

Change-Id: I28912281b5e66735be37e999cc8ef4b8b09028fb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7669
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src')
-rw-r--r--tvix/store/src/proto.rs31
1 files changed, 14 insertions, 17 deletions
diff --git a/tvix/store/src/proto.rs b/tvix/store/src/proto.rs
index e5cde99ca8dc..40f1d1050c10 100644
--- a/tvix/store/src/proto.rs
+++ b/tvix/store/src/proto.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::derive_partial_eq_without_eq)]
+// https://github.com/hyperium/tonic/issues/1056
 use std::collections::HashSet;
 use thiserror::Error;
 
@@ -6,7 +8,7 @@ use prost::Message;
 tonic::include_proto!("tvix.store.v1");
 
 /// Errors that can occur during the validation of Directory messages.
-#[derive(Debug, Error, PartialEq)]
+#[derive(Debug, PartialEq, Eq, Error)]
 pub enum ValidateDirectoryError {
     /// Elements are not in sorted order
     #[error("{0} is not sorted")]
@@ -28,10 +30,9 @@ pub enum ValidateDirectoryError {
 /// message with an empty string as name is allowed, but they don't occur
 /// inside a Directory message.
 fn validate_node_name(name: &str) -> Result<(), ValidateDirectoryError> {
-    if name == "" || name == ".." || name == "." || name.contains("\x00") || name.contains("/") {
-        return Err(ValidateDirectoryError::InvalidName(
-            name.to_string().clone(),
-        ));
+    if name.is_empty() || name == ".." || name == "." || name.contains('\x00') || name.contains('/')
+    {
+        return Err(ValidateDirectoryError::InvalidName(name.to_string()));
     }
     Ok(())
 }
@@ -53,9 +54,7 @@ fn update_if_lt_prev<'set, 'n>(
     name: &'n str,
 ) -> Result<(), ValidateDirectoryError> {
     if *name < **prev_name {
-        return Err(ValidateDirectoryError::WrongSorting(
-            name.to_string().clone(),
-        ));
+        return Err(ValidateDirectoryError::WrongSorting(name.to_string()));
     }
     *prev_name = name;
     Ok(())
@@ -68,9 +67,7 @@ fn insert_once<'n>(
     name: &'n str,
 ) -> Result<(), ValidateDirectoryError> {
     if seen_names.get(name).is_some() {
-        return Err(ValidateDirectoryError::DuplicateName(
-            name.to_string().clone(),
-        ));
+        return Err(ValidateDirectoryError::DuplicateName(name.to_string()));
     }
     seen_names.insert(name);
     Ok(())
@@ -111,8 +108,8 @@ impl Directory {
             validate_node_name(&directory_node.name)?;
             validate_digest(&directory_node.digest)?;
 
-            update_if_lt_prev(&mut last_directory_name, &mut directory_node.name.as_str())?;
-            insert_once(&mut seen_names, &directory_node.name.as_str())?;
+            update_if_lt_prev(&mut last_directory_name, directory_node.name.as_str())?;
+            insert_once(&mut seen_names, directory_node.name.as_str())?;
         }
 
         // check files
@@ -120,16 +117,16 @@ impl Directory {
             validate_node_name(&file_node.name)?;
             validate_digest(&file_node.digest)?;
 
-            update_if_lt_prev(&mut last_file_name, &mut file_node.name.as_str())?;
-            insert_once(&mut seen_names, &file_node.name.as_str())?;
+            update_if_lt_prev(&mut last_file_name, file_node.name.as_str())?;
+            insert_once(&mut seen_names, file_node.name.as_str())?;
         }
 
         // check symlinks
         for symlink_node in &self.symlinks {
             validate_node_name(&symlink_node.name)?;
 
-            update_if_lt_prev(&mut last_symlink_name, &mut symlink_node.name.as_str())?;
-            insert_once(&mut seen_names, &symlink_node.name.as_str())?;
+            update_if_lt_prev(&mut last_symlink_name, symlink_node.name.as_str())?;
+            insert_once(&mut seen_names, symlink_node.name.as_str())?;
         }
 
         Ok(())