git.delta.rocks / jrsonnet / refs/commits / a3646b331c9c

difftreelog

style fix formatting

wsyrkszxYaroslav Bolyukin2026-04-25parent: #112adb2.patch.diff
in: master

31 files changed

modifiedcrates/jrsonnet-evaluator/src/analyze.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/analyze.rs
+++ b/crates/jrsonnet-evaluator/src/analyze.rs
@@ -21,10 +21,10 @@
 use jrsonnet_gcmodule::Acyclic;
 use jrsonnet_interner::IStr;
 use jrsonnet_ir::{
-	function::FunctionSignature, ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BinaryOpType,
-	BindSpec, CompSpec, Destruct, Expr, ExprParams, FieldName, ForSpecData, IfElse, IfSpecData,
-	ImportKind, LiteralType, NumValue, ObjBody, ObjComp, ObjMembers, Slice, SliceDesc, Span,
-	Spanned, UnaryOpType, Visibility,
+	ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BinaryOpType, BindSpec, CompSpec, Destruct, Expr,
+	ExprParams, FieldName, ForSpecData, IfElse, IfSpecData, ImportKind, LiteralType, NumValue,
+	ObjBody, ObjComp, ObjMembers, Slice, SliceDesc, Span, Spanned, UnaryOpType, Visibility,
+	function::FunctionSignature,
 };
 use rustc_hash::FxHashMap;
 use smallvec::SmallVec;
modifiedcrates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/arr/mod.rs
+++ b/crates/jrsonnet-evaluator/src/arr/mod.rs
@@ -5,9 +5,9 @@
 	rc::Rc,
 };
 
-use jrsonnet_gcmodule::{cc_dyn, Cc};
+use jrsonnet_gcmodule::{Cc, cc_dyn};
 
-use crate::{analyze::LExpr, function::NativeFn, typed::IntoUntyped, Context, Result, Thunk, Val};
+use crate::{Context, Result, Thunk, Val, analyze::LExpr, function::NativeFn, typed::IntoUntyped};
 
 mod spec;
 pub use spec::{ArrayLike, *};
