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

difftreelog

refactor fix clippy warnings

Yaroslav Bolyukin2024-04-07parent: #d349b9e.patch.diff
in: master

27 files changed

modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -150,6 +150,9 @@
 redundant_pub_crate = "allow"
 # Sometimes code is fancier without that
 manual_let_else = "allow"
+# Something is broken about that lint, can't be allowed for
+# codegenerated-stdlib block
+similar_names = "allow"
 
 #[profile.test]
 #opt-level = 1
modifiedcmds/jrsonnet-fmt/src/tests.rsdiffbeforeafterboth
--- a/cmds/jrsonnet-fmt/src/tests.rs
+++ b/cmds/jrsonnet-fmt/src/tests.rs
@@ -1,4 +1,4 @@
-use dprint_core::formatting::{PrintOptions, PrintItems};
+use dprint_core::formatting::{PrintItems, PrintOptions};
 use indoc::indoc;
 
 use crate::Printable;
modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -153,7 +153,7 @@
 		if let Error::Evaluation(e) = e {
 			let mut out = String::new();
 			trace.write_trace(&mut out, &e).expect("format error");
-			eprintln!("{out}")
+			eprintln!("{out}");
 		} else {
 			eprintln!("{e}");
 		}
modifiedcrates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/lib.rs
+++ b/crates/jrsonnet-cli/src/lib.rs
@@ -10,7 +10,7 @@
 	stack::{limit_stack_depth, StackDepthLimitOverrideGuard},
 	FileImportResolver,
 };
-use jrsonnet_gcmodule::with_thread_object_space;
+use jrsonnet_gcmodule::{with_thread_object_space, ObjectSpace};
 pub use manifest::*;
 pub use stdlib::*;
 pub use tla::*;
@@ -88,7 +88,7 @@
 
 impl Drop for LeakSpace {
 	fn drop(&mut self) {
-		with_thread_object_space(|s| s.leak())
+		with_thread_object_space(ObjectSpace::leak);
 	}
 }
 
@@ -102,6 +102,6 @@
 			let collected = jrsonnet_gcmodule::collect_thread_cycles();
 			eprintln!("Collected: {collected}");
 		}
-		eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked())
+		eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked());
 	}
 }
