about summary refs log tree commit diff
path: root/tvix/glue
diff options
context:
space:
mode:
authorBob van der Linden <bobvanderlinden@gmail.com>2024-11-03T15·59+0100
committerBob van der Linden <bobvanderlinden@gmail.com>2024-11-04T10·39+0000
commit9aa479648b63cbffdae4c6365549827692ca1914 (patch)
tree28355d376af37fae2bfdbc39d550c55a5129e5e5 /tvix/glue
parentb6e524c7267f21173a29fdb9ad2bb72297299858 (diff)
refactor(tvix/eval): remove Value::Json and related functionality r/8890
Currently Value::Json is used in combination with VMRequest::ToJson to
recursively convert tvix Value to serde_json::Value. This functionality
is used in builtins.toJSON as well as derivation __structuredAttrs.

Both Value::Json and VMRequest::ToJson were removed in this commit.

Related functionality in vm.rs is also removed: vm.rs does not know
about JSON anymore.

Recursively converting to serde_json now happens without going through
the VM.

Thrown errors that are part of the value of toJSON are now directly
propagated as ErrorKind, were-as previously there was a split between
CatchableErrorKind and ErrorKind, where eventually CatchableErrorKind
would be converted to ErrorKind::Catchable.

Change-Id: I066f064926c491e4c087a984f07af43d19124cfe
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12732
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/glue')
-rw-r--r--tvix/glue/src/builtins/derivation.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/tvix/glue/src/builtins/derivation.rs b/tvix/glue/src/builtins/derivation.rs
index 11b70a934a7b..3048fd8390c2 100644
--- a/tvix/glue/src/builtins/derivation.rs
+++ b/tvix/glue/src/builtins/derivation.rs
@@ -300,7 +300,7 @@ pub(crate) mod derivation_builtins {
                     // Remove the original default `out` output.
                     drv.outputs.clear();
 
-                    let mut output_names = vec![];
+                    let mut output_names = Vec::with_capacity(outputs.len());
 
                     for output in outputs {
                         let output_name = generators::request_force(&co, output)
@@ -379,11 +379,7 @@ pub(crate) mod derivation_builtins {
                             return Ok(val);
                         }
 
-                        let (val_json, context) = match val.into_contextful_json(&co).await? {
-                            Ok(v) => v,
-                            Err(cek) => return Ok(Value::from(cek)),
-                        };
-
+                        let (val_json, context) = val.into_contextful_json(&co).await?;
                         input_context.extend(context.into_iter());
 
                         // No need to check for dups, we only iterate over every attribute name once