modifiedcrates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/arr/spec.rs
+++ b/crates/jrsonnet-evaluator/src/arr/spec.rs
@@ -11,13 +11,13 @@
 
 use super::ArrValue;
 use crate::{
+	Context, Error, ObjValue, Result, Thunk, Val,
 	analyze::LExpr,
 	error::ErrorKind::InfiniteRecursionDetected,
 	evaluate::evaluate,
 	function::NativeFn,
 	typed::{IntoUntyped, Typed},
 	val::ThunkValue,
-	Context, Error, ObjValue, Result, Thunk, Val,
 };
 
 pub trait ArrayLike: Any + Trace + Debug {
modifiedcrates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -4,7 +4,7 @@
 use jrsonnet_gcmodule::{Cc, Trace};
 use jrsonnet_interner::IStr;
 
-use crate::{analyze::LocalId, error, error::ErrorKind::*, Pending, Result, SupThis, Thunk, Val};
+use crate::{Pending, Result, SupThis, Thunk, Val, analyze::LocalId, error, error::ErrorKind::*};
 
 #[derive(Debug, Trace, Clone, Educe)]
 #[educe(PartialEq)]
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -9,10 +9,10 @@
 use thiserror::Error;
 
 use crate::{
+	ObjValue, ResolvePathOwned,
 	function::{CallLocation, FunctionSignature, ParamName},
 	stdlib::format::FormatError,
 	typed::TypeLocError,
-	ObjValue, ResolvePathOwned,
 };
 
 #[derive(Debug, Clone, Acyclic)]
@@ -286,11 +286,11 @@
 }
 impl fmt::Display for Error {
 	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-		writeln!(f, "{}", self.0 .0)?;
-		for el in &self.0 .1 .0 {
+		writeln!(f, "{}", self.0.0)?;
+		for el in &self.0.1.0 {
 			write!(f, "\t{}", el.desc)?;
 			if let Some(loc) = &el.location {
-				write!(f, "at {}", loc.0 .0 .0)?;
+				write!(f, "at {}", loc.0.0.0)?;
 				loc.0.map_source_locations(&[loc.1, loc.2]);
 			}
 			writeln!(f)?;
modifiedcrates/jrsonnet-evaluator/src/evaluate/compspec.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/compspec.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/compspec.rs
@@ -7,12 +7,12 @@
 	evaluate_field_member_static, evaluate_field_member_unbound,
 };
 use crate::{
+	Context, ContextBuilder, ObjValue, ObjValueBuilder, Pending, Result, Thunk, Val,
 	analyze::{LArrComp, LBind, LCompSpec, LDestruct, LExpr, LFieldMember, LObjComp, LocalId},
 	arr::ArrValue,
 	bail,
 	error::ErrorKind::*,
 	evaluate::evaluate,
-	Context, ContextBuilder, ObjValue, ObjValueBuilder, Pending, Result, Thunk, Val,
 };
 
 trait CompCollector {
modifiedcrates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
@@ -3,10 +3,10 @@
 use jrsonnet_gcmodule::Trace;
 
 use crate::{
+	Context, ContextBuilder, Pending, Result, SupThis, Thunk, Unbound, Val,
 	analyze::{LBind, LDestruct, LDestructField, LDestructRest, LExpr, LocalId},
 	bail,
 	evaluate::evaluate,
-	Context, ContextBuilder, Pending, Result, SupThis, Thunk, Unbound, Val,
 };
 
 #[allow(dead_code, reason = "not dead in exp-destruct")]
@@ -97,7 +97,7 @@
 	use jrsonnet_interner::IStr;
 	use rustc_hash::FxHashSet;
 
-	use crate::{bail, ObjValueBuilder};
+	use crate::{ObjValueBuilder, bail};
 
 	let captured_fields: FxHashSet<IStr> = fields.iter().map(|f| f.name.clone()).collect();
 	let field_names: Vec<(IStr, bool)> = fields
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -11,19 +11,20 @@
 	operator::evaluate_binary_op_special,
 };
 use crate::{
+	Context, Error, ObjValue, ObjValueBuilder, ObjectAssertion, Result, ResultExt as _, SupThis,
+	Unbound, Val,
 	analyze::{
 		LArgsDesc, LAssertStmt, LExpr, LFieldMember, LFieldName, LFunction, LIndexPart, LObjBody,
 		LObjMembers,
 	},
 	bail,
-	error::{suggest_object_fields, ErrorKind::*},
+	error::{ErrorKind::*, suggest_object_fields},
 	evaluate::operator::evaluate_unary_op,
-	function::{prepared::PreparedFuncVal, CallLocation, FuncDesc, FuncVal},
+	function::{CallLocation, FuncDesc, FuncVal, prepared::PreparedFuncVal},
 	in_frame, runtime_error,
 	typed::FromUntyped as _,
 	val::{CachedUnbound, Thunk},
-	with_state, Context, Error, ObjValue, ObjValueBuilder, ObjectAssertion, Result, ResultExt as _,
-	SupThis, Unbound, Val,
+	with_state,
 };
 
 pub mod compspec;
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs
@@ -3,6 +3,7 @@
 use jrsonnet_ir::{BinaryOpType, UnaryOpType};
 
 use crate::{
+	Context, Result, Val,
 	analyze::LExpr,
 	arr::ArrValue,
 	bail, error,
@@ -10,8 +11,7 @@
 	evaluate::evaluate,
 	stdlib::std_format,
 	typed::IntoUntyped as _,
-	val::{equals, StrValue},
-	Context, Result, Val,
+	val::{StrValue, equals},
 };
 
 pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Result<Val> {
modifiedcrates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/mod.rs
+++ b/crates/jrsonnet-evaluator/src/function/mod.rs
@@ -8,13 +8,13 @@
 
 use self::{
 	builtin::Builtin,
-	prepared::{parse_prepared_builtin_call, PreparedCall},
+	prepared::{PreparedCall, parse_prepared_builtin_call},
 };
 use crate::{
+	Context, ContextBuilder, Result, Thunk, Val,
 	analyze::{LDestruct, LExpr, LFunction},
 	evaluate::{destructure::destruct, ensure_sufficient_stack, evaluate, evaluate_trivial},
 	function::builtin::BuiltinFunc,
-	Context, ContextBuilder, Result, Thunk, Val,
 };
 
 pub mod builtin;
@@ -210,8 +210,7 @@
 					return false;
 				}
 				#[allow(irrefutable_let_patterns, reason = "refutable with exp-destruct")]
-				let LDestruct::Full(id) = &param.destruct
-				else {
+				let LDestruct::Full(id) = &param.destruct else {
 					return false;
 				};
 				matches!(&*desc.func.body, LExpr::Local(v) if v == id)
modifiedcrates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/parse.rs
+++ b/crates/jrsonnet-evaluator/src/function/parse.rs
@@ -1,9 +1,9 @@
 use std::rc::Rc;
 
 use crate::{
+	Context, ContextBuilder, Result, Thunk,
 	analyze::LFunction,
 	evaluate::{destructure::destruct, evaluate},
-	Context, ContextBuilder, Result, Thunk,
 };
 
 /// Creates Context with all argument default values applied
modifiedcrates/jrsonnet-evaluator/src/function/prepared.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/prepared.rs
+++ b/crates/jrsonnet-evaluator/src/function/prepared.rs
@@ -5,10 +5,7 @@
 use rustc_hash::FxHashSet;
 
 use super::{CallLocation, FuncVal};
-use crate::{
-	Result, Thunk, Val, bail,
-	error::ErrorKind::*,
-};
+use crate::{Result, Thunk, Val, bail, error::ErrorKind::*};
 
 #[derive(Debug, Trace, Clone)]
 pub struct PreparedFuncVal {
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/integrations/serde.rs
1use std::borrow::Cow;23use jrsonnet_interner::{IBytes, IStr};4use jrsonnet_ir::NumValue;5use serde::{6	de::{self, Visitor},7	ser::{8		Error, SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant, SerializeTuple,9		SerializeTupleStruct, SerializeTupleVariant,10	},11	Deserialize, Serialize, Serializer,12};1314use crate::{15	in_description_frame, runtime_error, Error as JrError, ObjValue, ObjValueBuilder, Result, Val,16};1718impl<'de> Deserialize<'de> for Val {19	fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>20	where21		D: serde::Deserializer<'de>,22	{23		struct ValVisitor;2425		// macro_rules! visit_num {26		// 	($($method:ident => $ty:ty),* $(,)?) => {$(27		// 		fn $method<E>(self, v: $ty) -> Result<Self::Value, E>28		// 		where29		// 			E: serde::de::Error,30		// 		{31		// 			Ok(Val::Num(f64::from(v)))32		// 		}33		// 	)*};34		// }3536		impl<'de> Visitor<'de> for ValVisitor {37			type Value = Val;3839			fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>40			where41				E: de::Error,42			{43				Ok(Val::Bool(v))44			}45			fn visit_f64<E>(self, v: f64) -> Result<Self::Value, E>46			where47				E: de::Error,48			{49				Ok(Val::Num(NumValue::new(v).ok_or_else(|| {50					E::custom("only finite numbers are supported")51				})?))52			}53			fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>54			where55				E: de::Error,56			{57				Ok(Val::string(v))58			}5960			// visit_num! {61			// 	visit_i8 => i8,62			// 	visit_i16 => i16,63			// 	visit_i32 => i32,64			// 	visit_u8 => u8,65			// 	visit_u16 => u16,66			// 	visit_u32 => u32,67			// }68			fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>69			where70				E: de::Error,71			{72				#[expect(73					clippy::cast_precision_loss,74					reason = "this is how it works with stdlib functions"75				)]76				Ok(Val::Num(NumValue::new(v as f64).expect("no overflow")))77			}78			fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>79			where80				E: de::Error,81			{82				#[expect(83					clippy::cast_precision_loss,84					reason = "this is how it works with stdlib functions"85				)]86				Ok(Val::Num(NumValue::new(v as f64).expect("no overflow")))87			}8889			fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>90			where91				E: de::Error,92			{93				Ok(Val::arr(IBytes::from(v)))94			}9596			fn visit_none<E>(self) -> Result<Self::Value, E>97			where98				E: de::Error,99			{100				Ok(Val::Null)101			}102			fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>103			where104				D: serde::Deserializer<'de>,105			{106				deserializer.deserialize_any(self)107			}108109			fn visit_unit<E>(self) -> Result<Self::Value, E>110			where111				E: de::Error,112			{113				Ok(Val::Null)114			}115116			fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>117			where118				D: serde::Deserializer<'de>,119			{120				deserializer.deserialize_any(self)121			}122123			fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>124			where125				A: de::SeqAccess<'de>,126			{127				let mut out = seq.size_hint().map_or_else(Vec::new, Vec::with_capacity);128129				while let Some(val) = seq.next_element::<Val>()? {130					out.push(val);131				}132133				Ok(Val::arr(out))134			}135136			fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>137			where138				A: de::MapAccess<'de>,139			{140				let mut out = map141					.size_hint()142					.map_or_else(ObjValueBuilder::new, ObjValueBuilder::with_capacity);143144				while let Some((k, v)) = map.next_entry::<Cow<'de, str>, Val>()? {145					// Jsonnet ignores duplicate keys146					out.field(k).value(v);147				}148149				Ok(Val::Obj(out.build()))150			}151152			fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {153				write!(formatter, "any valid jsonnet value")154			}155		}156		deserializer.deserialize_any(ValVisitor)157	}158}159160impl Serialize for Val {161	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>162	where163		S: serde::Serializer,164	{165		match self {166			Self::Bool(v) => serializer.serialize_bool(*v),167			Self::Null => serializer.serialize_none(),168			Self::Str(s) => serializer.serialize_str(&s.clone().into_flat()),169			Self::Num(n) => {170				let n = n.get();171				if n.fract() == 0.0 {172					#[expect(173						clippy::cast_possible_truncation,174						reason = "no correct implementation is possible here; expected"175					)]176					let n = n as i64;177					serializer.serialize_i64(n)178				} else {179					serializer.serialize_f64(n)180				}181			}182			#[cfg(feature = "exp-bigint")]183			Self::BigInt(b) => b.serialize(serializer),184			Self::Arr(arr) => {185				let mut seq = serializer.serialize_seq(Some(arr.len() as usize))?;186				for (i, element) in arr.iter().enumerate() {187					let mut serde_error = None;188					in_description_frame(189						|| format!("array index [{i}]"),190						|| {191							let e = element?;192							if let Err(e) = seq.serialize_element(&e) {193								serde_error = Some(e);194							}195							Ok(())196						},197					)198					.map_err(|e| S::Error::custom(e.to_string()))?;199					if let Some(e) = serde_error {200						return Err(e);201					}202				}203				seq.end()204			}205			Self::Obj(obj) => {206				let mut map = serializer.serialize_map(Some(obj.len() as usize))?;207				for (field, value) in obj.iter(208					#[cfg(feature = "exp-preserve-order")]209					true,210				) {211					let mut serde_error = None;212					// TODO: rewrite using try{} after stabilization213					in_description_frame(214						|| format!("object field {field:?}"),215						|| {216							let v = value?;217							if let Err(e) = map.serialize_entry(field.as_str(), &v) {218								serde_error = Some(e);219							}220							Ok(())221						},222					)223					.map_err(|e| S::Error::custom(e.to_string()))?;224					if let Some(e) = serde_error {225						return Err(e);226					}227				}228				map.end()229			}230			Self::Func(_) => Err(S::Error::custom("tried to manifest function")),231		}232	}233}234235struct IntoVecValSerializer {236	variant: Option<IStr>,237	data: Vec<Val>,238}239impl IntoVecValSerializer {240	fn new() -> Self {241		Self {242			variant: None,243			data: Vec::new(),244		}245	}246	fn with_capacity(capacity: usize) -> Self {247		Self {248			variant: None,249			data: Vec::with_capacity(capacity),250		}251	}252	fn variant_with_capacity(variant: impl Into<IStr>, capacity: usize) -> Self {253		Self {254			variant: Some(variant.into()),255			data: Vec::with_capacity(capacity),256		}257	}258}259impl SerializeSeq for IntoVecValSerializer {260	type Ok = Val;261	type Error = JrError;262263	fn serialize_element<T>(&mut self, value: &T) -> Result<()>264	where265		T: ?Sized + Serialize,266	{267		let value = value.serialize(IntoValSerializer)?;268		self.data.push(value);269		Ok(())270	}271272	fn end(self) -> Result<Val> {273		let inner = Val::arr(self.data);274		if let Some(variant) = self.variant {275			let mut out = ObjValue::builder_with_capacity(1);276			out.field(variant).value(inner);277			Ok(Val::Obj(out.build()))278		} else {279			Ok(inner)280		}281	}282}283impl SerializeTuple for IntoVecValSerializer {284	type Ok = Val;285	type Error = JrError;286287	fn serialize_element<T>(&mut self, value: &T) -> Result<()>288	where289		T: ?Sized + Serialize,290	{291		SerializeSeq::serialize_element(self, value)292	}293294	fn end(self) -> Result<Val> {295		SerializeSeq::end(self)296	}297}298impl SerializeTupleVariant for IntoVecValSerializer {299	type Ok = Val;300	type Error = JrError;301302	fn serialize_field<T>(&mut self, value: &T) -> Result<()>303	where304		T: ?Sized + Serialize,305	{306		SerializeSeq::serialize_element(self, value)307	}308309	fn end(self) -> Result<Val> {310		SerializeSeq::end(self)311	}312}313impl SerializeTupleStruct for IntoVecValSerializer {314	type Ok = Val;315	type Error = JrError;316317	fn serialize_field<T>(&mut self, value: &T) -> Result<()>318	where319		T: ?Sized + Serialize,320	{321		SerializeSeq::serialize_element(self, value)322	}323324	fn end(self) -> Result<Val> {325		SerializeSeq::end(self)326	}327}328329struct IntoObjValueSerializer {330	variant: Option<IStr>,331	data: ObjValueBuilder,332	key: Option<IStr>,333}334impl IntoObjValueSerializer {335	fn new() -> Self {336		Self {337			variant: None,338			data: ObjValue::builder(),339			key: None,340		}341	}342	fn with_capacity(capacity: usize) -> Self {343		Self {344			variant: None,345			data: ObjValue::builder_with_capacity(capacity),346			key: None,347		}348	}349	fn variant_with_capacity(variant: impl Into<IStr>, capacity: usize) -> Self {350		Self {351			variant: Some(variant.into()),352			data: ObjValue::builder_with_capacity(capacity),353			key: None,354		}355	}356}357impl SerializeMap for IntoObjValueSerializer {358	type Ok = Val;359	type Error = JrError;360361	fn serialize_key<T>(&mut self, key: &T) -> Result<()>362	where363		T: ?Sized + Serialize,364	{365		let key = key.serialize(IntoValSerializer)?;366		let key = key.to_string()?;367		self.key = Some(key);368		Ok(())369	}370371	fn serialize_value<T>(&mut self, value: &T) -> Result<()>372	where373		T: ?Sized + Serialize,374	{375		let key = self.key.take().expect("no serialize_key called");376		let value = value.serialize(IntoValSerializer)?;377		self.data.field(key).try_value(value)?;378		Ok(())379	}380381	// TODO: serialize_key/serialize_value382	fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<()>383	where384		K: ?Sized + Serialize,385		V: ?Sized + Serialize,386	{387		let key = key.serialize(IntoValSerializer)?;388		let key = key.to_string()?;389		let value = value.serialize(IntoValSerializer)?;390		self.data.field(key).try_value(value)?;391		Ok(())392	}393394	fn end(self) -> Result<Val> {395		let inner = Val::Obj(self.data.build());396		if let Some(variant) = self.variant {397			let mut out = ObjValue::builder_with_capacity(1);398			out.field(variant).value(inner);399			Ok(Val::Obj(out.build()))400		} else {401			Ok(inner)402		}403	}404}405impl SerializeStruct for IntoObjValueSerializer {406	type Ok = Val;407	type Error = JrError;408409	fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>410	where411		T: ?Sized + Serialize,412	{413		SerializeMap::serialize_entry(self, key, value)?;414		Ok(())415	}416417	fn end(self) -> Result<Val> {418		SerializeMap::end(self)419	}420}421impl SerializeStructVariant for IntoObjValueSerializer {422	type Ok = Val;423424	type Error = JrError;425426	fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>427	where428		T: ?Sized + Serialize,429	{430		SerializeMap::serialize_entry(self, key, value)?;431		Ok(())432	}433434	fn end(self) -> Result<Val> {435		SerializeMap::end(self)436	}437}438439struct IntoValSerializer;440impl Serializer for IntoValSerializer {441	type Ok = Val;442443	type Error = JrError;444445	type SerializeSeq = IntoVecValSerializer;446447	type SerializeTuple = IntoVecValSerializer;448449	type SerializeTupleStruct = IntoVecValSerializer;450451	type SerializeTupleVariant = IntoVecValSerializer;452453	type SerializeMap = IntoObjValueSerializer;454455	type SerializeStruct = IntoObjValueSerializer;456457	type SerializeStructVariant = IntoObjValueSerializer;458459	fn serialize_bool(self, v: bool) -> Result<Val> {460		Ok(Val::Bool(v))461	}462463	fn serialize_i8(self, v: i8) -> Result<Val> {464		Ok(Val::Num(v.into()))465	}466467	fn serialize_i16(self, v: i16) -> Result<Val> {468		Ok(Val::Num(v.into()))469	}470471	fn serialize_i32(self, v: i32) -> Result<Val> {472		Ok(Val::Num(v.into()))473	}474475	fn serialize_i64(self, v: i64) -> Result<Val> {476		Ok(Val::Str(v.to_string().into()))477	}478479	fn serialize_u8(self, v: u8) -> Result<Val> {480		Ok(Val::Num(v.into()))481	}482483	fn serialize_u16(self, v: u16) -> Result<Val> {484		Ok(Val::Num(v.into()))485	}486487	fn serialize_u32(self, v: u32) -> Result<Val> {488		Ok(Val::Num(v.into()))489	}490491	fn serialize_u64(self, v: u64) -> Result<Val> {492		Ok(Val::Str(v.to_string().into()))493	}494495	fn serialize_f32(self, v: f32) -> Result<Val> {496		Ok(Val::try_num(f64::from(v))?)497	}498499	fn serialize_f64(self, v: f64) -> Result<Val> {500		Ok(Val::try_num(v)?)501	}502503	fn serialize_char(self, v: char) -> Result<Val> {504		Ok(Val::Str(v.to_string().into()))505	}506507	fn serialize_str(self, v: &str) -> Result<Val> {508		Ok(Val::Str(v.into()))509	}510511	fn serialize_bytes(self, v: &[u8]) -> Result<Val> {512		Ok(Val::arr(IBytes::from(v)))513	}514515	fn serialize_none(self) -> Result<Val> {516		Ok(Val::Null)517	}518519	fn serialize_some<T>(self, value: &T) -> Result<Val>520	where521		T: ?Sized + Serialize,522	{523		value.serialize(self)524	}525526	fn serialize_unit(self) -> Result<Val> {527		Ok(Val::Null)528	}529530	fn serialize_unit_struct(self, _name: &'static str) -> Result<Val> {531		Ok(Val::Null)532	}533534	fn serialize_unit_variant(535		self,536		_name: &'static str,537		_variant_index: u32,538		variant: &'static str,539	) -> Result<Val> {540		Ok(Val::Str(variant.into()))541	}542543	fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> Result<Val>544	where545		T: ?Sized + Serialize,546	{547		value.serialize(self)548	}549550	fn serialize_newtype_variant<T>(551		self,552		_name: &'static str,553		_variant_index: u32,554		variant: &'static str,555		value: &T,556	) -> Result<Val>557	where558		T: ?Sized + Serialize,559	{560		let mut out = ObjValue::builder_with_capacity(1);561		let value = value.serialize(self)?;562		out.field(variant).value(value);563		Ok(Val::Obj(out.build()))564	}565566	fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {567		Ok(len.map_or_else(568			IntoVecValSerializer::new,569			IntoVecValSerializer::with_capacity,570		))571	}572573	fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, Self::Error> {574		Ok(IntoVecValSerializer::with_capacity(len))575	}576577	fn serialize_tuple_struct(578		self,579		_name: &'static str,580		len: usize,581	) -> Result<Self::SerializeTupleStruct, Self::Error> {582		Ok(IntoVecValSerializer::with_capacity(len))583	}584585	fn serialize_tuple_variant(586		self,587		_name: &'static str,588		_variant_index: u32,589		variant: &'static str,590		len: usize,591	) -> Result<Self::SerializeTupleVariant, Self::Error> {592		Ok(IntoVecValSerializer::variant_with_capacity(variant, len))593	}594595	fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {596		Ok(len.map_or_else(597			IntoObjValueSerializer::new,598			IntoObjValueSerializer::with_capacity,599		))600	}601602	fn serialize_struct(603		self,604		_name: &'static str,605		len: usize,606	) -> Result<Self::SerializeStruct, Self::Error> {607		Ok(IntoObjValueSerializer::with_capacity(len))608	}609610	fn serialize_struct_variant(611		self,612		_name: &'static str,613		_variant_index: u32,614		variant: &'static str,615		len: usize,616	) -> Result<Self::SerializeStructVariant, Self::Error> {617		Ok(IntoObjValueSerializer::variant_with_capacity(variant, len))618	}619}620621impl Val {622	pub fn from_serde(v: impl Serialize) -> Result<Self, JrError> {623		v.serialize(IntoValSerializer)624	}625}626627impl serde::ser::Error for JrError {628	fn custom<T>(msg: T) -> Self629	where630		T: std::fmt::Display,631	{632		runtime_error!("serde: {msg}")633	}634}
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -39,7 +39,7 @@
 pub use evaluate::ensure_sufficient_stack;
 use function::CallLocation;
 pub use import::*;
-use jrsonnet_gcmodule::{cc_dyn, Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace, cc_dyn};
 pub use jrsonnet_interner::{IBytes, IStr};
 use jrsonnet_ir::Expr;
 pub use jrsonnet_ir::{NumValue, Source, SourcePath, Span};
modifiedcrates/jrsonnet-evaluator/src/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/manifest.rs
@@ -1,8 +1,7 @@
 use std::{borrow::Cow, fmt::Write, hint::black_box, ptr};
 
 use crate::{
-	bail, evaluate::ensure_sufficient_stack, in_description_frame, Error,
-	Result, ResultExt, Val,
+	Error, Result, ResultExt, Val, bail, evaluate::ensure_sufficient_stack, in_description_frame,
 };
 
 pub trait ManifestFormat {
modifiedcrates/jrsonnet-evaluator/src/obj/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj/mod.rs
+++ b/crates/jrsonnet-evaluator/src/obj/mod.rs
@@ -11,8 +11,8 @@
 };
 
 use educe::Educe;
-use im_rc::{vector, Vector};
-use jrsonnet_gcmodule::{cc_dyn, Acyclic, Cc, Trace, Weak};
+use im_rc::{Vector, vector};
+use jrsonnet_gcmodule::{Acyclic, Cc, Trace, Weak, cc_dyn};
 use jrsonnet_interner::IStr;
 use jrsonnet_ir::Span;
 use rustc_hash::{FxHashMap, FxHashSet};
@@ -23,13 +23,13 @@
 pub use oop::ObjValueBuilder;
 
 use crate::{
+	CcUnbound, MaybeUnbound, Result, Thunk, Unbound, Val,
 	arr::{PickObjectKeyValues, PickObjectValues},
 	bail,
-	error::{suggest_object_fields, ErrorKind::*},
+	error::{ErrorKind::*, suggest_object_fields},
 	evaluate::operator::evaluate_add_op,
 	identity_hash,
 	val::{ArrValue, ThunkValue},
-	CcUnbound, MaybeUnbound, Result, Thunk, Unbound, Val,
 };
 
 #[cfg(not(feature = "exp-preserve-order"))]
modifiedcrates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/trace/mod.rs
+++ b/crates/jrsonnet-evaluator/src/trace/mod.rs
@@ -10,7 +10,7 @@
 #[cfg(feature = "explaining-traces")]
 use jrsonnet_ir::Span;
 
-use crate::{error::ErrorKind, Error};
+use crate::{Error, error::ErrorKind};
 
 /// The way paths should be displayed
 #[derive(Clone, Trace)]
@@ -259,7 +259,7 @@
 		struct ResetData {
 			loc: Span,
 		}
-		use hi_doc::{source_to_ansi, Formatting, SnippetBuilder, Text};
+		use hi_doc::{Formatting, SnippetBuilder, Text, source_to_ansi};
 
 		write!(out, "{}", error.error())?;
 		if let ErrorKind::ImportSyntaxError { path, error } = error.error() {
@@ -277,14 +277,15 @@
 			use crate::analyze::DiagLevel;
 			let mut builder: Option<SnippetBuilder> = None;
 			let mut current_src: Option<&str> = None;
-			let flush =
-				|builder: Option<SnippetBuilder>, out: &mut dyn std::fmt::Write| -> Result<(), std::fmt::Error> {
-					if let Some(b) = builder {
-						let ansi = source_to_ansi(&b.build());
-						write!(out, "\n{}", ansi.trim_end())?;
-					}
-					Ok(())
-				};
+			let flush = |builder: Option<SnippetBuilder>,
+			             out: &mut dyn std::fmt::Write|
+			 -> Result<(), std::fmt::Error> {
+				if let Some(b) = builder {
+					let ansi = source_to_ansi(&b.build());
+					write!(out, "\n{}", ansi.trim_end())?;
+				}
+				Ok(())
+			};
 			for diag in diagnostics {
 				if let Some(span) = &diag.span {
 					let src = span.0.code();
@@ -295,14 +296,12 @@
 					}
 					let b = builder.as_mut().unwrap();
 					let ab = match diag.level {
-						DiagLevel::Error => b.error(Text::fragment(
-							diag.message.clone(),
-							Formatting::default(),
-						)),
-						DiagLevel::Warning => b.warning(Text::fragment(
-							diag.message.clone(),
-							Formatting::default(),
-						)),
+						DiagLevel::Error => {
+							b.error(Text::fragment(diag.message.clone(), Formatting::default()))
+						}
+						DiagLevel::Warning => {
+							b.warning(Text::fragment(diag.message.clone(), Formatting::default()))
+						}
 					};
 					ab.range(span.range()).build();
 				} else {
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -17,7 +17,13 @@
 
 pub use crate::arr::{ArrValue, ArrayLike};
 use crate::{
-	NumValue, ObjValue, Result, SupThis, Unbound, WeakSupThis, bail, error::{Error, ErrorKind::*}, evaluate::operator::{evaluate_compare_op, evaluate_mod_op}, function::FuncVal, gc::WithCapacityExt as _, manifest::{ManifestFormat, ToStringFormat}, typed::BoundedUsize
+	NumValue, ObjValue, Result, SupThis, Unbound, WeakSupThis, bail,
+	error::{Error, ErrorKind::*},
+	evaluate::operator::{evaluate_compare_op, evaluate_mod_op},
+	function::FuncVal,
+	gc::WithCapacityExt as _,
+	manifest::{ManifestFormat, ToStringFormat},
+	typed::BoundedUsize,
 };
 
 pub trait ThunkValue: Trace {
modifiedcrates/jrsonnet-ir-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-ir-parser/src/lib.rs
+++ b/crates/jrsonnet-ir-parser/src/lib.rs
@@ -1,11 +1,11 @@
 use jrsonnet_gcmodule::Acyclic;
 use jrsonnet_ir::{
-	unescape, ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BinaryOpType, BindSpec, CompSpec,
-	Destruct, Expr, ExprParam, ExprParams, FieldMember, FieldName, ForSpecData, IStr, IfElse,
-	IfSpecData, ImportKind, IndexPart, LiteralType, Member, NumValue, ObjBody, ObjComp, ObjMembers,
-	Slice, SliceDesc, Source, Span, Spanned, UnaryOpType, Visibility,
+	ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BinaryOpType, BindSpec, CompSpec, Destruct, Expr,
+	ExprParam, ExprParams, FieldMember, FieldName, ForSpecData, IStr, IfElse, IfSpecData,
+	ImportKind, IndexPart, LiteralType, Member, NumValue, ObjBody, ObjComp, ObjMembers, Slice,
+	SliceDesc, Source, Span, Spanned, UnaryOpType, Visibility, unescape,
 };
-use jrsonnet_lexer::{collect_lexed_str_block, Lexeme, Lexer, Span as LexSpan, SyntaxKind, T};
+use jrsonnet_lexer::{Lexeme, Lexer, Span as LexSpan, SyntaxKind, T, collect_lexed_str_block};
 
 pub struct ParserSettings {
 	pub source: Source,
modifiedcrates/jrsonnet-ir/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-ir/src/expr.rs
+++ b/crates/jrsonnet-ir/src/expr.rs
@@ -7,9 +7,9 @@
 use jrsonnet_interner::IStr;
 
 use crate::{
+	NumValue,
 	function::{FunctionSignature, ParamDefault, ParamName, ParamParse},
 	source::Source,
-	NumValue,
 };
 
 #[derive(Debug, PartialEq, Acyclic)]
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-macros/src/lib.rs
+++ b/crates/jrsonnet-macros/src/lib.rs
@@ -3,14 +3,13 @@
 use proc_macro2::TokenStream;
 use quote::{quote, quote_spanned};
 use syn::{
-	parenthesized,
+	Attribute, DeriveInput, Error, Expr, ExprClosure, FnArg, GenericArgument, Ident, ItemFn,
+	LitStr, Meta, Pat, Path, PathArguments, Result, ReturnType, Token, Type, parenthesized,
 	parse::{Parse, ParseStream},
 	parse_macro_input,
 	punctuated::Punctuated,
 	spanned::Spanned,
 	token::Comma,
-	Attribute, DeriveInput, Error, Expr, ExprClosure, FnArg, GenericArgument, Ident, ItemFn,
-	LitStr, Meta, Pat, Path, PathArguments, Result, ReturnType, Token, Type,
 };
 
 use self::typed::{derive_from_untyped_inner, derive_into_untyped_inner, derive_typed_inner};
modifiedcrates/jrsonnet-stdlib/src/arrays.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/arrays.rs
+++ b/crates/jrsonnet-stdlib/src/arrays.rs
@@ -1,12 +1,11 @@
 #![allow(non_snake_case)]
 
 use jrsonnet_evaluator::{
-	bail, error,
-	function::{builtin, NativeFn},
+	Either, IStr, ObjValue, ObjValueBuilder, Result, ResultExt, Thunk, Val, bail, error,
+	function::{NativeFn, builtin},
 	runtime_error,
 	typed::{BoundedUsize, Either2, FromUntyped},
-	val::{equals, ArrValue, IndexableVal},
-	Either, IStr, ObjValue, ObjValueBuilder, Result, ResultExt, Thunk, Val,
+	val::{ArrValue, IndexableVal, equals},
 };
 
 pub fn eval_on_empty(on_empty: Option<Thunk<Val>>) -> Result<Val> {
modifiedcrates/jrsonnet-stdlib/src/compat.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/compat.rs
+++ b/crates/jrsonnet-stdlib/src/compat.rs
@@ -1,6 +1,6 @@
 use std::cmp::Ordering;
 
-use jrsonnet_evaluator::{function::builtin, val::ArrValue, Result, Val};
+use jrsonnet_evaluator::{Result, Val, function::builtin, val::ArrValue};
 
 #[builtin]
 #[allow(non_snake_case)]
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -12,7 +12,12 @@
 pub use encoding::*;
 pub use hash::*;
 use jrsonnet_evaluator::{
-	IStr, InitialContextBuilder, NumValue, ObjValue, ObjValueBuilder, Source, Thunk, Val, error::Result, function::{CallLocation, FuncVal, builtin_id}, tla::TlaArg, trace::PathResolver, typed::SerializeTypedObj as _
+	IStr, InitialContextBuilder, NumValue, ObjValue, ObjValueBuilder, Source, Thunk, Val,
+	error::Result,
+	function::{CallLocation, FuncVal, builtin_id},
+	tla::TlaArg,
+	trace::PathResolver,
+	typed::SerializeTypedObj as _,
 };
 use jrsonnet_gcmodule::{Acyclic, Cc, Trace};
 use jrsonnet_macros::{IntoUntyped, Typed};
modifiedcrates/jrsonnet-stdlib/src/manifest/toml.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/manifest/toml.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/toml.rs
@@ -1,7 +1,10 @@
 use std::borrow::Cow;
 
 use jrsonnet_evaluator::{
-	Error, IStr, ObjValue, Result, ResultExt, Val, bail, ensure_sufficient_stack, in_description_frame, manifest::{ManifestFormat, escape_string_json_buf}, val::ArrValue
+	Error, IStr, ObjValue, Result, ResultExt, Val, bail, ensure_sufficient_stack,
+	in_description_frame,
+	manifest::{ManifestFormat, escape_string_json_buf},
+	val::ArrValue,
 };
 
 pub struct TomlFormat<'s> {
@@ -218,14 +221,16 @@
 		}
 		first = false;
 		path.push(k.clone());
-		ensure_sufficient_stack(|| in_description_frame(
-			|| format!("section <{k}> manifestification"),
-			|| match v {
-				Val::Obj(obj) => manifest_table(&obj, path, buf, cur_padding, options),
-				Val::Arr(arr) => manifest_table_array(&arr, path, buf, cur_padding, options),
-				_ => unreachable!("iterating over sections"),
-			},
-		))?;
+		ensure_sufficient_stack(|| {
+			in_description_frame(
+				|| format!("section <{k}> manifestification"),
+				|| match v {
+					Val::Obj(obj) => manifest_table(&obj, path, buf, cur_padding, options),
+					Val::Arr(arr) => manifest_table_array(&arr, path, buf, cur_padding, options),
+					_ => unreachable!("iterating over sections"),
+				},
+			)
+		})?;
 		path.pop();
 	}
 	Ok(())
modifiedcrates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/misc.rs
+++ b/crates/jrsonnet-stdlib/src/misc.rs
@@ -1,13 +1,12 @@
 use std::{cell::RefCell, collections::BTreeSet};
 
 use jrsonnet_evaluator::{
-	bail,
+	Either, IStr, ObjValue, ObjValueBuilder, ResultExt, Thunk, Val, bail,
 	error::{ErrorKind::*, Result},
-	function::{builtin, CallLocation, FuncVal},
+	function::{CallLocation, FuncVal, builtin},
 	manifest::JsonFormat,
 	typed::{Either2, Either4},
-	val::{equals, ArrValue},
-	Either, IStr, ObjValue, ObjValueBuilder, ResultExt, Thunk, Val,
+	val::{ArrValue, equals},
 };
 use jrsonnet_gcmodule::Cc;
 
modifiedcrates/jrsonnet-stdlib/src/operator.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/operator.rs
+++ b/crates/jrsonnet-stdlib/src/operator.rs
@@ -2,11 +2,11 @@
 //! However, in our case we instead implement them in native, and implement native functions on top of core for backwards compatibility
 
 use jrsonnet_evaluator::{
+	IStr, NumValue, Result, Val,
 	function::builtin,
 	stdlib::std_format,
 	typed::{Either, Either2},
 	val::{equals, primitive_equals},
-	IStr, NumValue, Result, Val,
 };
 
 #[builtin]
modifiedcrates/jrsonnet-stdlib/src/sets.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/sets.rs
+++ b/crates/jrsonnet-stdlib/src/sets.rs
@@ -1,6 +1,6 @@
 use std::cmp::Ordering;
 
-use jrsonnet_evaluator::{function::builtin, val::ArrValue, Result, Thunk, Val};
+use jrsonnet_evaluator::{Result, Thunk, Val, function::builtin, val::ArrValue};
 
 use crate::keyf::KeyF;
 
modifiedcrates/jrsonnet-stdlib/src/sort.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/sort.rs
+++ b/crates/jrsonnet-stdlib/src/sort.rs
@@ -3,10 +3,9 @@
 use std::cmp::Ordering;
 
 use jrsonnet_evaluator::{
-	bail,
+	Result, Thunk, Val, bail,
 	function::builtin,
-	val::{equals, ArrValue},
-	Result, Thunk, Val,
+	val::{ArrValue, equals},
 };
 
 use crate::{eval_on_empty, keyf::KeyF};
modifiedtests/tests/builtin.rsdiffbeforeafterboth
--- a/tests/tests/builtin.rs
+++ b/tests/tests/builtin.rs
@@ -1,7 +1,11 @@
 mod common;
 
 use jrsonnet_evaluator::{
-	ContextInitializer, FileImportResolver, InitialContextBuilder, Result, Source, State, Thunk, Val, function::{CallLocation, FuncVal, builtin, builtin::{Builtin}}, trace::PathResolver, typed::FromUntyped
+	ContextInitializer, FileImportResolver, InitialContextBuilder, Result, Source, State, Thunk,
+	Val,
+	function::{CallLocation, FuncVal, builtin, builtin::Builtin},
+	trace::PathResolver,
+	typed::FromUntyped,
 };
 use jrsonnet_gcmodule::Trace;
 use jrsonnet_stdlib::ContextInitializer as StdContextInitializer;
modifiedtests/tests/common.rsdiffbeforeafterboth
--- a/tests/tests/common.rs
+++ b/tests/tests/common.rs
@@ -1,5 +1,7 @@
 use jrsonnet_evaluator::{
-	ContextBuilder, ContextInitializer as ContextInitializerT, InitialContextBuilder, ObjValueBuilder, Result, Thunk, Val, bail, function::{FuncVal, builtin}, Source
+	ContextBuilder, ContextInitializer as ContextInitializerT, InitialContextBuilder,
+	ObjValueBuilder, Result, Source, Thunk, Val, bail,
+	function::{FuncVal, builtin},
 };
 use jrsonnet_gcmodule::Trace;