modifiedcrates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/stdlib.rs
+++ b/crates/jrsonnet-cli/src/stdlib.rs
@@ -39,11 +39,11 @@
 
 	fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
 		match s.find('=') {
-			Some(idx) => Ok(ExtStr {
+			Some(idx) => Ok(Self {
 				name: s[..idx].to_owned(),
 				value: s[idx + 1..].to_owned(),
 			}),
-			None => Ok(ExtStr {
+			None => Ok(Self {
 				name: s.to_owned(),
 				value: std::env::var(s).or(Err("missing env var"))?,
 			}),
@@ -109,16 +109,16 @@
 			return Ok(None);
 		}
 		let ctx = ContextInitializer::new(s.clone(), PathResolver::new_cwd_fallback());
-		for ext in self.ext_str.iter() {
+		for ext in &self.ext_str {
 			ctx.add_ext_str((&ext.name as &str).into(), (&ext.value as &str).into());
 		}
-		for ext in self.ext_str_file.iter() {
+		for ext in &self.ext_str_file {
 			ctx.add_ext_str((&ext.name as &str).into(), (&ext.value as &str).into());
 		}
-		for ext in self.ext_code.iter() {
+		for ext in &self.ext_code {
 			ctx.add_ext_code(&ext.name as &str, &ext.value as &str)?;
 		}
-		for ext in self.ext_code_file.iter() {
+		for ext in &self.ext_code_file {
 			ctx.add_ext_code(&ext.name as &str, &ext.value as &str)?;
 		}
 		Ok(Some(ctx))
modifiedcrates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/arr/mod.rs
+++ b/crates/jrsonnet-evaluator/src/arr/mod.rs
@@ -42,7 +42,7 @@
 		Self::new(EagerArray(values))
 	}
 
-	pub fn repeated(data: ArrValue, repeats: usize) -> Option<Self> {
+	pub fn repeated(data: Self, repeats: usize) -> Option<Self> {
 		Some(Self::new(RepeatedArray::new(data, repeats)?))
 	}
 
@@ -70,7 +70,7 @@
 		Ok(Self::eager(out))
 	}
 
-	pub fn extended(a: ArrValue, b: ArrValue) -> Self {
+	pub fn extended(a: Self, b: Self) -> Self {
 		// TODO: benchmark for an optimal value, currently just a arbitrary choice
 		const ARR_EXTEND_THRESHOLD: usize = 100;
 
modifiedcrates/jrsonnet-evaluator/src/function/arglike.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/arglike.rs
+++ b/crates/jrsonnet-evaluator/src/function/arglike.rs
@@ -61,8 +61,8 @@
 impl ArgLike for TlaArg {
 	fn evaluate_arg(&self, ctx: Context, tailstrict: bool) -> Result<Thunk<Val>> {
 		match self {
-			TlaArg::String(s) => Ok(Thunk::evaluated(Val::string(s.clone()))),
-			TlaArg::Code(code) => Ok(if tailstrict {
+			Self::String(s) => Ok(Thunk::evaluated(Val::string(s.clone()))),
+			Self::Code(code) => Ok(if tailstrict {
 				Thunk::evaluated(evaluate(ctx, code)?)
 			} else {
 				Thunk::new(EvaluateThunk {
@@ -70,8 +70,8 @@
 					expr: code.clone(),
 				})
 			}),
-			TlaArg::Val(val) => Ok(Thunk::evaluated(val.clone())),
-			TlaArg::Lazy(lazy) => Ok(lazy.clone()),
+			Self::Val(val) => Ok(Thunk::evaluated(val.clone())),
+			Self::Lazy(lazy) => Ok(lazy.clone()),
 		}
 	}
 }
modifiedcrates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/mod.rs
+++ b/crates/jrsonnet-evaluator/src/function/mod.rs
@@ -237,7 +237,7 @@
 
 	pub fn evaluate_trivial(&self) -> Option<Val> {
 		match self {
-			FuncVal::Normal(n) => n.evaluate_trivial(),
+			Self::Normal(n) => n.evaluate_trivial(),
 			_ => None,
 		}
 	}
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/import.rs
+++ b/crates/jrsonnet-evaluator/src/import.rs
@@ -10,7 +10,7 @@
 use fs::File;
 use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IBytes;
-use jrsonnet_parser::{SourceDirectory, SourceFile, SourcePath, SourceFifo};
+use jrsonnet_parser::{SourceDirectory, SourceFifo, SourceFile, SourcePath};
 
 use crate::{
 	bail,
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -15,7 +15,7 @@
 };
 
 impl<'de> Deserialize<'de> for Val {
-	fn deserialize<D>(deserializer: D) -> Result<Val, D::Error>
+	fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
 	where
 		D: serde::Deserializer<'de>,
 	{
@@ -155,10 +155,10 @@
 		S: serde::Serializer,
 	{
 		match self {
-			Val::Bool(v) => serializer.serialize_bool(*v),
-			Val::Null => serializer.serialize_none(),
-			Val::Str(s) => serializer.serialize_str(&s.clone().into_flat()),
-			Val::Num(n) => {
+			Self::Bool(v) => serializer.serialize_bool(*v),
+			Self::Null => serializer.serialize_none(),
+			Self::Str(s) => serializer.serialize_str(&s.clone().into_flat()),
+			Self::Num(n) => {
 				if n.fract() == 0.0 {
 					let n = *n as i64;
 					serializer.serialize_i64(n)
@@ -167,8 +167,8 @@
 				}
 			}
 			#[cfg(feature = "exp-bigint")]
-			Val::BigInt(b) => b.serialize(serializer),
-			Val::Arr(arr) => {
+			Self::BigInt(b) => b.serialize(serializer),
+			Self::Arr(arr) => {
 				let mut seq = serializer.serialize_seq(Some(arr.len()))?;
 				for (i, element) in arr.iter().enumerate() {
 					let mut serde_error = None;
@@ -190,7 +190,7 @@
 				}
 				seq.end()
 			}
-			Val::Obj(obj) => {
+			Self::Obj(obj) => {
 				let mut map = serializer.serialize_map(Some(obj.len()))?;
 				for (field, value) in obj.iter(
 					#[cfg(feature = "exp-preserve-order")]
@@ -215,7 +215,7 @@
 				}
 				map.end()
 			}
-			Val::Func(_) => Err(S::Error::custom("tried to manifest function")),
+			Self::Func(_) => Err(S::Error::custom("tried to manifest function")),
 		}
 	}
 }
@@ -248,9 +248,9 @@
 	type Ok = Val;
 	type Error = JrError;
 
-	fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<()>
+	fn serialize_element<T>(&mut self, value: &T) -> Result<()>
 	where
-		T: Serialize,
+		T: ?Sized + Serialize,
 	{
 		let value = value.serialize(IntoValSerializer)?;
 		self.data.push(value);
@@ -272,9 +272,9 @@
 	type Ok = Val;
 	type Error = JrError;
 
-	fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<()>
+	fn serialize_element<T>(&mut self, value: &T) -> Result<()>
 	where
-		T: Serialize,
+		T: ?Sized + Serialize,
 	{
 		SerializeSeq::serialize_element(self, value)
 	}
@@ -287,9 +287,9 @@
 	type Ok = Val;
 	type Error = JrError;
 
-	fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<()>
+	fn serialize_field<T>(&mut self, value: &T) -> Result<()>
 	where
-		T: Serialize,
+		T: ?Sized + Serialize,
 	{
 		SerializeSeq::serialize_element(self, value)
 	}
@@ -302,9 +302,9 @@
 	type Ok = Val;
 	type Error = JrError;
 
-	fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<()>
+	fn serialize_field<T>(&mut self, value: &T) -> Result<()>
 	where
-		T: Serialize,
+		T: ?Sized + Serialize,
 	{
 		SerializeSeq::serialize_element(self, value)
 	}
@@ -607,7 +607,7 @@
 }
 
 impl Val {
-	pub fn from_serde(v: impl Serialize) -> Result<Val, JrError> {
+	pub fn from_serde(v: impl Serialize) -> Result<Self, JrError> {
 		v.serialize(IntoValSerializer)
 	}
 }
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -45,7 +45,7 @@
 #[doc(hidden)]
 pub use jrsonnet_macros;
 pub use jrsonnet_parser as parser;
-use jrsonnet_parser::*;
+use jrsonnet_parser::{ExprLocation, LocExpr, ParserSettings, Source, SourcePath};
 pub use obj::*;
 use stack::check_depth;
 pub use tla::apply_tla;
modifiedcrates/jrsonnet-evaluator/src/stack.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stack.rs
+++ b/crates/jrsonnet-evaluator/src/stack.rs
@@ -24,7 +24,7 @@
 pub struct StackOverflowError;
 impl From<StackOverflowError> for ErrorKind {
 	fn from(_: StackOverflowError) -> Self {
-		ErrorKind::StackOverflow
+		Self::StackOverflow
 	}
 }
 impl From<StackOverflowError> for Error {
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/typed/conversions.rs
1use std::{collections::BTreeMap, marker::PhantomData, ops::Deref};23use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_interner::{IBytes, IStr};5pub use jrsonnet_macros::Typed;6use jrsonnet_types::{ComplexValType, ValType};78use crate::{9	arr::{ArrValue, BytesArray},10	bail,11	function::{native::NativeDesc, FuncDesc, FuncVal},12	typed::CheckType,13	val::{IndexableVal, StrValue, ThunkMapper},14	ObjValue, ObjValueBuilder, Result, Thunk, Val,15};1617#[derive(Trace)]18struct FromUntyped<K: Trace>(PhantomData<fn() -> K>);19impl<K> ThunkMapper<Val> for FromUntyped<K>20where21	K: Typed + Trace,22{23	type Output = K;2425	fn map(self, from: Val) -> Result<Self::Output> {26		K::from_untyped(from)27	}28}29impl<K: Trace> Default for FromUntyped<K> {30	fn default() -> Self {31		Self(PhantomData)32	}33}3435pub trait TypedObj: Typed {36	fn serialize(self, out: &mut ObjValueBuilder) -> Result<()>;37	fn parse(obj: &ObjValue) -> Result<Self>;38	fn into_object(self) -> Result<ObjValue> {39		let mut builder = ObjValueBuilder::new();40		self.serialize(&mut builder)?;41		Ok(builder.build())42	}43}4445pub trait Typed: Sized {46	const TYPE: &'static ComplexValType;47	fn into_untyped(typed: Self) -> Result<Val>;48	fn into_lazy_untyped(typed: Self) -> Thunk<Val> {49		Thunk::from(Self::into_untyped(typed))50	}51	fn from_untyped(untyped: Val) -> Result<Self>;52	fn from_lazy_untyped(lazy: Thunk<Val>) -> Result<Self> {53		Self::from_untyped(lazy.evaluate()?)54	}5556	// Whatever caller should use `into_lazy_untyped` instead of `into_untyped`57	fn provides_lazy() -> bool {58		false59	}6061	// Whatever caller should use `from_lazy_untyped` instead of `from_untyped` when possible62	fn wants_lazy() -> bool {63		false64	}6566	/// Hack to make builtins be able to return non-result values, and make macros able to convert those values to result67	/// This method returns identity in impl Typed for Result, and should not be overriden68	#[doc(hidden)]69	fn into_result(typed: Self) -> Result<Val> {70		let value = Self::into_untyped(typed)?;71		Ok(value)72	}73}7475impl<T> Typed for Thunk<T>76where77	T: Typed + Trace + Clone,78{79	const TYPE: &'static ComplexValType = &ComplexValType::Lazy(T::TYPE);8081	fn into_untyped(typed: Self) -> Result<Val> {82		T::into_untyped(typed.evaluate()?)83	}8485	fn from_untyped(untyped: Val) -> Result<Self> {86		Self::from_lazy_untyped(Thunk::evaluated(untyped))87	}8889	fn provides_lazy() -> bool {90		true91	}9293	fn into_lazy_untyped(inner: Self) -> Thunk<Val> {94		#[derive(Trace)]95		struct IntoUntyped<K: Trace>(PhantomData<fn() -> K>);96		impl<K> ThunkMapper<K> for IntoUntyped<K>97		where98			K: Typed + Trace,99		{100			type Output = Val;101102			fn map(self, from: K) -> Result<Self::Output> {103				K::into_untyped(from)104			}105		}106		impl<K: Trace> Default for IntoUntyped<K> {107			fn default() -> Self {108				Self(PhantomData)109			}110		}111		inner.map(<IntoUntyped<T>>::default())112	}113114	fn wants_lazy() -> bool {115		true116	}117118	fn from_lazy_untyped(inner: Thunk<Val>) -> Result<Self> {119		Ok(inner.map(<FromUntyped<T>>::default()))120	}121}122123const MAX_SAFE_INTEGER: f64 = ((1u64 << (f64::MANTISSA_DIGITS + 1)) - 1) as f64;124125macro_rules! impl_int {126	($($ty:ty)*) => {$(127		impl Typed for $ty {128			const TYPE: &'static ComplexValType =129				&ComplexValType::BoundedNumber(Some(Self::MIN as f64), Some(Self::MAX as f64));130			fn from_untyped(value: Val) -> Result<Self> {131				<Self as Typed>::TYPE.check(&value)?;132				match value {133					Val::Num(n) => {134						#[allow(clippy::float_cmp)]135						if n.trunc() != n {136							bail!(137								"cannot convert number with fractional part to {}",138								stringify!($ty)139							)140						}141						Ok(n as Self)142					}143					_ => unreachable!(),144				}145			}146			fn into_untyped(value: Self) -> Result<Val> {147				Ok(Val::Num(value as f64))148			}149		}150	)*};151}152153impl_int!(i8 u8 i16 u16 i32 u32);154155macro_rules! impl_bounded_int {156	($($name:ident = $ty:ty)*) => {$(157		#[derive(Clone, Copy)]158		pub struct $name<const MIN: $ty, const MAX: $ty>($ty);159		impl<const MIN: $ty, const MAX: $ty> $name<MIN, MAX> {160			pub const fn new(value: $ty) -> Option<$name<MIN, MAX>> {161				if value >= MIN && value <= MAX {162					Some(Self(value))163				} else {164					None165				}166			}167			pub const fn value(self) -> $ty {168				self.0169			}170		}171		impl<const MIN: $ty, const MAX: $ty> Deref for $name<MIN, MAX> {172			type Target = $ty;173			fn deref(&self) -> &Self::Target {174				&self.0175			}176		}177178		impl<const MIN: $ty, const MAX: $ty> Typed for $name<MIN, MAX> {179			const TYPE: &'static ComplexValType =180				&ComplexValType::BoundedNumber(181					Some(MIN as f64),182					Some(MAX as f64),183				);184185			fn from_untyped(value: Val) -> Result<Self> {186				<Self as Typed>::TYPE.check(&value)?;187				match value {188					Val::Num(n) => {189						#[allow(clippy::float_cmp)]190						if n.trunc() != n {191							bail!(192								"cannot convert number with fractional part to {}",193								stringify!($ty)194							)195						}196						Ok(Self(n as $ty))197					}198					_ => unreachable!(),199				}200			}201202			fn into_untyped(value: Self) -> Result<Val> {203				Ok(Val::Num(value.0 as f64))204			}205		}206	)*};207}208209impl_bounded_int!(210	BoundedI8 = i8211	BoundedI16 = i16212	BoundedI32 = i32213	BoundedI64 = i64214	BoundedUsize = usize215);216217impl Typed for f64 {218	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Num);219220	fn into_untyped(value: Self) -> Result<Val> {221		Ok(Val::Num(value))222	}223224	fn from_untyped(value: Val) -> Result<Self> {225		<Self as Typed>::TYPE.check(&value)?;226		match value {227			Val::Num(n) => Ok(n),228			_ => unreachable!(),229		}230	}231}232233pub struct PositiveF64(pub f64);234impl Typed for PositiveF64 {235	const TYPE: &'static ComplexValType = &ComplexValType::BoundedNumber(Some(0.0), None);236237	fn into_untyped(value: Self) -> Result<Val> {238		Ok(Val::Num(value.0))239	}240241	fn from_untyped(value: Val) -> Result<Self> {242		<Self as Typed>::TYPE.check(&value)?;243		match value {244			Val::Num(n) => Ok(Self(n)),245			_ => unreachable!(),246		}247	}248}249impl Typed for usize {250	const TYPE: &'static ComplexValType =251		&ComplexValType::BoundedNumber(Some(0.0), Some(MAX_SAFE_INTEGER));252253	fn into_untyped(value: Self) -> Result<Val> {254		if value > MAX_SAFE_INTEGER as Self {255			bail!("number is too large")256		}257		Ok(Val::Num(value as f64))258	}259260	fn from_untyped(value: Val) -> Result<Self> {261		<Self as Typed>::TYPE.check(&value)?;262		match value {263			Val::Num(n) => {264				#[allow(clippy::float_cmp)]265				if n.trunc() != n {266					bail!("cannot convert number with fractional part to usize")267				}268				Ok(n as Self)269			}270			_ => unreachable!(),271		}272	}273}274275impl Typed for IStr {276	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Str);277278	fn into_untyped(value: Self) -> Result<Val> {279		Ok(Val::string(value))280	}281282	fn from_untyped(value: Val) -> Result<Self> {283		<Self as Typed>::TYPE.check(&value)?;284		match value {285			Val::Str(s) => Ok(s.into_flat()),286			_ => unreachable!(),287		}288	}289}290291impl Typed for String {292	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Str);293294	fn into_untyped(value: Self) -> Result<Val> {295		Ok(Val::string(value))296	}297298	fn from_untyped(value: Val) -> Result<Self> {299		<Self as Typed>::TYPE.check(&value)?;300		match value {301			Val::Str(s) => Ok(s.to_string()),302			_ => unreachable!(),303		}304	}305}306307impl Typed for StrValue {308	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Str);309310	fn into_untyped(value: Self) -> Result<Val> {311		Ok(Val::Str(value))312	}313314	fn from_untyped(value: Val) -> Result<Self> {315		<Self as Typed>::TYPE.check(&value)?;316		match value {317			Val::Str(s) => Ok(s),318			_ => unreachable!(),319		}320	}321}322323impl Typed for char {324	const TYPE: &'static ComplexValType = &ComplexValType::Char;325326	fn into_untyped(value: Self) -> Result<Val> {327		Ok(Val::string(value))328	}329330	fn from_untyped(value: Val) -> Result<Self> {331		<Self as Typed>::TYPE.check(&value)?;332		match value {333			Val::Str(s) => Ok(s.into_flat().chars().next().unwrap()),334			_ => unreachable!(),335		}336	}337}338339impl<T> Typed for Vec<T>340where341	T: Typed,342{343	const TYPE: &'static ComplexValType = &ComplexValType::ArrayRef(T::TYPE);344345	fn into_untyped(value: Self) -> Result<Val> {346		Ok(Val::Arr(347			value348				.into_iter()349				.map(T::into_untyped)350				.collect::<Result<ArrValue>>()?,351		))352	}353354	fn from_untyped(value: Val) -> Result<Self> {355		let Val::Arr(a) = value else {356			<Self as Typed>::TYPE.check(&value)?;357			unreachable!("typecheck should fail")358		};359		a.iter()360			.map(|r| r.and_then(T::from_untyped))361			.collect::<Result<Vec<T>>>()362	}363}364365impl<K: Typed + Ord, V: Typed> Typed for BTreeMap<K, V> {366	const TYPE: &'static ComplexValType = &ComplexValType::AttrsOf(V::TYPE);367368	fn into_untyped(typed: Self) -> Result<Val> {369		let mut out = ObjValueBuilder::with_capacity(typed.len());370		for (k, v) in typed {371			let Some(key) = K::into_untyped(k)?.as_str() else {372				bail!("map key should serialize to string");373			};374			let value = V::into_untyped(v)?;375			out.field(key).value(value);376		}377		Ok(Val::Obj(out.build()))378	}379380	fn from_untyped(value: Val) -> Result<Self> {381		Self::TYPE.check(&value)?;382		let obj = value.as_obj().expect("typecheck should fail");383384		let mut out = BTreeMap::new();385		if V::wants_lazy() {386			for key in obj.fields_ex(387				false,388				#[cfg(feature = "exp-preserve-order")]389				false,390			) {391				let value = obj.get_lazy(key.clone()).expect("field exists");392				let value = V::from_lazy_untyped(value)?;393				let key = K::from_untyped(Val::Str(key.into()))?;394				let _ = out.insert(key, value);395			}396		} else {397			for (key, value) in obj.iter(398				#[cfg(feature = "exp-preserve-order")]399				false,400			) {401				let key = K::from_untyped(Val::Str(key.into()))?;402				let value = V::from_untyped(value?)?;403				let _ = out.insert(key, value);404			}405		}406		Ok(out)407	}408}409410impl Typed for Val {411	const TYPE: &'static ComplexValType = &ComplexValType::Any;412413	fn into_untyped(typed: Self) -> Result<Val> {414		Ok(typed)415	}416	fn from_untyped(untyped: Val) -> Result<Self> {417		Ok(untyped)418	}419}420421// Hack422#[doc(hidden)]423impl<T> Typed for Result<T>424where425	T: Typed,426{427	const TYPE: &'static ComplexValType = &ComplexValType::Any;428429	fn into_untyped(_typed: Self) -> Result<Val> {430		panic!("do not use this conversion")431	}432433	fn from_untyped(_untyped: Val) -> Result<Self> {434		panic!("do not use this conversion")435	}436437	fn into_result(typed: Self) -> Result<Val> {438		typed.map(T::into_untyped)?439	}440}441442/// Specialization443impl Typed for IBytes {444	const TYPE: &'static ComplexValType =445		&ComplexValType::ArrayRef(&ComplexValType::BoundedNumber(Some(0.0), Some(255.0)));446447	fn into_untyped(value: Self) -> Result<Val> {448		Ok(Val::Arr(ArrValue::bytes(value)))449	}450451	fn from_untyped(value: Val) -> Result<Self> {452		let Val::Arr(a) = &value else {453			<Self as Typed>::TYPE.check(&value)?;454			unreachable!()455		};456		if let Some(bytes) = a.as_any().downcast_ref::<BytesArray>() {457			return Ok(bytes.0.as_slice().into());458		};459		<Self as Typed>::TYPE.check(&value)?;460		// Any::downcast_ref::<ByteArray>(&a);461		let mut out = Vec::with_capacity(a.len());462		for e in a.iter() {463			let r = e?;464			out.push(u8::from_untyped(r)?);465		}466		Ok(out.as_slice().into())467	}468}469470pub struct M1;471impl Typed for M1 {472	const TYPE: &'static ComplexValType = &ComplexValType::BoundedNumber(Some(-1.0), Some(-1.0));473474	fn into_untyped(_: Self) -> Result<Val> {475		Ok(Val::Num(-1.0))476	}477478	fn from_untyped(value: Val) -> Result<Self> {479		<Self as Typed>::TYPE.check(&value)?;480		Ok(Self)481	}482}483484macro_rules! decl_either {485	($($name: ident, $($id: ident)*);*) => {$(486		#[derive(Clone)]487		pub enum $name<$($id),*> {488			$($id($id)),*489		}490		impl<$($id),*> Typed for $name<$($id),*>491		where492			$($id: Typed,)*493		{494			const TYPE: &'static ComplexValType = &ComplexValType::UnionRef(&[$($id::TYPE),*]);495496			fn into_untyped(value: Self) -> Result<Val> {497				match value {$(498					$name::$id(v) => $id::into_untyped(v)499				),*}500			}501502			fn from_untyped(value: Val) -> Result<Self> {503				$(504					if $id::TYPE.check(&value).is_ok() {505						$id::from_untyped(value).map(Self::$id)506					} else507				)* {508					<Self as Typed>::TYPE.check(&value)?;509					unreachable!()510				}511			}512		}513	)*}514}515decl_either!(516	Either1, A;517	Either2, A B;518	Either3, A B C;519	Either4, A B C D;520	Either5, A B C D E;521	Either6, A B C D E F;522	Either7, A B C D E F G523);524#[macro_export]525macro_rules! Either {526	($a:ty) => {$crate::typed::Either1<$a>};527	($a:ty, $b:ty) => {$crate::typed::Either2<$a, $b>};528	($a:ty, $b:ty, $c:ty) => {$crate::typed::Either3<$a, $b, $c>};529	($a:ty, $b:ty, $c:ty, $d:ty) => {$crate::typed::Either4<$a, $b, $c, $d>};530	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty) => {$crate::typed::Either5<$a, $b, $c, $d, $e>};531	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty) => {$crate::typed::Either6<$a, $b, $c, $d, $e, $f>};532	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty) => {$crate::typed::Either7<$a, $b, $c, $d, $e, $f, $g>};533}534pub use Either;535536pub type MyType = Either![u32, f64, String];537538impl Typed for ArrValue {539	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Arr);540541	fn into_untyped(value: Self) -> Result<Val> {542		Ok(Val::Arr(value))543	}544545	fn from_untyped(value: Val) -> Result<Self> {546		<Self as Typed>::TYPE.check(&value)?;547		match value {548			Val::Arr(a) => Ok(a),549			_ => unreachable!(),550		}551	}552}553554impl Typed for FuncVal {555	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Func);556557	fn into_untyped(value: Self) -> Result<Val> {558		Ok(Val::Func(value))559	}560561	fn from_untyped(value: Val) -> Result<Self> {562		<Self as Typed>::TYPE.check(&value)?;563		match value {564			Val::Func(a) => Ok(a),565			_ => unreachable!(),566		}567	}568}569570impl Typed for Cc<FuncDesc> {571	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Func);572573	fn into_untyped(value: Self) -> Result<Val> {574		Ok(Val::Func(FuncVal::Normal(value)))575	}576577	fn from_untyped(value: Val) -> Result<Self> {578		<Self as Typed>::TYPE.check(&value)?;579		match value {580			Val::Func(FuncVal::Normal(desc)) => Ok(desc),581			Val::Func(_) => bail!("expected normal function, not builtin"),582			_ => unreachable!(),583		}584	}585}586587impl Typed for ObjValue {588	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Obj);589590	fn into_untyped(value: Self) -> Result<Val> {591		Ok(Val::Obj(value))592	}593594	fn from_untyped(value: Val) -> Result<Self> {595		<Self as Typed>::TYPE.check(&value)?;596		match value {597			Val::Obj(a) => Ok(a),598			_ => unreachable!(),599		}600	}601}602603impl Typed for bool {604	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Bool);605606	fn into_untyped(value: Self) -> Result<Val> {607		Ok(Val::Bool(value))608	}609610	fn from_untyped(value: Val) -> Result<Self> {611		<Self as Typed>::TYPE.check(&value)?;612		match value {613			Val::Bool(a) => Ok(a),614			_ => unreachable!(),615		}616	}617}618impl Typed for IndexableVal {619	const TYPE: &'static ComplexValType = &ComplexValType::UnionRef(&[620		&ComplexValType::Simple(ValType::Arr),621		&ComplexValType::Simple(ValType::Str),622	]);623624	fn into_untyped(value: Self) -> Result<Val> {625		match value {626			IndexableVal::Str(s) => Ok(Val::string(s)),627			IndexableVal::Arr(a) => Ok(Val::Arr(a)),628		}629	}630631	fn from_untyped(value: Val) -> Result<Self> {632		<Self as Typed>::TYPE.check(&value)?;633		value.into_indexable()634	}635}636637pub struct Null;638impl Typed for Null {639	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Null);640641	fn into_untyped(_: Self) -> Result<Val> {642		Ok(Val::Null)643	}644645	fn from_untyped(value: Val) -> Result<Self> {646		<Self as Typed>::TYPE.check(&value)?;647		Ok(Self)648	}649}650651pub struct NativeFn<D: NativeDesc>(D::Value);652impl<D: NativeDesc> Deref for NativeFn<D> {653	type Target = D::Value;654655	fn deref(&self) -> &Self::Target {656		&self.0657	}658}659impl<D: NativeDesc> Typed for NativeFn<D> {660	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Func);661662	fn into_untyped(_typed: Self) -> Result<Val> {663		bail!("can only convert functions from jsonnet to native")664	}665666	fn from_untyped(untyped: Val) -> Result<Self> {667		Ok(Self(668			untyped669				.as_func()670				.expect("shape is checked")671				.into_native::<D>(),672		))673	}674}
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -147,7 +147,7 @@
 	T: ThunkValue<Output = V>,
 {
 	fn from(value: T) -> Self {
-		Thunk::new(value)
+		Self::new(value)
 	}
 }
 
@@ -221,8 +221,8 @@
 impl IndexableVal {
 	pub fn to_array(self) -> ArrValue {
 		match self {
-			IndexableVal::Str(s) => ArrValue::chars(s.chars()),
-			IndexableVal::Arr(arr) => arr,
+			Self::Str(s) => ArrValue::chars(s.chars()),
+			Self::Arr(arr) => arr,
 		}
 	}
 	/// Slice the value.
@@ -239,7 +239,7 @@
 		step: Option<BoundedUsize<1, { i32::MAX as usize }>>,
 	) -> Result<Self> {
 		match &self {
-			IndexableVal::Str(s) => {
+			Self::Str(s) => {
 				let mut computed_len = None;
 				let mut get_len = || {
 					computed_len.map_or_else(
@@ -277,7 +277,7 @@
 					.into(),
 				))
 			}
-			IndexableVal::Arr(arr) => {
+			Self::Arr(arr) => {
 				let get_idx = |pos: Option<i32>, len: usize, default| match pos {
 					Some(v) if v < 0 => len.saturating_sub((-v) as usize),
 					Some(v) => (v as usize).min(len),
@@ -307,7 +307,7 @@
 	Tree(Rc<(StrValue, StrValue, usize)>),
 }
 impl StrValue {
-	pub fn concat(a: StrValue, b: StrValue) -> Self {
+	pub fn concat(a: Self, b: Self) -> Self {
 		// TODO: benchmark for an optimal value, currently just a arbitrary choice
 		const STRING_EXTEND_THRESHOLD: usize = 100;
 
@@ -334,8 +334,8 @@
 			}
 		}
 		match self {
-			StrValue::Flat(f) => f,
-			StrValue::Tree(_) => {
+			Self::Flat(f) => f,
+			Self::Tree(_) => {
 				let mut buf = String::with_capacity(self.len());
 				write_buf(&self, &mut buf);
 				buf.into()
@@ -344,8 +344,8 @@
 	}
 	pub fn len(&self) -> usize {
 		match self {
-			StrValue::Flat(v) => v.len(),
-			StrValue::Tree(t) => t.2,
+			Self::Flat(v) => v.len(),
+			Self::Tree(t) => t.2,
 		}
 	}
 	pub fn is_empty(&self) -> bool {
@@ -367,8 +367,8 @@
 impl Display for StrValue {
 	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 		match self {
-			StrValue::Flat(v) => write!(f, "{v}"),
-			StrValue::Tree(t) => {
+			Self::Flat(v) => write!(f, "{v}"),
+			Self::Tree(t) => {
 				write!(f, "{}", t.0)?;
 				write!(f, "{}", t.1)
 			}
@@ -522,8 +522,8 @@
 
 	pub fn into_indexable(self) -> Result<IndexableVal> {
 		Ok(match self {
-			Val::Str(s) => IndexableVal::Str(s.into_flat()),
-			Val::Arr(arr) => IndexableVal::Arr(arr),
+			Self::Str(s) => IndexableVal::Str(s.into_flat()),
+			Self::Arr(arr) => IndexableVal::Arr(arr),
 			_ => bail!(ValueIsNotIndexable(self.value_type())),
 		})
 	}
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-macros/src/lib.rs
+++ b/crates/jrsonnet-macros/src/lib.rs
@@ -1,3 +1,5 @@
+use std::string::String;
+
 use proc_macro2::TokenStream;
 use quote::quote;
 use syn::{
@@ -205,6 +207,7 @@
 	}
 }
 
+#[allow(clippy::too_many_lines)]
 fn builtin_inner(
 	attr: BuiltinAttrs,
 	fun: ItemFn,
@@ -225,7 +228,7 @@
 		.map(|arg| ArgInfo::parse(&name, arg))
 		.collect::<Result<Vec<_>>>()?;
 
-	let params_desc = args.iter().flat_map(|a| match a {
+	let params_desc = args.iter().filter_map(|a| match a {
 		ArgInfo::Normal {
 			is_option,
 			name,
@@ -234,8 +237,7 @@
 		} => {
 			let name = name
 				.as_ref()
-				.map(|n| quote! {ParamName::new_static(#n)})
-				.unwrap_or_else(|| quote! {None});
+				.map_or_else(|| quote! {None}, |n| quote! {ParamName::new_static(#n)});
 			Some(quote! {
 				#(#cfg_attrs)*
 				BuiltinParam::new(#name, #is_option),
@@ -244,15 +246,12 @@
 		ArgInfo::Lazy { is_option, name } => {
 			let name = name
 				.as_ref()
-				.map(|n| quote! {ParamName::new_static(#n)})
-				.unwrap_or_else(|| quote! {None});
+				.map_or_else(|| quote! {None}, |n| quote! {ParamName::new_static(#n)});
 			Some(quote! {
 				BuiltinParam::new(#name, #is_option),
 			})
 		}
-		ArgInfo::Context => None,
-		ArgInfo::Location => None,
-		ArgInfo::This => None,
+		ArgInfo::Context | ArgInfo::Location | ArgInfo::This => None,
 	});
 
 	let mut id = 0usize;
@@ -275,7 +274,7 @@
 				name,
 				cfg_attrs,
 			} => {
-				let name = name.as_ref().map(|v| v.as_str()).unwrap_or("<unnamed>");
+				let name = name.as_ref().map_or("<unnamed>", String::as_str);
 				let eval = quote! {jrsonnet_evaluator::State::push_description(
 					|| format!("argument <{}> evaluation", #name),
 					|| <#ty>::from_untyped(value.evaluate()?),
@@ -390,6 +389,7 @@
 }
 
 #[derive(Default)]
+#[allow(clippy::struct_excessive_bools)]
 struct TypedAttr {
 	rename: Option<String>,
 	flatten: bool,
@@ -467,11 +467,8 @@
 				"this field should appear in output object, but it has no visible name",
 			));
 		};
-		let (is_option, ty) = if let Some(ty) = extract_type_from_option(&field.ty)? {
-			(true, ty.clone())
-		} else {
-			(false, field.ty.clone())
-		};
+		let (is_option, ty) = extract_type_from_option(&field.ty)?
+			.map_or_else(|| (false, field.ty.clone()), |ty| (true, ty.clone()));
 		if is_option && attr.flatten {
 			if !attr.flatten_ok {
 				return Err(Error::new(
@@ -551,48 +548,53 @@
 			#ident: #value,
 		}
 	}
-	fn expand_serialize(&self) -> Result<TokenStream> {
+	fn expand_serialize(&self) -> TokenStream {
 		let ident = &self.ident;
 		let ty = &self.ty;
-		Ok(if let Some(name) = self.name() {
-			let hide = if self.attr.hide {
-				quote! {.hide()}
-			} else {
-				quote! {}
-			};
-			let add = if self.attr.add {
-				quote! {.add()}
-			} else {
-				quote! {}
-			};
-			if self.is_option {
-				quote! {
-					if let Some(value) = self.#ident {
+		self.name().map_or_else(
+			|| {
+				if self.is_option {
+					quote! {
+						if let Some(value) = self.#ident {
+							<#ty as TypedObj>::serialize(value, out)?;
+						}
+					}
+				} else {
+					quote! {
+						<#ty as TypedObj>::serialize(self.#ident, out)?;
+					}
+				}
+			},
+			|name| {
+				let hide = if self.attr.hide {
+					quote! {.hide()}
+				} else {
+					quote! {}
+				};
+				let add = if self.attr.add {
+					quote! {.add()}
+				} else {
+					quote! {}
+				};
+				if self.is_option {
+					quote! {
+						if let Some(value) = self.#ident {
+							out.field(#name)
+								#hide
+								#add
+								.try_value(<#ty as Typed>::into_untyped(value)?)?;
+						}
+					}
+				} else {
+					quote! {
 						out.field(#name)
 							#hide
 							#add
-							.try_value(<#ty as Typed>::into_untyped(value)?)?;
+							.try_value(<#ty as Typed>::into_untyped(self.#ident)?)?;
 					}
 				}
-			} else {
-				quote! {
-					out.field(#name)
-						#hide
-						#add
-						.try_value(<#ty as Typed>::into_untyped(self.#ident)?)?;
-				}
-			}
-		} else if self.is_option {
-			quote! {
-				if let Some(value) = self.#ident {
-					<#ty as TypedObj>::serialize(value, out)?;
-				}
-			}
-		} else {
-			quote! {
-				<#ty as TypedObj>::serialize(self.#ident, out)?;
-			}
-		})
+			},
+		)
 	}
 }
 
@@ -623,7 +625,7 @@
 	let typed = {
 		let fields = fields
 			.iter()
-			.flat_map(TypedField::expand_field)
+			.filter_map(TypedField::expand_field)
 			.collect::<Vec<_>>();
 		quote! {
 			impl #impl_generics Typed for #ident #ty_generics #where_clause {
@@ -650,7 +652,7 @@
 	let fields_serialize = fields
 		.iter()
 		.map(TypedField::expand_serialize)
-		.collect::<Result<Vec<_>>>()?;
+		.collect::<Vec<_>>();
 
 	Ok(quote! {
 		const _: () = {
@@ -767,7 +769,7 @@
 	}
 }
 
-/// IStr formatting helper
+/// `IStr` formatting helper
 ///
 /// Using `format!("literal with no codes").into()` is slower than just `"literal with no codes".into()`
 /// This macro looks for formatting codes in the input string, and uses
modifiedcrates/jrsonnet-rowan-parser/src/parser.rsdiffbeforeafterboth
--- a/crates/jrsonnet-rowan-parser/src/parser.rs
+++ b/crates/jrsonnet-rowan-parser/src/parser.rs
@@ -758,10 +758,10 @@
 			} else if p.at(T![...]) {
 				// let m_err = p.start_ranger();
 				destruct_rest(p);
-				// if had_rest {
-				// 	p.custom_error(m_err.finish(p), "only one rest can be present in array");
-				// }
-				// had_rest = true;
+			// if had_rest {
+			// 	p.custom_error(m_err.finish(p), "only one rest can be present in array");
+			// }
+			// had_rest = true;
 			} else {
 				destruct(p);
 			}
modifiedcrates/jrsonnet-stdlib/build.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/build.rs
+++ b/crates/jrsonnet-stdlib/build.rs
@@ -26,7 +26,9 @@
 			let dest_path = Path::new(&out_dir).join("stdlib.rs");
 			let mut f = File::create(dest_path).unwrap();
 			f.write_all(
-				("#[allow(clippy::redundant_clone)]".to_owned() + &v.to_string()).as_bytes(),
+				("#[allow(clippy::redundant_clone, clippy::similar_names)]".to_owned()
+					+ &v.to_string())
+					.as_bytes(),
 			)
 			.unwrap();
 		}
modifiedcrates/jrsonnet-stdlib/src/arrays.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/arrays.rs
+++ b/crates/jrsonnet-stdlib/src/arrays.rs
@@ -9,7 +9,7 @@
 	Either, IStr, ObjValueBuilder, Result, ResultExt, Thunk, Val,
 };
 
-pub(crate) fn eval_on_empty(on_empty: Option<Thunk<Val>>) -> Result<Val> {
+pub fn eval_on_empty(on_empty: Option<Thunk<Val>>) -> Result<Val> {
 	if let Some(on_empty) = on_empty {
 		on_empty.evaluate()
 	} else {
@@ -270,8 +270,8 @@
 	let newArrRight = arr.slice(Some(at + 1), None, None);
 
 	Ok(ArrValue::extended(
-		newArrLeft.unwrap_or(ArrValue::empty()),
-		newArrRight.unwrap_or(ArrValue::empty()),
+		newArrLeft.unwrap_or_else(ArrValue::empty),
+		newArrRight.unwrap_or_else(ArrValue::empty),
 	))
 }
 
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -313,10 +313,10 @@
 	settings: Rc<RefCell<Settings>>,
 }
 impl ContextInitializer {
-	pub fn new(_s: State, resolver: PathResolver) -> Self {
+	pub fn new(s: State, resolver: PathResolver) -> Self {
 		let settings = Settings {
-			ext_vars: Default::default(),
-			ext_natives: Default::default(),
+			ext_vars: HashMap::new(),
+			ext_natives: HashMap::new(),
 			trace_printer: Box::new(StdTracePrinter::new(resolver.clone())),
 			path_resolver: resolver,
 		};
@@ -324,10 +324,12 @@
 		let stdlib_obj = stdlib_uncached(settings.clone());
 		#[cfg(not(feature = "legacy-this-file"))]
 		let stdlib_thunk = Thunk::evaluated(Val::Obj(stdlib_obj));
+		#[cfg(feature = "legacy-this-file")]
+		let _ = s;
 		Self {
 			#[cfg(not(feature = "legacy-this-file"))]
 			context: {
-				let mut context = ContextBuilder::with_capacity(_s, 1);
+				let mut context = ContextBuilder::with_capacity(s, 1);
 				context.bind("std", stdlib_thunk.clone());
 				context.build()
 			},
modifiedcrates/jrsonnet-stdlib/src/manifest/toml.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/manifest/toml.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/toml.rs
@@ -180,7 +180,9 @@
 		options.preserve_order,
 	) {
 		let value = value?;
-		if !is_section(&value)? {
+		if is_section(&value)? {
+			sections.push((key, value));
+		} else {
 			if !first {
 				buf.push('\n');
 			}
@@ -189,8 +191,6 @@
 			escape_key_toml_buf(&key, buf);
 			buf.push_str(" = ");
 			manifest_value(&value, false, buf, cur_padding, options)?;
-		} else {
-			sections.push((key, value));
 		}
 	}
 	for (k, v) in sections {
modifiedcrates/jrsonnet-stdlib/src/math.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/math.rs
+++ b/crates/jrsonnet-stdlib/src/math.rs
@@ -131,16 +131,19 @@
 }
 
 #[builtin]
+#[allow(clippy::float_cmp)]
 pub fn builtin_is_odd(x: f64) -> bool {
 	builtin_round(x) % 2.0 == 1.0
 }
 
 #[builtin]
+#[allow(clippy::float_cmp)]
 pub fn builtin_is_integer(x: f64) -> bool {
 	builtin_round(x) == x
 }
 
 #[builtin]
+#[allow(clippy::float_cmp)]
 pub fn builtin_is_decimal(x: f64) -> bool {
 	builtin_round(x) != x
 }
modifiedcrates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/misc.rs
+++ b/crates/jrsonnet-stdlib/src/misc.rs
@@ -67,11 +67,7 @@
 			v => v.manifest(JsonFormat::debug())?.into(),
 		},
 	);
-	if let Some(rest) = rest {
-		rest.evaluate()
-	} else {
-		Ok(str)
-	}
+	rest.map_or_else(|| Ok(str), |rest| rest.evaluate())
 }
 
 #[allow(clippy::comparison_chain)]
@@ -84,16 +80,15 @@
 				return Ok(false);
 			} else if b.len() == a.len() {
 				return equals(&Val::Arr(a), &Val::Arr(b));
-			} else {
-				for (a, b) in a.iter().take(b.len()).zip(b.iter()) {
-					let a = a?;
-					let b = b?;
-					if !equals(&a, &b)? {
-						return Ok(false);
-					}
+			}
+			for (a, b) in a.iter().take(b.len()).zip(b.iter()) {
+				let a = a?;
+				let b = b?;
+				if !equals(&a, &b)? {
+					return Ok(false);
 				}
-				true
 			}
+			true
 		}
 		_ => bail!("both arguments should be of the same type"),
 	})
@@ -109,17 +104,16 @@
 				return Ok(false);
 			} else if b.len() == a.len() {
 				return equals(&Val::Arr(a), &Val::Arr(b));
-			} else {
-				let a_len = a.len();
-				for (a, b) in a.iter().skip(a_len - b.len()).zip(b.iter()) {
-					let a = a?;
-					let b = b?;
-					if !equals(&a, &b)? {
-						return Ok(false);
-					}
+			}
+			let a_len = a.len();
+			for (a, b) in a.iter().skip(a_len - b.len()).zip(b.iter()) {
+				let a = a?;
+				let b = b?;
+				if !equals(&a, &b)? {
+					return Ok(false);
 				}
-				true
 			}
+			true
 		}
 		_ => bail!("both arguments should be of the same type"),
 	})
modifiedcrates/jrsonnet-stdlib/src/objects.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/objects.rs
+++ b/crates/jrsonnet-stdlib/src/objects.rs
@@ -155,7 +155,7 @@
 		if k == key {
 			continue;
 		}
-		new_obj.field(k).value(v.unwrap())
+		new_obj.field(k).value(v.unwrap());
 	}
 
 	new_obj.build()
modifiedcrates/jrsonnet-stdlib/src/sort.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/sort.rs
+++ b/crates/jrsonnet-stdlib/src/sort.rs
@@ -36,7 +36,7 @@
 
 fn get_sort_type<T>(values: &[T], key_getter: impl Fn(&T) -> &Val) -> Result<SortKeyType> {
 	let mut sort_type = SortKeyType::Unknown;
-	for i in values.iter() {
+	for i in values {
 		let i = key_getter(i);
 		match (i, sort_type) {
 			(Val::Str(_), SortKeyType::Unknown) => sort_type = SortKeyType::String,
modifiedcrates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/strings.rs
+++ b/crates/jrsonnet-stdlib/src/strings.rs
@@ -75,7 +75,7 @@
 		.enumerate()
 	{
 		if &strb[i..i + pat.len()] == pat {
-			out.push(Val::Num(ch_idx as f64))
+			out.push(Val::Num(ch_idx as f64));
 		}
 	}
 	out.into()
@@ -117,11 +117,6 @@
 }
 
 fn parse_nat<const BASE: u32>(raw: &str) -> Result<f64> {
-	debug_assert!(
-		1 <= BASE && BASE <= 16,
-		"integer base should be between 1 and 16"
-	);
-
 	const ZERO_CODE: u32 = '0' as u32;
 	const UPPER_A_CODE: u32 = 'A' as u32;
 	const LOWER_A_CODE: u32 = 'a' as u32;
@@ -135,10 +130,17 @@
 		}
 	}
 
-	let base = BASE as f64;
+	debug_assert!(
+		1 <= BASE && BASE <= 16,
+		"integer base should be between 1 and 16"
+	);
+
+	let base = f64::from(BASE);
 
 	raw.chars().try_fold(0f64, |aggregate, digit| {
 		let digit = digit as u32;
+		// if-let-else looks better here than Option combinators
+		#[allow(clippy::option_if_let_else)]
 		let digit = if let Some(digit) = checked_sub_if(BASE > 10, digit, LOWER_A_CODE) {
 			digit + 10
 		} else if let Some(digit) = checked_sub_if(BASE > 10, digit, UPPER_A_CODE) {
@@ -148,7 +150,7 @@
 		};
 
 		if digit < BASE {
-			Ok(base * aggregate + digit as f64)
+			Ok(base.mul_add(aggregate, f64::from(digit)))
 		} else {
 			bail!("{raw:?} is not a base {BASE} integer");
 		}
modifiedcrates/jrsonnet-types/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-types/src/lib.rs
+++ b/crates/jrsonnet-types/src/lib.rs
@@ -166,9 +166,9 @@
 
 fn print_array(a: &ComplexValType, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 	if *a == ComplexValType::Any {
-		write!(f, "array")?
+		write!(f, "array")?;
 	} else {
-		write!(f, "Array<{a}>")?
+		write!(f, "Array<{a}>")?;
 	}
 	Ok(())
 }
@@ -176,18 +176,20 @@
 impl Display for ComplexValType {
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		match self {
-			ComplexValType::Any => write!(f, "any")?,
-			ComplexValType::Simple(s) => write!(f, "{s}")?,
-			ComplexValType::Char => write!(f, "char")?,
-			ComplexValType::BoundedNumber(a, b) => write!(
+			Self::Any => write!(f, "any")?,
+			Self::Simple(s) => write!(f, "{s}")?,
+			Self::Char => write!(f, "char")?,
+			Self::BoundedNumber(a, b) => write!(
 				f,
 				"BoundedNumber<{}, {}>",
-				a.map(|e| e.to_string()).unwrap_or_else(|| "".into()),
-				b.map(|e| e.to_string()).unwrap_or_else(|| "".into())
+				a.map(|e| e.to_string())
+					.unwrap_or_else(|| "open".to_owned()),
+				b.map(|e| e.to_string())
+					.unwrap_or_else(|| "open".to_owned())
 			)?,
-			ComplexValType::ArrayRef(a) => print_array(a, f)?,
-			ComplexValType::Array(a) => print_array(a, f)?,
-			ComplexValType::ObjectRef(fields) => {
+			Self::ArrayRef(a) => print_array(a, f)?,
+			Self::Array(a) => print_array(a, f)?,
+			Self::ObjectRef(fields) => {
 				write!(f, "{{")?;
 				for (i, (k, v)) in fields.iter().enumerate() {
 					if i != 0 {
@@ -197,18 +199,18 @@
 				}
 				write!(f, "}}")?;
 			}
-			ComplexValType::AttrsOf(a) => {
-				if matches!(a, ComplexValType::Any) {
+			Self::AttrsOf(a) => {
+				if matches!(a, Self::Any) {
 					write!(f, "object")?;
 				} else {
 					write!(f, "AttrsOf<{a}>")?;
 				}
 			}
-			ComplexValType::Union(v) => write_union(f, true, v.iter())?,
-			ComplexValType::UnionRef(v) => write_union(f, true, v.iter().copied())?,
-			ComplexValType::Sum(v) => write_union(f, false, v.iter())?,
-			ComplexValType::SumRef(v) => write_union(f, false, v.iter().copied())?,
-			ComplexValType::Lazy(lazy) => write!(f, "Lazy<{lazy}>")?,
+			Self::Union(v) => write_union(f, true, v.iter())?,
+			Self::UnionRef(v) => write_union(f, true, v.iter().copied())?,
+			Self::Sum(v) => write_union(f, false, v.iter())?,
+			Self::SumRef(v) => write_union(f, false, v.iter().copied())?,
+			Self::Lazy(lazy) => write!(f, "Lazy<{lazy}>")?,
 		};
 		Ok(())
 	}
modifiedtests/suite/std_param_names.jsonnetdiffbeforeafterboth
--- a/tests/suite/std_param_names.jsonnet
+++ b/tests/suite/std_param_names.jsonnet
@@ -49,6 +49,7 @@
     min: ['a', 'b'],
     clamp: ['x', 'minVal', 'maxVal'],
     flattenArrays: ['arrs'],
+    flattenDeepArray: ['value'],
     manifestIni: ['ini'],
     manifestToml: ['value'],
     manifestTomlEx: ['value', 'indent'],