From dad8a7cbffbb0fac850e081e564eb09c67dd2fca Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 21 Nov 2022 20:04:12 -0800 Subject: feat(tvix/eval): non-recursive implementation of nix_eq() This passes all the function/thunk-pointer-equality tests in cl/7369. Change-Id: Ib47535ba2fc77a4f1c2cc2fd23d3a879e21d8b4c Signed-off-by: Adam Joseph Reviewed-on: https://cl.tvl.fyi/c/depot/+/7358 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/src/value/thunk.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tvix/eval/src/value/thunk.rs') 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 { -- cgit 1.4.1