about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-12-12T20·26+0300
committertazjin <tazjin@tvl.su>2022-12-21T22·59+0000
commitedd13573f523a3a03346d6737081466bc9c5299d (patch)
tree5f1b2439ec8e182890f5fc09451af4dd5a07c825 /tvix
parent947a56c4b6c5d5ed4f25f229f5de6afde564bbf9 (diff)
refactor(tvix/eval): use light spans in builtins.import r/5466
Change-Id: I05732073155b430575babb6f076bf465aef98857
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7581
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/builtins/impure.rs8
-rw-r--r--tvix/eval/src/vm.rs12
2 files changed, 8 insertions, 12 deletions
diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs
index 904706dc65..d371d87797 100644
--- a/tvix/eval/src/builtins/impure.rs
+++ b/tvix/eval/src/builtins/impure.rs
@@ -13,7 +13,6 @@ use crate::{
     errors::ErrorKind,
     io::FileType,
     observer::NoOpObserver,
-    spans::LightSpan,
     value::{Builtin, BuiltinArgument, NixAttrs, Thunk},
     vm::VM,
     SourceCode, Value,
@@ -123,7 +122,7 @@ pub fn builtins_import(globals: &Weak<GlobalsMap>, source: SourceCode) -> Builti
                 path.push("default.nix");
             }
 
-            let current_span = vm.current_span();
+            let current_span = vm.current_light_span();
 
             if let Some(cached) = vm.import_cache.get(&path) {
                 return Ok(cached.clone());
@@ -172,10 +171,7 @@ pub fn builtins_import(globals: &Weak<GlobalsMap>, source: SourceCode) -> Builti
 
             // Compilation succeeded, we can construct a thunk from whatever it spat
             // out and return that.
-            let res = Value::Thunk(Thunk::new_suspended(
-                result.lambda,
-                LightSpan::new_actual(current_span),
-            ));
+            let res = Value::Thunk(Thunk::new_suspended(result.lambda, current_span));
 
             vm.import_cache.insert(path, res.clone());
 
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index fcbbe61909..b074bd4224 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -220,17 +220,17 @@ impl<'o> VM<'o> {
         self.chunk().get_span(self.frame().ip - 1)
     }
 
-    /// Access the I/O handle used for filesystem access in this VM.
-    pub(crate) fn io(&self) -> &Box<dyn EvalIO> {
-        &self.io_handle
-    }
-
     /// Returns the information needed to calculate the current span,
     /// but without performing that calculation.
-    fn current_light_span(&self) -> LightSpan {
+    pub(crate) fn current_light_span(&self) -> LightSpan {
         LightSpan::new_delayed(self.frame().lambda.clone(), self.frame().ip - 1)
     }
 
+    /// Access the I/O handle used for filesystem access in this VM.
+    pub(crate) fn io(&self) -> &Box<dyn EvalIO> {
+        &self.io_handle
+    }
+
     /// Construct an error from the given ErrorKind and the source
     /// span of the current instruction.
     pub fn error(&self, kind: ErrorKind) -> Error {