about summary refs log tree commit diff
path: root/tvix/eval/src/value/thunk.rs
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-11-22T04·04-0800
committerAdam Joseph <adam@westernsemico.com>2022-11-27T19·10+0000
commitdad8a7cbffbb0fac850e081e564eb09c67dd2fca (patch)
tree8b22a1affbe3c9175b68012caa5b849dd920c14e /tvix/eval/src/value/thunk.rs
parented9aa0c32a5c14768f887b9c237ab80d7d6be254 (diff)
feat(tvix/eval): non-recursive implementation of nix_eq() r/5345
This passes all the function/thunk-pointer-equality tests in
cl/7369.

Change-Id: Ib47535ba2fc77a4f1c2cc2fd23d3a879e21d8b4c
Signed-off-by: Adam Joseph <adam@westernsemico.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7358
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/value/thunk.rs')
-rw-r--r--tvix/eval/src/value/thunk.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs
index 1be13bfe893f..0d4c26bab492 100644
--- a/tvix/eval/src/value/thunk.rs
+++ b/tvix/eval/src/value/thunk.rs
@@ -190,6 +190,12 @@ impl Thunk {
             thunk => panic!("upvalues() on non-suspended thunk: {thunk:?}"),
         })
     }
+
+    /// Do not use this without first reading and understanding
+    /// `tvix/docs/value-pointer-equality.md`.
+    pub(crate) fn ptr_eq(&self, other: &Self) -> bool {
+        Rc::ptr_eq(&self.0, &other.0)
+    }
 }
 
 impl TotalDisplay for Thunk {