diff options
author | Bob van der Linden <bobvanderlinden@gmail.com> | 2024-11-03T15·59+0100 |
---|---|---|
committer | Bob van der Linden <bobvanderlinden@gmail.com> | 2024-11-04T10·39+0000 |
commit | 9aa479648b63cbffdae4c6365549827692ca1914 (patch) | |
tree | 28355d376af37fae2bfdbc39d550c55a5129e5e5 /tvix/eval/src/vm/generators.rs | |
parent | b6e524c7267f21173a29fdb9ad2bb72297299858 (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/eval/src/vm/generators.rs')
-rw-r--r-- | tvix/eval/src/vm/generators.rs | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/tvix/eval/src/vm/generators.rs b/tvix/eval/src/vm/generators.rs index ae9a8dd6ab51..b47f20bae289 100644 --- a/tvix/eval/src/vm/generators.rs +++ b/tvix/eval/src/vm/generators.rs @@ -118,10 +118,6 @@ pub enum VMRequest { /// [`VM::catch_result`] for an explanation of how this works. TryForce(Value), - /// Request serialisation of a value to JSON, according to the - /// slightly odd Nix evaluation rules. - ToJson(Value), - /// Request the VM for the file type of the given path. ReadFileType(PathBuf), } @@ -180,7 +176,6 @@ impl Display for VMRequest { VMRequest::ReadDir(p) => write!(f, "read_dir({})", p.to_string_lossy()), VMRequest::Span => write!(f, "span"), VMRequest::TryForce(v) => write!(f, "try_force({})", v.type_of()), - VMRequest::ToJson(v) => write!(f, "to_json({})", v.type_of()), VMRequest::ReadFileType(p) => write!(f, "read_file_type({})", p.to_string_lossy()), } } @@ -497,14 +492,6 @@ where return Ok(false); } - VMRequest::ToJson(value) => { - self.reenqueue_generator(name, span, generator); - self.enqueue_generator("to_json", span, |co| { - value.into_contextful_json_generator(co) - }); - return Ok(false); - } - VMRequest::ReadFileType(path) => { let file_type = self .io_handle @@ -798,20 +785,6 @@ pub(crate) async fn request_span(co: &GenCo) -> Span { } } -pub(crate) async fn request_to_json( - co: &GenCo, - value: Value, -) -> Result<(serde_json::Value, NixContext), CatchableErrorKind> { - match co.yield_(VMRequest::ToJson(value)).await { - VMResponse::Value(Value::Json(json_with_ctx)) => Ok(*json_with_ctx), - VMResponse::Value(Value::Catchable(cek)) => Err(*cek), - msg => panic!( - "Tvix bug: VM responded with incorrect generator message: {}", - msg - ), - } -} - #[cfg_attr(not(feature = "impure"), allow(unused))] pub(crate) async fn request_read_file_type(co: &GenCo, path: PathBuf) -> FileType { match co.yield_(VMRequest::ReadFileType(path)).await { |