about summary refs log tree commit diff
path: root/tvix/nix-compat
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/nix-compat')
-rw-r--r--tvix/nix-compat/src/store_path/mod.rs4
-rw-r--r--tvix/nix-compat/src/store_path/utils.rs3
2 files changed, 4 insertions, 3 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs
index 56bf639f2129..8c5f6fd5c222 100644
--- a/tvix/nix-compat/src/store_path/mod.rs
+++ b/tvix/nix-compat/src/store_path/mod.rs
@@ -177,7 +177,9 @@ impl StorePath {
 
 /// Checks a given &[u8] to match the restrictions for [StorePath::name], and
 /// returns the name as string if successful.
-pub(crate) fn validate_name(s: &[u8]) -> Result<&str, Error> {
+pub(crate) fn validate_name(s: &(impl AsRef<[u8]> + ?Sized)) -> Result<&str, Error> {
+    let s = s.as_ref();
+
     // Empty or excessively long names are not allowed.
     if s.is_empty() || s.len() > 211 {
         return Err(Error::InvalidLength());
diff --git a/tvix/nix-compat/src/store_path/utils.rs b/tvix/nix-compat/src/store_path/utils.rs
index 94e9f106d9d5..44e4e4a59e94 100644
--- a/tvix/nix-compat/src/store_path/utils.rs
+++ b/tvix/nix-compat/src/store_path/utils.rs
@@ -166,8 +166,7 @@ fn build_store_path_from_fingerprint_parts<B: AsRef<[u8]>>(
     hash: &NixHash,
     name: B,
 ) -> Result<StorePath, Error> {
-    let name = name.as_ref();
-    let name = super::validate_name(name.as_ref())?.to_owned();
+    let name = super::validate_name(&name)?.to_owned();
 
     let digest = compress_hash(&{
         let mut h = Sha256::new();