about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-10T17·42+0300
committertazjin <tazjin@tvl.su>2022-08-25T11·11+0000
commit58db7e3a65ac96664ebd8c73bdff7185e59b8cff (patch)
tree6f566dbd326993a67ed98486961e44fe7906f584 /tvix/eval/src
parentfb3d024d75fe4f6760ef616fe8dfd307b7d7b688 (diff)
fix(tvix/value): ensure only string values of NixString are hashed r/4473
Change-Id: I1b97cf5a9e4e235fac72a507de49a8df508bcaa1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6138
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/value/string.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs
index 1b4f349f1ac5..f9178ca7f4bb 100644
--- a/tvix/eval/src/value/string.rs
+++ b/tvix/eval/src/value/string.rs
@@ -1,9 +1,10 @@
+use std::hash::Hash;
 use std::{borrow::Cow, fmt::Display};
 
 /// This module implements Nix language strings and their different
 /// backing implementations.
 
-#[derive(Clone, Debug, Hash, Eq, Ord)]
+#[derive(Clone, Debug, Eq, Ord)]
 pub enum NixString {
     Static(&'static str),
     Heap(String),
@@ -33,6 +34,12 @@ impl From<String> for NixString {
     }
 }
 
+impl Hash for NixString {
+    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+        self.as_str().hash(state)
+    }
+}
+
 impl NixString {
     pub const NAME: Self = NixString::Static("name");
     pub const VALUE: Self = NixString::Static("value");