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
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -3,16 +3,16 @@
 use jrsonnet_interner::{IBytes, IStr};
 use jrsonnet_ir::NumValue;
 use serde::{
+	Deserialize, Serialize, Serializer,
 	de::{self, Visitor},
 	ser::{
 		Error, SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant, SerializeTuple,
 		SerializeTupleStruct, SerializeTupleVariant,
 	},
-	Deserialize, Serialize, Serializer,
 };
 
 use crate::{
-	in_description_frame, runtime_error, Error as JrError, ObjValue, ObjValueBuilder, Result, Val,
+	Error as JrError, ObjValue, ObjValueBuilder, Result, Val, in_description_frame, runtime_error,
 };
 
 impl<'de> Deserialize<'de> for Val {
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
after · crates/jrsonnet-stdlib/src/misc.rs
1use std::{cell::RefCell, collections::BTreeSet};23use jrsonnet_evaluator::{4	Either, IStr, ObjValue, ObjValueBuilder, ResultExt, Thunk, Val, bail,5	error::{ErrorKind::*, Result},6	function::{CallLocation, FuncVal, builtin},7	manifest::JsonFormat,8	typed::{Either2, Either4},9	val::{ArrValue, equals},10};11use jrsonnet_gcmodule::Cc;1213use crate::Settings;1415#[builtin]16pub fn builtin_length(x: Either![IStr, ArrValue, ObjValue, FuncVal]) -> u32 {17	use Either4::*;18	match x {19		A(x) => x.chars().count() as u32,20		B(x) => x.len(),21		C(x) => x.len(),22		D(f) => f.params_len(),23	}24}2526#[builtin]27pub fn builtin_get(28	o: ObjValue,29	f: IStr,30	default: Option<Thunk<Val>>,31	#[default(true)] inc_hidden: bool,32) -> Result<Val> {33	let do_default = move || {34		let Some(default) = default else {35			return Ok(Val::Null);36		};37		default.evaluate()38	};39	// Happy path for invisible fields40	if !inc_hidden && !o.has_field_ex(f.clone(), false) {41		return do_default();42	}43	let Some(v) = o.get(f)? else {44		return do_default();45	};46	Ok(v)47}4849#[builtin(fields(50	settings: Cc<RefCell<Settings>>,51))]52pub fn builtin_ext_var(this: &builtin_ext_var, x: IStr) -> Result<Val> {53	this.settings54		.borrow()55		.ext_vars56		.get(&x)57		.cloned()58		.ok_or_else(|| UndefinedExternalVariable(x))?59		.evaluate_tailstrict()60}6162#[builtin(fields(63	settings: Cc<RefCell<Settings>>,64))]65pub fn builtin_native(this: &builtin_native, x: IStr) -> Val {66	this.settings67		.borrow()68		.ext_natives69		.get(&x)70		.cloned()71		.map_or(Val::Null, Val::Func)72}7374#[builtin(fields(75	settings: Cc<RefCell<Settings>>,76))]77pub fn builtin_trace(78	this: &builtin_trace,79	loc: CallLocation,80	str: Val,81	rest: Option<Thunk<Val>>,82) -> Result<Val> {83	this.settings.borrow().trace_printer.print_trace(84		loc,85		match &str {86			Val::Str(s) => s.clone().into_flat(),87			Val::Func(f) => format!("{f:?}").into(),88			v => v.manifest(JsonFormat::debug())?.into(),89		},90	);91	rest.map_or_else(|| Ok(str), |rest| rest.evaluate())92}9394#[allow(clippy::comparison_chain)]95#[builtin]96pub fn builtin_starts_with(a: Either![IStr, ArrValue], b: Either![IStr, ArrValue]) -> Result<bool> {97	Ok(match (a, b) {98		(Either2::A(a), Either2::A(b)) => a.starts_with(b.as_str()),99		(Either2::B(a), Either2::B(b)) => {100			if b.len() > a.len() {101				return Ok(false);102			} else if b.len() == a.len() {103				return equals(&Val::Arr(a), &Val::Arr(b));104			}105			for (a, b) in a.iter().take(b.len() as usize).zip(b.iter()) {106				let a = a?;107				let b = b?;108				if !equals(&a, &b)? {109					return Ok(false);110				}111			}112			true113		}114		_ => bail!("both arguments should be of the same type"),115	})116}117118#[allow(clippy::comparison_chain)]119#[builtin]120pub fn builtin_ends_with(a: Either![IStr, ArrValue], b: Either![IStr, ArrValue]) -> Result<bool> {121	Ok(match (a, b) {122		(Either2::A(a), Either2::A(b)) => a.ends_with(b.as_str()),123		(Either2::B(a), Either2::B(b)) => {124			if b.len() > a.len() {125				return Ok(false);126			} else if b.len() == a.len() {127				return equals(&Val::Arr(a), &Val::Arr(b));128			}129			let a_len = a.len();130			for (a, b) in a.iter().skip((a_len - b.len()) as usize).zip(b.iter()) {131				let a = a?;132				let b = b?;133				if !equals(&a, &b)? {134					return Ok(false);135				}136			}137			true138		}139		_ => bail!("both arguments should be of the same type"),140	})141}142143#[builtin]144pub fn builtin_assert_equal(a: Val, b: Val) -> Result<bool> {145	if equals(&a, &b)? {146		return Ok(true);147	}148	// TODO: Use debug output format149	let format = JsonFormat::std_to_json(150		"  ".to_owned(),151		"\n",152		": ",153		#[cfg(feature = "exp-preserve-order")]154		true,155	);156	let a = if let Some(a) = a.as_str() {157		format!("<A>\n{a}\n</A>")158	} else {159		a.manifest(&format).description("<a> manifestification")?160	};161	let b = if let Some(b) = b.as_str() {162		format!("<B>\n{b}\n</B>")163	} else {164		b.manifest(&format).description("<b> manifestification")?165	};166	bail!("assertion failed: A != B\nA: {a}\nB: {b}")167}168169#[builtin]170pub fn builtin_merge_patch(target: Val, patch: Val) -> Result<Val> {171	let Some(patch) = patch.as_obj() else {172		return Ok(patch);173	};174	let target = target.as_obj().unwrap_or_else(ObjValue::empty);175	let target_fields = target176		.fields(177			// FIXME: Makes no sense to preserve order for BTreeSet, it would be better to use IndexSet here?178			// But IndexSet won't allow fast ordered union...179			// // Makes sense to preserve source ordering where possible.180			// // May affect evaluation order, but it is not specified by jsonnet spec.181			// #[cfg(feature = "exp-preserve-order")]182			// true,183			#[cfg(feature = "exp-preserve-order")]184			false,185		)186		.into_iter()187		.collect::<BTreeSet<IStr>>();188	let patch_fields = patch189		.fields(190			// No need to look at the patch field order, I think?191			// New fields (that will be appended at the end) will be alphabeticaly-ordered,192			// but it is fine for jsonpatch, I don't think people write jsonpatch in jsonnet,193			// when they can use mixins.194			#[cfg(feature = "exp-preserve-order")]195			false,196		)197		.into_iter()198		.collect::<BTreeSet<IStr>>();199200	let mut out = ObjValueBuilder::new();201	for field in target_fields.union(&patch_fields) {202		let Some(field_patch) = patch.get(field.clone())? else {203			// All lazy fields might be unified into a single filtered object core instead of creating a thunk per, but this implementation is good enough.204			let target_field = target.get_lazy(field.clone()).expect(205				"we're iterating over fields union, if field is missing in patch - it exists in target",206			);207			out.field(field.clone()).thunk(target_field);208			continue;209		};210		if matches!(field_patch, Val::Null) {211			continue;212		}213		let field_target = target.get(field.clone())?.unwrap_or(Val::Null);214		out.field(field.clone())215			.value(builtin_merge_patch(field_target, field_patch)?);216	}217	Ok(out.build().into())218}
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;