about summary refs log tree commit diff
path: root/tvix/eval/src/value/attrs.rs
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2023-12-11T11·57-0800
committerclbot <clbot@tvl.fyi>2023-12-12T14·54+0000
commit1ac57b0d1cdade99cd6cdf34211aa23e63db6f97 (patch)
treed4e50c627f6d06ec0889f42da2402a33ae89ccd2 /tvix/eval/src/value/attrs.rs
parent370137974526ef9af1f0d3496d17e4232e3babfe (diff)
feat(tvix/eval): nonrecursive coerce_to_string() r/7176
After this commit, the only non-builtins uses of generators are:

  - coerce_to_string() uses generators::request_enter_lambda()
  - Thunk::force() uses generators::request_enter_lambda()

That's it!  Once those two are taken care of, GenCo can become an
implementation detail of `builtins::BuiltinGen`.  No more crazy
nonlocal flow control within the interpreter: if you've got a GenCo
floating around in your code it's because you're writing a builtin,
which isn't part of the core interpreter.  The interpreter won't
need GenCos to talk to itself anymore.

Technically generators::request_path_import() is also used by
coerce_to_string(), but that's just because the io_handle happens to
be part of the VM.  There's no recursion-depth issue there, so the
call doesn't need to go through the generator mechanism
(request_path_import() doesn't call back to the interpreter!)

Change-Id: I83ce5774d49b88fdafdd61160975b4937a435bb0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10256
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Autosubmit: Adam Joseph <adam@westernsemico.com>
Diffstat (limited to 'tvix/eval/src/value/attrs.rs')
-rw-r--r--tvix/eval/src/value/attrs.rs26
1 files changed, 0 insertions, 26 deletions
diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs
index 03183810f2..b80d8b2db8 100644
--- a/tvix/eval/src/value/attrs.rs
+++ b/tvix/eval/src/value/attrs.rs
@@ -14,11 +14,9 @@ use serde::Deserialize;
 
 use super::string::NixString;
 use super::thunk::ThunkSet;
-use super::CoercionKind;
 use super::TotalDisplay;
 use super::Value;
 use crate::errors::ErrorKind;
-use crate::generators::{self, GenCo};
 
 lazy_static! {
     static ref NAME_S: NixString = "name".into();
@@ -370,30 +368,6 @@ impl NixAttrs {
     pub(crate) fn from_kv(name: Value, value: Value) -> Self {
         NixAttrs(AttrsRep::KV { name, value })
     }
-
-    /// Attempt to coerce an attribute set with a `__toString`
-    /// attribute to a string.
-    pub(crate) async fn try_to_string(&self, co: &GenCo, kind: CoercionKind) -> Option<NixString> {
-        if let Some(to_string) = self.select("__toString") {
-            let callable = generators::request_force(co, to_string.clone()).await;
-
-            // Leave the attribute set on the stack as an argument
-            // to the function call.
-            generators::request_stack_push(co, Value::Attrs(Box::new(self.clone()))).await;
-
-            // Call the callable ...
-            let result = generators::request_call(co, callable).await;
-
-            // Recurse on the result, as attribute set coercion
-            // actually works recursively, e.g. you can even return
-            // /another/ set with a __toString attr.
-            let s = generators::request_string_coerce(co, result, kind).await;
-
-            return s.ok();
-        }
-
-        None
-    }
 }
 
 impl IntoIterator for NixAttrs {