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
before · crates/jrsonnet-ir/src/expr.rs
1use std::{2	fmt::{self, Debug, Display},3	ops::{Deref, RangeInclusive},4};56use jrsonnet_gcmodule::Acyclic;7use jrsonnet_interner::IStr;89use crate::{10	function::{FunctionSignature, ParamDefault, ParamName, ParamParse},11	source::Source,12	NumValue,13};1415#[derive(Debug, PartialEq, Acyclic)]16pub enum FieldName {17	/// {fixed: 2}18	Fixed(IStr),19	/// {["dyn"+"amic"]: 3}20	Dyn(Expr),21}2223#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]24#[repr(u8)]25pub enum Visibility {26	/// :27	Normal,28	/// ::29	Hidden,30	/// :::31	Unhide,32}3334impl Visibility {35	pub fn is_visible(&self) -> bool {36		matches!(self, Self::Normal | Self::Unhide)37	}38}3940#[derive(Debug, PartialEq, Acyclic)]41pub struct AssertStmt {42	pub assertion: Spanned<Expr>,43	pub message: Option<Expr>,44}4546#[derive(Debug, PartialEq, Acyclic)]47pub struct FieldMember {48	pub name: Spanned<FieldName>,49	pub plus: bool,50	pub params: Option<ExprParams>,51	pub visibility: Visibility,52	pub value: Expr,53}5455#[derive(Debug, PartialEq, Acyclic)]56pub enum Member {57	Field(FieldMember),58	BindStmt(BindSpec),59	AssertStmt(AssertStmt),60}6162#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]63pub enum UnaryOpType {64	Plus,65	Minus,66	BitNot,67	Not,68}6970impl Display for UnaryOpType {71	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {72		use UnaryOpType::*;73		write!(74			f,75			"{}",76			match self {77				Plus => "+",78				Minus => "-",79				BitNot => "~",80				Not => "!",81			}82		)83	}84}8586#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]87pub enum BinaryOpType {88	Mul,89	Div,9091	/// Implemented as intrinsic, put here for completeness92	Mod,9394	Add,95	Sub,9697	Lhs,98	Rhs,99100	Lt,101	Gt,102	Lte,103	Gte,104105	BitAnd,106	BitOr,107	BitXor,108109	Eq,110	Neq,111112	And,113	Or,114	#[cfg(feature = "exp-null-coaelse")]115	NullCoaelse,116117	// Equialent to std.objectHasEx(a, b, true)118	In,119}120121impl Display for BinaryOpType {122	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {123		use BinaryOpType::*;124		write!(125			f,126			"{}",127			match self {128				Mul => "*",129				Div => "/",130				Mod => "%",131				Add => "+",132				Sub => "-",133				Lhs => "<<",134				Rhs => ">>",135				Lt => "<",136				Gt => ">",137				Lte => "<=",138				Gte => ">=",139				BitAnd => "&",140				BitOr => "|",141				BitXor => "^",142				Eq => "==",143				Neq => "!=",144				And => "&&",145				Or => "||",146				In => "in",147				#[cfg(feature = "exp-null-coaelse")]148				NullCoaelse => "??",149			}150		)151	}152}153154/// name, default value155#[derive(Debug, PartialEq, Acyclic)]156pub struct ExprParam {157	pub destruct: Destruct,158	pub default: Option<Expr>,159}160161/// Defined function parameters162#[derive(Debug, PartialEq, Acyclic)]163pub struct ExprParams {164	pub exprs: Vec<ExprParam>,165	pub signature: FunctionSignature,166	pub(crate) binds_len: usize,167}168impl ExprParams {169	pub fn len(&self) -> usize {170		self.exprs.len()171	}172	pub fn is_empty(&self) -> bool {173		self.exprs.is_empty()174	}175176	pub fn binds_len(&self) -> usize {177		self.binds_len178	}179	pub fn new(exprs: Vec<ExprParam>) -> Self {180		Self {181			signature: FunctionSignature::new(182				exprs183					.iter()184					.map(|p| {185						ParamParse::new(186							p.destruct.name(),187							ParamDefault::exists(p.default.is_some()),188						)189					})190					.collect(),191			),192			binds_len: exprs.iter().map(|v| v.destruct.binds_len()).sum(),193			exprs,194		}195	}196}197198#[derive(Debug, PartialEq, Acyclic)]199pub struct ArgsDesc {200	pub unnamed: Vec<Expr>,201	pub names: Vec<IStr>,202	pub values: Vec<Expr>,203}204impl ArgsDesc {205	pub fn new(unnamed: Vec<Expr>, names: Vec<IStr>, values: Vec<Expr>) -> Self {206		Self {207			unnamed,208			names,209			values,210		}211	}212}213214#[derive(Debug, Clone, PartialEq, Eq, Acyclic)]215pub enum DestructRest {216	/// ...rest217	Keep(IStr),218	/// ...219	Drop,220}221222#[derive(Debug, Clone, PartialEq, Acyclic)]223pub enum Destruct {224	Full(Spanned<IStr>),225	#[cfg(feature = "exp-destruct")]226	Skip,227	#[cfg(feature = "exp-destruct")]228	Array {229		start: Vec<Destruct>,230		rest: Option<DestructRest>,231		end: Vec<Destruct>,232	},233	#[cfg(feature = "exp-destruct")]234	Object {235		#[allow(clippy::type_complexity)]236		fields: Vec<(IStr, Option<Destruct>, Option<Rc<Spanned<Expr>>>)>,237		rest: Option<DestructRest>,238	},239}240impl Destruct {241	/// Name of destructure, used for function parameter names242	pub fn name(&self) -> ParamName {243		match self {244			Self::Full(name) => ParamName::Named(name.value.clone()),245			#[cfg(feature = "exp-destruct")]246			_ => ParamName::Unnamed,247		}248	}249	pub fn binds_len(&self) -> usize {250		#[cfg(feature = "exp-destruct")]251		fn cap_rest(rest: &Option<DestructRest>) -> usize {252			match rest {253				Some(DestructRest::Keep(_)) => 1,254				Some(DestructRest::Drop) => 0,255				None => 0,256			}257		}258		match self {259			Self::Full(_) => 1,260			#[cfg(feature = "exp-destruct")]261			Self::Skip => 0,262			#[cfg(feature = "exp-destruct")]263			Self::Array { start, rest, end } => {264				start.iter().map(Destruct::binds_len).sum::<usize>()265					+ end.iter().map(Destruct::binds_len).sum::<usize>()266					+ cap_rest(rest)267			}268			#[cfg(feature = "exp-destruct")]269			Self::Object { fields, rest } => {270				let mut out = 0;271				for (_, into, _) in fields {272					match into {273						Some(v) => out += v.binds_len(),274						// Field is destructured to default name275						None => out += 1,276					}277				}278				out + cap_rest(rest)279			}280		}281	}282}283284#[derive(Debug, PartialEq, Acyclic)]285pub enum BindSpec {286	Field {287		into: Destruct,288		value: Expr,289	},290	Function {291		name: IStr,292		params: ExprParams,293		value: Expr,294	},295}296impl BindSpec {297	pub fn binds_len(&self) -> usize {298		match self {299			BindSpec::Field { into, .. } => into.binds_len(),300			BindSpec::Function { .. } => 1,301		}302	}303}304305#[derive(Debug, PartialEq, Acyclic)]306pub struct IfSpecData {307	pub span: Span,308	pub cond: Expr,309}310311#[derive(Debug, PartialEq, Acyclic)]312pub struct ForSpecData {313	pub destruct: Destruct,314	pub over: Expr,315}316317#[derive(Debug, PartialEq, Acyclic)]318pub enum CompSpec {319	IfSpec(IfSpecData),320	ForSpec(ForSpecData),321}322323#[derive(Debug, PartialEq, Acyclic)]324pub struct ObjComp {325	pub locals: Vec<BindSpec>,326	pub field: Box<FieldMember>,327	pub compspecs: Vec<CompSpec>,328}329330#[derive(Debug, PartialEq, Acyclic)]331pub struct ObjMembers {332	pub locals: Vec<BindSpec>,333	pub asserts: Vec<AssertStmt>,334	pub fields: Vec<FieldMember>,335}336337#[derive(Debug, PartialEq, Acyclic)]338pub enum ObjBody {339	MemberList(ObjMembers),340	ObjComp(ObjComp),341}342343#[derive(Debug, PartialEq, Eq, Clone, Copy, Acyclic)]344pub enum LiteralType {345	This,346	Super,347	Dollar,348	Null,349	True,350	False,351}352353#[derive(Debug, PartialEq, Acyclic)]354pub struct SliceDesc {355	pub start: Option<Spanned<Expr>>,356	pub end: Option<Spanned<Expr>>,357	pub step: Option<Spanned<Expr>>,358}359360#[derive(Debug, PartialEq, Acyclic)]361pub struct AssertExpr {362	pub assert: AssertStmt,363	pub rest: Expr,364}365366#[derive(Debug, PartialEq, Acyclic)]367pub struct BinaryOp {368	pub lhs: Expr,369	pub op: BinaryOpType,370	pub rhs: Expr,371}372373#[derive(Debug, PartialEq, Acyclic, Clone, Copy)]374pub enum ImportKind {375	Normal,376	Str,377	Bin,378}379380#[derive(Debug, PartialEq, Acyclic)]381pub struct IfElse {382	pub cond: IfSpecData,383	pub cond_then: Expr,384	pub cond_else: Option<Expr>,385}386387#[derive(Debug, PartialEq, Acyclic)]388pub struct Slice {389	pub value: Expr,390	pub slice: SliceDesc,391}392393/// Syntax base394#[derive(Debug, PartialEq, Acyclic)]395pub enum Expr {396	Literal(LiteralType),397398	/// String value: "hello"399	Str(IStr),400	/// Number: 1, 2.0, 2e+20401	Num(NumValue),402	/// Variable name: test403	Var(Spanned<IStr>),404405	/// Array of expressions: [1, 2, "Hello"]406	Arr(Vec<Expr>),407	/// Array comprehension:408	/// ```jsonnet409	///  ingredients: [410	///    { kind: kind, qty: 4 / 3 }411	///    for kind in [412	///      'Honey Syrup',413	///      'Lemon Juice',414	///      'Farmers Gin',415	///    ]416	///  ],417	/// ```418	ArrComp(Box<Expr>, Vec<CompSpec>),419420	/// Object: {a: 2}421	Obj(ObjBody),422	/// Object extension: var1 {b: 2}423	ObjExtend(Box<Expr>, ObjBody),424425	/// -2426	UnaryOp(UnaryOpType, Box<Expr>),427	/// 2 - 2428	BinaryOp(Box<BinaryOp>),429	/// assert 2 == 2 : "Math is broken"430	AssertExpr(Box<AssertExpr>),431	/// local a = 2; { b: a }432	LocalExpr(Vec<BindSpec>, Box<Expr>),433434	/// import* "hello"435	Import(Spanned<ImportKind>, Box<Expr>),436	/// error "I'm broken"437	ErrorStmt(Span, Box<Expr>),438	/// a(b, c)439	Apply(Box<Expr>, Spanned<ArgsDesc>, bool),440	/// a[b], a.b, a?.b441	Index {442		indexable: Box<Expr>,443		parts: Vec<IndexPart>,444	},445	/// function(x) x446	Function(ExprParams, Box<Expr>),447	/// if true == false then 1 else 2448	IfElse(Box<IfElse>),449	Slice(Box<Slice>),450}451452#[derive(Debug, PartialEq, Acyclic)]453pub struct IndexPart {454	pub span: Span,455	pub value: Expr,456	#[cfg(feature = "exp-null-coaelse")]457	pub null_coaelse: bool,458}459460/// file, begin offset, end offset461#[derive(Clone, PartialEq, Eq, Acyclic)]462#[repr(C)]463pub struct Span(pub Source, pub u32, pub u32);464impl Span {465	pub fn belongs_to(&self, other: &Span) -> bool {466		other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2467	}468	pub fn range(&self) -> RangeInclusive<usize> {469		let start = self.1;470		let mut end = self.2;471		if end > start {472			// Because it is originally exclusive473			end -= 1;474		}475		start as usize..=end as usize476	}477}478479#[cfg(target_pointer_width = "64")]480static_assertions::assert_eq_size!(Span, (usize, usize));481482impl Debug for Span {483	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {484		write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)485	}486}487488#[derive(Clone, PartialEq, Acyclic)]489pub struct Spanned<T: Acyclic> {490	pub value: T,491	pub span: Span,492}493impl<T: Acyclic> Deref for Spanned<T> {494	type Target = T;495	fn deref(&self) -> &Self::Target {496		&self.value497	}498}499impl<T: Acyclic> Spanned<T> {500	#[inline]501	pub fn new(value: T, span: Span) -> Self {502		Self { value, span }503	}504	pub fn map<U: Acyclic>(self, v: impl FnOnce(T) -> U) -> Spanned<U> {505		Spanned {506			span: self.span,507			value: v(self.value),508		}509	}510	pub fn as_ref<'a>(&'a self) -> Spanned<&'a T>511	where512		&'a T: Acyclic,513	{514		Spanned {515			span: self.span.clone(),516			value: &self.value,517		}518	}519}520521impl<T: Debug + Acyclic> Debug for Spanned<T> {522	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {523		let expr = &**self;524		if f.alternate() {525			write!(f, "{:#?}", expr)?;526		} else {527			write!(f, "{:?}", expr)?;528		}529		write!(f, " from {:?}", self.span)?;530		Ok(())531	}532}
after · crates/jrsonnet-ir/src/expr.rs
1use std::{2	fmt::{self, Debug, Display},3	ops::{Deref, RangeInclusive},4};56use jrsonnet_gcmodule::Acyclic;7use jrsonnet_interner::IStr;89use crate::{10	NumValue,11	function::{FunctionSignature, ParamDefault, ParamName, ParamParse},12	source::Source,13};1415#[derive(Debug, PartialEq, Acyclic)]16pub enum FieldName {17	/// {fixed: 2}18	Fixed(IStr),19	/// {["dyn"+"amic"]: 3}20	Dyn(Expr),21}2223#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]24#[repr(u8)]25pub enum Visibility {26	/// :27	Normal,28	/// ::29	Hidden,30	/// :::31	Unhide,32}3334impl Visibility {35	pub fn is_visible(&self) -> bool {36		matches!(self, Self::Normal | Self::Unhide)37	}38}3940#[derive(Debug, PartialEq, Acyclic)]41pub struct AssertStmt {42	pub assertion: Spanned<Expr>,43	pub message: Option<Expr>,44}4546#[derive(Debug, PartialEq, Acyclic)]47pub struct FieldMember {48	pub name: Spanned<FieldName>,49	pub plus: bool,50	pub params: Option<ExprParams>,51	pub visibility: Visibility,52	pub value: Expr,53}5455#[derive(Debug, PartialEq, Acyclic)]56pub enum Member {57	Field(FieldMember),58	BindStmt(BindSpec),59	AssertStmt(AssertStmt),60}6162#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]63pub enum UnaryOpType {64	Plus,65	Minus,66	BitNot,67	Not,68}6970impl Display for UnaryOpType {71	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {72		use UnaryOpType::*;73		write!(74			f,75			"{}",76			match self {77				Plus => "+",78				Minus => "-",79				BitNot => "~",80				Not => "!",81			}82		)83	}84}8586#[derive(Debug, Clone, Copy, PartialEq, Eq, Acyclic)]87pub enum BinaryOpType {88	Mul,89	Div,9091	/// Implemented as intrinsic, put here for completeness92	Mod,9394	Add,95	Sub,9697	Lhs,98	Rhs,99100	Lt,101	Gt,102	Lte,103	Gte,104105	BitAnd,106	BitOr,107	BitXor,108109	Eq,110	Neq,111112	And,113	Or,114	#[cfg(feature = "exp-null-coaelse")]115	NullCoaelse,116117	// Equialent to std.objectHasEx(a, b, true)118	In,119}120121impl Display for BinaryOpType {122	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {123		use BinaryOpType::*;124		write!(125			f,126			"{}",127			match self {128				Mul => "*",129				Div => "/",130				Mod => "%",131				Add => "+",132				Sub => "-",133				Lhs => "<<",134				Rhs => ">>",135				Lt => "<",136				Gt => ">",137				Lte => "<=",138				Gte => ">=",139				BitAnd => "&",140				BitOr => "|",141				BitXor => "^",142				Eq => "==",143				Neq => "!=",144				And => "&&",145				Or => "||",146				In => "in",147				#[cfg(feature = "exp-null-coaelse")]148				NullCoaelse => "??",149			}150		)151	}152}153154/// name, default value155#[derive(Debug, PartialEq, Acyclic)]156pub struct ExprParam {157	pub destruct: Destruct,158	pub default: Option<Expr>,159}160161/// Defined function parameters162#[derive(Debug, PartialEq, Acyclic)]163pub struct ExprParams {164	pub exprs: Vec<ExprParam>,165	pub signature: FunctionSignature,166	pub(crate) binds_len: usize,167}168impl ExprParams {169	pub fn len(&self) -> usize {170		self.exprs.len()171	}172	pub fn is_empty(&self) -> bool {173		self.exprs.is_empty()174	}175176	pub fn binds_len(&self) -> usize {177		self.binds_len178	}179	pub fn new(exprs: Vec<ExprParam>) -> Self {180		Self {181			signature: FunctionSignature::new(182				exprs183					.iter()184					.map(|p| {185						ParamParse::new(186							p.destruct.name(),187							ParamDefault::exists(p.default.is_some()),188						)189					})190					.collect(),191			),192			binds_len: exprs.iter().map(|v| v.destruct.binds_len()).sum(),193			exprs,194		}195	}196}197198#[derive(Debug, PartialEq, Acyclic)]199pub struct ArgsDesc {200	pub unnamed: Vec<Expr>,201	pub names: Vec<IStr>,202	pub values: Vec<Expr>,203}204impl ArgsDesc {205	pub fn new(unnamed: Vec<Expr>, names: Vec<IStr>, values: Vec<Expr>) -> Self {206		Self {207			unnamed,208			names,209			values,210		}211	}212}213214#[derive(Debug, Clone, PartialEq, Eq, Acyclic)]215pub enum DestructRest {216	/// ...rest217	Keep(IStr),218	/// ...219	Drop,220}221222#[derive(Debug, Clone, PartialEq, Acyclic)]223pub enum Destruct {224	Full(Spanned<IStr>),225	#[cfg(feature = "exp-destruct")]226	Skip,227	#[cfg(feature = "exp-destruct")]228	Array {229		start: Vec<Destruct>,230		rest: Option<DestructRest>,231		end: Vec<Destruct>,232	},233	#[cfg(feature = "exp-destruct")]234	Object {235		#[allow(clippy::type_complexity)]236		fields: Vec<(IStr, Option<Destruct>, Option<Rc<Spanned<Expr>>>)>,237		rest: Option<DestructRest>,238	},239}240impl Destruct {241	/// Name of destructure, used for function parameter names242	pub fn name(&self) -> ParamName {243		match self {244			Self::Full(name) => ParamName::Named(name.value.clone()),245			#[cfg(feature = "exp-destruct")]246			_ => ParamName::Unnamed,247		}248	}249	pub fn binds_len(&self) -> usize {250		#[cfg(feature = "exp-destruct")]251		fn cap_rest(rest: &Option<DestructRest>) -> usize {252			match rest {253				Some(DestructRest::Keep(_)) => 1,254				Some(DestructRest::Drop) => 0,255				None => 0,256			}257		}258		match self {259			Self::Full(_) => 1,260			#[cfg(feature = "exp-destruct")]261			Self::Skip => 0,262			#[cfg(feature = "exp-destruct")]263			Self::Array { start, rest, end } => {264				start.iter().map(Destruct::binds_len).sum::<usize>()265					+ end.iter().map(Destruct::binds_len).sum::<usize>()266					+ cap_rest(rest)267			}268			#[cfg(feature = "exp-destruct")]269			Self::Object { fields, rest } => {270				let mut out = 0;271				for (_, into, _) in fields {272					match into {273						Some(v) => out += v.binds_len(),274						// Field is destructured to default name275						None => out += 1,276					}277				}278				out + cap_rest(rest)279			}280		}281	}282}283284#[derive(Debug, PartialEq, Acyclic)]285pub enum BindSpec {286	Field {287		into: Destruct,288		value: Expr,289	},290	Function {291		name: IStr,292		params: ExprParams,293		value: Expr,294	},295}296impl BindSpec {297	pub fn binds_len(&self) -> usize {298		match self {299			BindSpec::Field { into, .. } => into.binds_len(),300			BindSpec::Function { .. } => 1,301		}302	}303}304305#[derive(Debug, PartialEq, Acyclic)]306pub struct IfSpecData {307	pub span: Span,308	pub cond: Expr,309}310311#[derive(Debug, PartialEq, Acyclic)]312pub struct ForSpecData {313	pub destruct: Destruct,314	pub over: Expr,315}316317#[derive(Debug, PartialEq, Acyclic)]318pub enum CompSpec {319	IfSpec(IfSpecData),320	ForSpec(ForSpecData),321}322323#[derive(Debug, PartialEq, Acyclic)]324pub struct ObjComp {325	pub locals: Vec<BindSpec>,326	pub field: Box<FieldMember>,327	pub compspecs: Vec<CompSpec>,328}329330#[derive(Debug, PartialEq, Acyclic)]331pub struct ObjMembers {332	pub locals: Vec<BindSpec>,333	pub asserts: Vec<AssertStmt>,334	pub fields: Vec<FieldMember>,335}336337#[derive(Debug, PartialEq, Acyclic)]338pub enum ObjBody {339	MemberList(ObjMembers),340	ObjComp(ObjComp),341}342343#[derive(Debug, PartialEq, Eq, Clone, Copy, Acyclic)]344pub enum LiteralType {345	This,346	Super,347	Dollar,348	Null,349	True,350	False,351}352353#[derive(Debug, PartialEq, Acyclic)]354pub struct SliceDesc {355	pub start: Option<Spanned<Expr>>,356	pub end: Option<Spanned<Expr>>,357	pub step: Option<Spanned<Expr>>,358}359360#[derive(Debug, PartialEq, Acyclic)]361pub struct AssertExpr {362	pub assert: AssertStmt,363	pub rest: Expr,364}365366#[derive(Debug, PartialEq, Acyclic)]367pub struct BinaryOp {368	pub lhs: Expr,369	pub op: BinaryOpType,370	pub rhs: Expr,371}372373#[derive(Debug, PartialEq, Acyclic, Clone, Copy)]374pub enum ImportKind {375	Normal,376	Str,377	Bin,378}379380#[derive(Debug, PartialEq, Acyclic)]381pub struct IfElse {382	pub cond: IfSpecData,383	pub cond_then: Expr,384	pub cond_else: Option<Expr>,385}386387#[derive(Debug, PartialEq, Acyclic)]388pub struct Slice {389	pub value: Expr,390	pub slice: SliceDesc,391}392393/// Syntax base394#[derive(Debug, PartialEq, Acyclic)]395pub enum Expr {396	Literal(LiteralType),397398	/// String value: "hello"399	Str(IStr),400	/// Number: 1, 2.0, 2e+20401	Num(NumValue),402	/// Variable name: test403	Var(Spanned<IStr>),404405	/// Array of expressions: [1, 2, "Hello"]406	Arr(Vec<Expr>),407	/// Array comprehension:408	/// ```jsonnet409	///  ingredients: [410	///    { kind: kind, qty: 4 / 3 }411	///    for kind in [412	///      'Honey Syrup',413	///      'Lemon Juice',414	///      'Farmers Gin',415	///    ]416	///  ],417	/// ```418	ArrComp(Box<Expr>, Vec<CompSpec>),419420	/// Object: {a: 2}421	Obj(ObjBody),422	/// Object extension: var1 {b: 2}423	ObjExtend(Box<Expr>, ObjBody),424425	/// -2426	UnaryOp(UnaryOpType, Box<Expr>),427	/// 2 - 2428	BinaryOp(Box<BinaryOp>),429	/// assert 2 == 2 : "Math is broken"430	AssertExpr(Box<AssertExpr>),431	/// local a = 2; { b: a }432	LocalExpr(Vec<BindSpec>, Box<Expr>),433434	/// import* "hello"435	Import(Spanned<ImportKind>, Box<Expr>),436	/// error "I'm broken"437	ErrorStmt(Span, Box<Expr>),438	/// a(b, c)439	Apply(Box<Expr>, Spanned<ArgsDesc>, bool),440	/// a[b], a.b, a?.b441	Index {442		indexable: Box<Expr>,443		parts: Vec<IndexPart>,444	},445	/// function(x) x446	Function(ExprParams, Box<Expr>),447	/// if true == false then 1 else 2448	IfElse(Box<IfElse>),449	Slice(Box<Slice>),450}451452#[derive(Debug, PartialEq, Acyclic)]453pub struct IndexPart {454	pub span: Span,455	pub value: Expr,456	#[cfg(feature = "exp-null-coaelse")]457	pub null_coaelse: bool,458}459460/// file, begin offset, end offset461#[derive(Clone, PartialEq, Eq, Acyclic)]462#[repr(C)]463pub struct Span(pub Source, pub u32, pub u32);464impl Span {465	pub fn belongs_to(&self, other: &Span) -> bool {466		other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2467	}468	pub fn range(&self) -> RangeInclusive<usize> {469		let start = self.1;470		let mut end = self.2;471		if end > start {472			// Because it is originally exclusive473			end -= 1;474		}475		start as usize..=end as usize476	}477}478479#[cfg(target_pointer_width = "64")]480static_assertions::assert_eq_size!(Span, (usize, usize));481482impl Debug for Span {483	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {484		write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)485	}486}487488#[derive(Clone, PartialEq, Acyclic)]489pub struct Spanned<T: Acyclic> {490	pub value: T,491	pub span: Span,492}493impl<T: Acyclic> Deref for Spanned<T> {494	type Target = T;495	fn deref(&self) -> &Self::Target {496		&self.value497	}498}499impl<T: Acyclic> Spanned<T> {500	#[inline]501	pub fn new(value: T, span: Span) -> Self {502		Self { value, span }503	}504	pub fn map<U: Acyclic>(self, v: impl FnOnce(T) -> U) -> Spanned<U> {505		Spanned {506			span: self.span,507			value: v(self.value),508		}509	}510	pub fn as_ref<'a>(&'a self) -> Spanned<&'a T>511	where512		&'a T: Acyclic,513	{514		Spanned {515			span: self.span.clone(),516			value: &self.value,517		}518	}519}520521impl<T: Debug + Acyclic> Debug for Spanned<T> {522	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {523		let expr = &**self;524		if f.alternate() {525			write!(f, "{:#?}", expr)?;526		} else {527			write!(f, "{:?}", expr)?;528		}529		write!(f, " from {:?}", self.span)?;530		Ok(())531	}532}
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;