about summary refs log tree commit diff
path: root/tvix/serde
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@tvl.su>2024-02-20T08·38+0700
committertazjin <tazjin@tvl.su>2024-02-20T09·18+0000
commit94f582341e4f37228fbdf0997255d6374264b4b3 (patch)
treea3425ba313777076559203174ba5755864b05c98 /tvix/serde
parent3c87687798a3cfb6c3cfcc231e6c60511e3341ab (diff)
refactor(tvix/eval): use internal SourceCode field in error printers r/7572
Makes use of the SourceCode field now being stored directly in
errors (see parent CL). With this change, the default `Display`
implementation can now format errors correctly, and there is no need
to keep a `SourceCode` around just for error formatting.

Updates dependent crates (CLI, serde, tvixbolt) to use this correctly.

Change-Id: Iddc5d7a6b4bab391f30a999e4c68aca34304c059
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10987
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/serde')
-rw-r--r--tvix/serde/src/de.rs2
-rw-r--r--tvix/serde/src/error.rs9
2 files changed, 3 insertions, 8 deletions
diff --git a/tvix/serde/src/de.rs b/tvix/serde/src/de.rs
index 6a020c978f..e9d4f6cf49 100644
--- a/tvix/serde/src/de.rs
+++ b/tvix/serde/src/de.rs
@@ -51,13 +51,11 @@ where
     config(&mut eval);
 
     eval.strict = true;
-    let source = eval.source_map();
     let result = eval.evaluate(src, None);
 
     if !result.errors.is_empty() {
         return Err(Error::NixErrors {
             errors: result.errors,
-            source,
         });
     }
 
diff --git a/tvix/serde/src/error.rs b/tvix/serde/src/error.rs
index c1d2258bbf..d921cc4b4b 100644
--- a/tvix/serde/src/error.rs
+++ b/tvix/serde/src/error.rs
@@ -27,10 +27,7 @@ pub enum Error {
 
     /// Evaluation of the supplied Nix code failed while computing the
     /// value for deserialisation.
-    NixErrors {
-        errors: Vec<tvix_eval::Error>,
-        source: tvix_eval::SourceCode,
-    },
+    NixErrors { errors: Vec<tvix_eval::Error> },
 
     /// Could not determine an externally tagged enum representation.
     AmbiguousEnum,
@@ -56,7 +53,7 @@ impl Display for Error {
                 write!(f, "expected type {}, but got Nix type {}", expected, got)
             }
 
-            Error::NixErrors { errors, source } => {
+            Error::NixErrors { errors } => {
                 writeln!(
                     f,
                     "{} occured during Nix evaluation: ",
@@ -64,7 +61,7 @@ impl Display for Error {
                 )?;
 
                 for err in errors {
-                    writeln!(f, "{}", err.fancy_format_str(source))?;
+                    writeln!(f, "{}", err.fancy_format_str())?;
                 }
 
                 Ok(())