about summary refs log tree commit diff
path: root/tvix/eval/src/value
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r--tvix/eval/src/value/attrs.rs12
-rw-r--r--tvix/eval/src/value/mod.rs27
2 files changed, 23 insertions, 16 deletions
diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs
index f614128550f3..319f6bdfa9bb 100644
--- a/tvix/eval/src/value/attrs.rs
+++ b/tvix/eval/src/value/attrs.rs
@@ -10,7 +10,7 @@ use std::collections::BTreeMap;
 use std::fmt::Display;
 use std::rc::Rc;
 
-use crate::errors::{Error, EvalResult};
+use crate::errors::{ErrorKind, EvalResult};
 
 use super::string::NixString;
 use super::Value;
@@ -304,9 +304,10 @@ fn attempt_optimise_kv(slice: &mut [Value]) -> Option<NixAttrs> {
 // checking against duplicate keys.
 fn set_attr(attrs: &mut NixAttrs, key: NixString, value: Value) -> EvalResult<()> {
     match attrs.0.map_mut().entry(key) {
-        btree_map::Entry::Occupied(entry) => Err(Error::DuplicateAttrsKey {
+        btree_map::Entry::Occupied(entry) => Err(ErrorKind::DuplicateAttrsKey {
             key: entry.key().as_str().to_string(),
-        }),
+        }
+        .into()),
 
         btree_map::Entry::Vacant(entry) => {
             entry.insert(value);
@@ -365,9 +366,10 @@ fn set_nested_attr(
             }
 
             _ => {
-                return Err(Error::DuplicateAttrsKey {
+                return Err(ErrorKind::DuplicateAttrsKey {
                     key: entry.key().as_str().to_string(),
-                })
+                }
+                .into())
             }
         },
     }
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 6c0473fa6618..f054191f6716 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -7,7 +7,7 @@ mod attrs;
 mod list;
 mod string;
 
-use crate::errors::{Error, EvalResult};
+use crate::errors::{ErrorKind, EvalResult};
 pub use attrs::NixAttrs;
 pub use list::NixList;
 pub use string::NixString;
@@ -55,50 +55,55 @@ impl Value {
     pub fn as_bool(&self) -> EvalResult<bool> {
         match self {
             Value::Bool(b) => Ok(*b),
-            other => Err(Error::TypeError {
+            other => Err(ErrorKind::TypeError {
                 expected: "bool",
                 actual: other.type_of(),
-            }),
+            }
+            .into()),
         }
     }
 
     pub fn as_attrs(&self) -> EvalResult<&NixAttrs> {
         match self {
             Value::Attrs(attrs) => Ok(attrs),
-            other => Err(Error::TypeError {
+            other => Err(ErrorKind::TypeError {
                 expected: "set",
                 actual: other.type_of(),
-            }),
+            }
+            .into()),
         }
     }
 
     pub fn to_string(self) -> EvalResult<NixString> {
         match self {
             Value::String(s) => Ok(s),
-            other => Err(Error::TypeError {
+            other => Err(ErrorKind::TypeError {
                 expected: "string",
                 actual: other.type_of(),
-            }),
+            }
+            .into()),
         }
     }
 
     pub fn to_attrs(self) -> EvalResult<Rc<NixAttrs>> {
         match self {
             Value::Attrs(s) => Ok(s),
-            other => Err(Error::TypeError {
+            other => Err(ErrorKind::TypeError {
                 expected: "set",
                 actual: other.type_of(),
-            }),
+            }
+            .into()),
         }
     }
 
     pub fn to_list(self) -> EvalResult<NixList> {
         match self {
             Value::List(l) => Ok(l),
-            other => Err(Error::TypeError {
+            other => Err(ErrorKind::TypeError {
                 expected: "list",
                 actual: other.type_of(),
-            }),
+            }
+            .into()),
         }
     }