about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-02-26T15·40+0300
committertazjin <tazjin@tvl.su>2023-03-04T15·53+0000
commitbfb787a6c5dc6ccd9a25efc015770f20702c2a55 (patch)
tree9bd2630aeb074ad5fb3ae6e261350785392ad4f4 /tvix/eval
parent38fd3cb2929518aae42ce239a8b115c4d568bb4d (diff)
refactor(tvix/eval): remove VM argument from suspended native thunks r/5888
Because they do not use it, and it can not be passed with the coming
generator refactoring.

Change-Id: I0d96f2357a7ee79cd8a0f401583d4286230d4a6b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8146
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/builtins/impure.rs8
-rw-r--r--tvix/eval/src/compiler/mod.rs4
-rw-r--r--tvix/eval/src/value/thunk.rs8
3 files changed, 7 insertions, 13 deletions
diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs
index 8073670811..91dce152e5 100644
--- a/tvix/eval/src/builtins/impure.rs
+++ b/tvix/eval/src/builtins/impure.rs
@@ -6,13 +6,7 @@ use std::{
     time::{SystemTime, UNIX_EPOCH},
 };
 
-use crate::{
-    errors::ErrorKind,
-    io::FileType,
-    value::{NixAttrs, Thunk},
-    vm::VM,
-    Value,
-};
+use crate::{errors::ErrorKind, io::FileType, value::NixAttrs, vm::VM, Value};
 
 #[builtins]
 mod impure_builtins {
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 83b1f01a80..6dd0b669f9 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -1329,7 +1329,7 @@ fn compile_src_builtin(
     let file = source.add_file(format!("<src-builtins/{}.nix>", name), code.to_string());
     let weak = weak.clone();
 
-    Value::Thunk(Thunk::new_suspended_native(Box::new(move |_| {
+    Value::Thunk(Thunk::new_suspended_native(Box::new(move || {
         let result = compile(
             &parsed.tree().expr().unwrap(),
             None,
@@ -1390,7 +1390,7 @@ pub fn prepare_globals(
         let weak_globals = weak.clone();
         builtins.insert(
             "builtins",
-            Value::Thunk(Thunk::new_suspended_native(Box::new(move |_| {
+            Value::Thunk(Thunk::new_suspended_native(Box::new(move || {
                 Ok(weak_globals
                     .upgrade()
                     .unwrap()
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs
index 1c7ed61552..43adb314a2 100644
--- a/tvix/eval/src/value/thunk.rs
+++ b/tvix/eval/src/value/thunk.rs
@@ -39,7 +39,7 @@ use crate::{
 use super::{Lambda, TotalDisplay};
 
 /// Internal representation of a suspended native thunk.
-struct SuspendedNative(Box<dyn Fn(&mut VM) -> Result<Value, ErrorKind>>);
+struct SuspendedNative(Box<dyn Fn() -> Result<Value, ErrorKind>>);
 
 impl Debug for SuspendedNative {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -109,7 +109,7 @@ impl Thunk {
         })))
     }
 
-    pub fn new_suspended_native(native: Box<dyn Fn(&mut VM) -> Result<Value, ErrorKind>>) -> Self {
+    pub fn new_suspended_native(native: Box<dyn Fn() -> Result<Value, ErrorKind>>) -> Self {
         Thunk(Rc::new(RefCell::new(ThunkRepr::Native(SuspendedNative(
             native,
         )))))
@@ -199,7 +199,7 @@ impl Thunk {
             // the trampoline, to handle the case of the native function
             // returning another thunk.
             ThunkRepr::Native(native) => {
-                let value = native.0(vm)?;
+                let value = native.0()?;
                 self.0.replace(ThunkRepr::Evaluated(value));
                 let self_clone = self.clone();
 
@@ -277,7 +277,7 @@ impl Thunk {
                     // Same as for the native case above, but results are placed
                     // in *both* thunks.
                     ThunkRepr::Native(native) => {
-                        let value = native.0(vm)?;
+                        let value = native.0()?;
                         self.0.replace(ThunkRepr::Evaluated(value.clone()));
                         inner.0.replace(ThunkRepr::Evaluated(value));
                         let self_clone = self.clone();