diff options
author | Adam Joseph <adam@westernsemico.com> | 2022-11-24T08·35-0800 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-11-26T11·44+0000 |
commit | 0616976f7c4be17d375aefaa3df9ba8088bd57a0 (patch) | |
tree | 7837abc552c82209d72178f904bf0f8060f9b994 /tvix/eval/src/value/thunk.rs | |
parent | 5eabadf06ce3c07978fcd59b978be398964e30c5 (diff) |
feat(tvix/eval): wrap Closure::upvalues in Rc r/5324
See cl/7372; Nix equality semantics require the ability to track pointer equality of upvalue-sets. Signed-off-by: Adam Joseph <adam@westernsemico.com> Change-Id: I82ba517499cf370189a80355e4e46a5caaab7153 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7373 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/value/thunk.rs')
-rw-r--r-- | tvix/eval/src/value/thunk.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs index 5107c6328da4..1be13bfe893f 100644 --- a/tvix/eval/src/value/thunk.rs +++ b/tvix/eval/src/value/thunk.rs @@ -70,7 +70,7 @@ impl Thunk { pub fn new_closure(lambda: Rc<Lambda>) -> Self { Thunk(Rc::new(RefCell::new(ThunkRepr::Evaluated(Value::Closure( Closure { - upvalues: Upvalues::with_capacity(lambda.upvalue_count), + upvalues: Rc::new(Upvalues::with_capacity(lambda.upvalue_count)), lambda: lambda.clone(), #[cfg(debug_assertions)] is_finalised: false, @@ -184,7 +184,8 @@ impl Thunk { if *is_finalised { panic!("Thunk::upvalues_mut() called on a finalised closure"); } - upvalues + Rc::get_mut(upvalues) + .expect("upvalues_mut() was called on a thunk which already had multiple references to it") } thunk => panic!("upvalues() on non-suspended thunk: {thunk:?}"), }) |