git.delta.rocks / jrsonnet / refs/commits / 70f37833046b

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2022-10-11parent: #afca252.patch.diff
in: master

20 files changed

modifiedbindings/jsonnet/src/lib.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/lib.rs
+++ b/bindings/jsonnet/src/lib.rs
@@ -70,6 +70,7 @@
 
 /// Creates a new Jsonnet virtual machine.
 #[no_mangle]
+#[allow(clippy::box_default)]
 pub extern "C" fn jsonnet_make() -> *mut State {
 	let state = State::default();
 	state.settings_mut().import_resolver = Box::new(FileImportResolver::default());
modifiedcrates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/stdlib.rs
+++ b/crates/jrsonnet-cli/src/stdlib.rs
@@ -44,7 +44,7 @@
 		if out.len() != 2 {
 			return Err("bad ext-file syntax".to_owned());
 		}
-		let file = read_to_string(&out[1]);
+		let file = read_to_string(out[1]);
 		match file {
 			Ok(content) => Ok(Self {
 				name: out[0].into(),
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -100,7 +100,7 @@
 	#[error("duplicate local var: {0}")]
 	DuplicateLocalVar(IStr),
 
-	#[error("type mismatch: expected {}, got {2} {0}", .1.iter().map(|e| format!("{}", e)).collect::<Vec<_>>().join(", "))]
+	#[error("type mismatch: expected {}, got {2} {0}", .1.iter().map(|e| format!("{e}")).collect::<Vec<_>>().join(", "))]
 	TypeMismatch(&'static str, Vec<ValType>, ValType),
 	#[error("no such field: {}{}", format_empty_str(.0), format_found(.1, "field"))]
 	NoSuchField(IStr, Vec<IStr>),
@@ -113,7 +113,7 @@
 	BindingParameterASecondTime(IStr),
 	#[error("too many args, function has {0}{}", format_signature(.1))]
 	TooManyArgsFunctionHas(usize, FunctionSignature),
-	#[error("function argument is not passed: {}{}", .0.as_ref().map(|n| n.as_str()).unwrap_or("<unnamed>"), format_signature(.1))]
+	#[error("function argument is not passed: {}{}", .0.as_ref().map_or("<unnamed>", IStr::as_str), format_signature(.1))]
 	FunctionParameterNotBoundInCall(Option<IStr>, FunctionSignature),
 
 	#[error("external variable is not defined: {0}")]
@@ -249,7 +249,7 @@
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		writeln!(f, "{}", self.0 .0)?;
 		for el in &self.0 .1 .0 {
-			writeln!(f, "\t{:?}", el)?;
+			writeln!(f, "\t{el:?}")?;
 		}
 		Ok(())
 	}
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -436,7 +436,7 @@
 		UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(s, ctx, v)?)?,
 		Var(name) => s.push(
 			CallLocation::new(loc),
-			|| format!("variable <{}> access", name),
+			|| format!("variable <{name}> access"),
 			|| ctx.binding(name.clone())?.evaluate(s.clone()),
 		)?,
 		Index(value, index) => {
@@ -446,7 +446,7 @@
 			) {
 				(Val::Obj(v), Val::Str(key)) => s.push(
 					CallLocation::new(loc),
-					|| format!("field <{}> access", key),
+					|| format!("field <{key}> access"),
 					|| match v.get(s.clone(), key.clone()) {
 						Ok(Some(v)) => Ok(v),
 						#[cfg(not(feature = "friendly-errors"))]
@@ -611,7 +611,7 @@
 				if let Some(value) = expr {
 					Ok(Some(s.push(
 						loc,
-						|| format!("slice {}", desc),
+						|| format!("slice {desc}"),
 						|| T::from_untyped(evaluate(s.clone(), ctx.clone(), value)?, s.clone()),
 					)?))
 				} else {
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs
@@ -30,8 +30,8 @@
 		(Str(a), Num(b)) => Str(format!("{a}{b}").into()),
 
 		(Str(a), o) | (o, Str(a)) if a.is_empty() => Val::Str(o.clone().to_string(s)?),
-		(Str(a), o) => Str(format!("{}{}", a, o.clone().to_string(s)?).into()),
-		(o, Str(a)) => Str(format!("{}{}", o.clone().to_string(s)?, a).into()),
+		(Str(a), o) => Str(format!("{a}{}", o.clone().to_string(s)?).into()),
+		(o, Str(a)) => Str(format!("{}{a}", o.clone().to_string(s)?).into()),
 
 		(Obj(v1), Obj(v2)) => Obj(v2.extend_from(v1.clone())),
 		(Arr(a), Arr(b)) => {
modifiedcrates/jrsonnet-evaluator/src/function/arglike.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/arglike.rs
+++ b/crates/jrsonnet-evaluator/src/function/arglike.rs
@@ -108,7 +108,7 @@
 		handler: &mut dyn FnMut(usize, Thunk<Val>) -> Result<()>,
 	) -> Result<()> {
 		for (idx, el) in self.iter().enumerate() {
-			handler(idx, Thunk::evaluated(el.clone()))?
+			handler(idx, Thunk::evaluated(el.clone()))?;
 		}
 		Ok(())
 	}
modifiedcrates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/parse.rs
+++ b/crates/jrsonnet-evaluator/src/function/parse.rs
@@ -179,12 +179,7 @@
 		// FIXME: O(n) for arg existence check
 		let id = params
 			.iter()
-			.position(|p| {
-				p.name
-					.as_ref()
-					.map(|v| &v as &str == name as &str)
-					.unwrap_or(false)
-			})
+			.position(|p| p.name.as_ref().map_or(false, |v| v as &str == name as &str))
 			.ok_or_else(|| UnknownFunctionParameter((name as &str).to_owned()))?;
 		if replace(&mut passed_args[id], Some(arg)).is_some() {
 			throw!(BindingParameterASecondTime(name.clone()));
@@ -209,8 +204,7 @@
 					if param
 						.name
 						.as_ref()
-						.map(|v| &v as &str == name as &str)
-						.unwrap_or(false)
+						.map_or(false, |v| v as &str == name as &str)
 					{
 						found = true;
 					}
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/import.rs
1use std::{2	any::Any,3	cell::RefCell,4	env::current_dir,5	fs,6	io::{ErrorKind, Read},7	path::{Path, PathBuf},8};910use fs::File;11use jrsonnet_parser::{SourceDirectory, SourceFile, SourcePath};1213use crate::{14	error::{15		Error::{self, *},16		Result,17	},18	throw,19};2021/// Implements file resolution logic for `import` and `importStr`22pub trait ImportResolver {23	/// Resolves file path, e.g. `(/home/user/manifests, b.libjsonnet)` can correspond24	/// both to `/home/user/manifests/b.libjsonnet` and to `/home/user/${vendor}/b.libjsonnet`25	/// where `${vendor}` is a library path.26	///27	/// `from` should only be returned from [`ImportResolver::resolve`], or from other defined file, any other value28	/// may result in panic29	fn resolve_from(&self, from: &SourcePath, path: &str) -> Result<SourcePath> {30		throw!(ImportNotSupported(from.clone(), path.into()))31	}32	fn resolve_from_default(&self, path: &str) -> Result<SourcePath> {33		self.resolve_from(&SourcePath::default(), path)34	}35	/// Resolves absolute path, doesn't supports jpath and other fancy things36	fn resolve(&self, path: &Path) -> Result<SourcePath> {37		throw!(AbsoluteImportNotSupported(path.to_owned()))38	}3940	/// Load resolved file41	/// This should only be called with value returned from [`ImportResolver::resolve_file`]/[`ImportResolver::resolve`],42	/// this cannot be resolved using associated type, as evaluator uses object instead of generic for [`ImportResolver`]43	fn load_file_contents(&self, resolved: &SourcePath) -> Result<Vec<u8>>;4445	/// For downcasts46	fn as_any(&self) -> &dyn Any;47}4849/// Dummy resolver, can't resolve/load any file50pub struct DummyImportResolver;51impl ImportResolver for DummyImportResolver {52	fn load_file_contents(&self, _resolved: &SourcePath) -> Result<Vec<u8>> {53		panic!("dummy resolver can't load any file")54	}5556	fn as_any(&self) -> &dyn Any {57		self58	}59}60#[allow(clippy::use_self)]61impl Default for Box<dyn ImportResolver> {62	fn default() -> Self {63		Box::new(DummyImportResolver)64	}65}6667/// File resolver, can load file from both FS and library paths68#[derive(Default)]69pub struct FileImportResolver {70	/// Library directories to search for file.71	/// Referred to as `jpath` in original jsonnet implementation.72	library_paths: RefCell<Vec<PathBuf>>,73}74impl FileImportResolver {75	pub fn new(jpath: Vec<PathBuf>) -> Self {76		Self {77			library_paths: RefCell::new(jpath),78		}79	}80	/// Dynamically add new jpath, used by bindings81	pub fn add_jpath(&self, path: PathBuf) {82		self.library_paths.borrow_mut().push(path);83	}84}85impl ImportResolver for FileImportResolver {86	fn resolve_from(&self, from: &SourcePath, path: &str) -> Result<SourcePath> {87		let mut direct = if let Some(f) = from.downcast_ref::<SourceFile>() {88			let mut o = f.path().to_owned();89			o.pop();90			o91		} else if let Some(d) = from.downcast_ref::<SourceDirectory>() {92			d.path().to_owned()93		} else if from.is_default() {94			current_dir().map_err(|e| Error::ImportIo(e.to_string()))?95		} else {96			unreachable!("resolver can't return this path")97		};98		direct.push(path);99		if direct.is_file() {100			Ok(SourcePath::new(SourceFile::new(101				direct.canonicalize().map_err(|e| ImportIo(e.to_string()))?,102			)))103		} else {104			for library_path in self.library_paths.borrow().iter() {105				let mut cloned = library_path.clone();106				cloned.push(path);107				if cloned.exists() {108					return Ok(SourcePath::new(SourceFile::new(109						cloned.canonicalize().map_err(|e| ImportIo(e.to_string()))?,110					)));111				}112			}113			throw!(ImportFileNotFound(from.clone(), path.to_owned()))114		}115	}116	fn resolve(&self, path: &Path) -> Result<SourcePath> {117		let meta = match fs::metadata(path) {118			Ok(v) => v,119			Err(e) if e.kind() == ErrorKind::NotFound => {120				throw!(AbsoluteImportFileNotFound(path.to_owned()))121			}122			Err(e) => throw!(Error::ImportIo(e.to_string())),123		};124		if meta.is_file() {125			Ok(SourcePath::new(SourceFile::new(126				path.canonicalize()127					.map_err(|e| ImportIo(e.to_string()))?128					.to_owned(),129			)))130		} else if meta.is_dir() {131			Ok(SourcePath::new(SourceDirectory::new(132				path.canonicalize()133					.map_err(|e| ImportIo(e.to_string()))?134					.to_owned(),135			)))136		} else {137			unreachable!("this can't be a symlink")138		}139	}140141	fn load_file_contents(&self, id: &SourcePath) -> Result<Vec<u8>> {142		let path = if let Some(f) = id.downcast_ref::<SourceFile>() {143			f.path()144		} else if id.downcast_ref::<SourceDirectory>().is_some() || id.is_default() {145			throw!(Error::ImportIsADirectory(id.clone()))146		} else {147			unreachable!("other types are not supported in resolve");148		};149		let mut file = File::open(path).map_err(|_e| ResolvedFileNotFound(id.clone()))?;150		let mut out = Vec::new();151		file.read_to_end(&mut out)152			.map_err(|e| ImportIo(e.to_string()))?;153		Ok(out)154	}155156	fn as_any(&self) -> &dyn Any {157		self158	}159160	fn resolve_from_default(&self, path: &str) -> Result<SourcePath> {161		self.resolve_from(&SourcePath::default(), path)162	}163}
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -16,7 +16,7 @@
 			Self::Null => Val::Null,
 			Self::Bool(v) => Val::Bool(v),
 			Self::Number(n) => Val::Num(n.as_f64().ok_or_else(|| {
-				RuntimeError(format!("json number can't be represented as jsonnet: {}", n).into())
+				RuntimeError(format!("json number can't be represented as jsonnet: {n}").into())
 			})?),
 			Self::String(s) => Val::Str((&s as &str).into()),
 			Self::Array(a) => {
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -594,7 +594,7 @@
 			.insert(name, TlaArg::String(value));
 	}
 	pub fn add_tla_code(&self, name: IStr, code: &str) -> Result<()> {
-		let source_name = format!("<top-level-arg:{}>", name);
+		let source_name = format!("<top-level-arg:{name}>");
 		let source = Source::new_virtual(source_name.into(), code.into());
 		let parsed = jrsonnet_parser::parse(
 			code,
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -156,9 +156,9 @@
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		if let Some(super_obj) = self.0.sup.as_ref() {
 			if f.alternate() {
-				write!(f, "{:#?}", super_obj)?;
+				write!(f, "{super_obj:#?}")?;
 			} else {
-				write!(f, "{:?}", super_obj)?;
+				write!(f, "{super_obj:?}")?;
 			}
 			write!(f, " + ")?;
 		}
@@ -395,10 +395,9 @@
 			})?;
 		self.0.value_cache.borrow_mut().insert(
 			key,
-			match &value {
-				Some(v) => CacheValue::Cached(v.clone()),
-				None => CacheValue::NotFound,
-			},
+			value
+				.as_ref()
+				.map_or(CacheValue::NotFound, |v| CacheValue::Cached(v.clone())),
 		);
 		Ok(value)
 	}
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -45,7 +45,7 @@
 		let mut i = 1;
 		while i < bytes.len() {
 			if bytes[i] == b')' {
-				return Ok((&str[1..i as usize], &str[i as usize + 1..]));
+				return Ok((&str[1..i], &str[i + 1..]));
 			}
 			i += 1;
 		}
@@ -310,6 +310,7 @@
 		nums
 	};
 	let neg = iv < 0.0;
+	#[allow(clippy::bool_to_int_with_if)]
 	let zp = padding.saturating_sub(if neg || blank || sign { 1 } else { 0 });
 	let zp2 = zp
 		.max(precision)
@@ -406,6 +407,7 @@
 	ensure_pt: bool,
 	trailing: bool,
 ) {
+	#[allow(clippy::bool_to_int_with_if)]
 	let dot_size = if precision == 0 && !ensure_pt { 0 } else { 1 };
 	padding = padding.saturating_sub(dot_size + precision);
 	render_decimal(out, n.floor(), padding, 0, blank, sign);
@@ -478,10 +480,7 @@
 	precision: Option<usize>,
 ) -> Result<()> {
 	let clfags = &code.cflags;
-	let (fpprec, iprec) = match precision {
-		Some(v) => (v, v),
-		None => (6, 0),
-	};
+	let (fpprec, iprec) = precision.map_or((6, 0), |v| (v, v));
 	let padding = if clfags.zero && !clfags.left {
 		width
 	} else {
@@ -586,8 +585,10 @@
 			}
 		}
 		ConvTypeV::Char => match value.clone() {
-			Val::Num(n) => tmp_out
-				.push(std::char::from_u32(n as u32).ok_or(InvalidUnicodeCodepointGot(n as u32))?),
+			Val::Num(n) => tmp_out.push(
+				std::char::from_u32(n as u32)
+					.ok_or_else(|| InvalidUnicodeCodepointGot(n as u32))?,
+			),
 			Val::Str(s) => {
 				if s.chars().count() != 1 {
 					throw!(RuntimeError(
modifiedcrates/jrsonnet-evaluator/src/stdlib/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/manifest.rs
@@ -49,7 +49,7 @@
 		}
 		Val::Null => buf.push_str("null"),
 		Val::Str(s) => escape_string_json_buf(s, buf),
-		Val::Num(n) => write!(buf, "{}", n).unwrap(),
+		Val::Num(n) => write!(buf, "{n}").unwrap(),
 		Val::Arr(items) => {
 			buf.push('[');
 			if !items.is_empty() {
modifiedcrates/jrsonnet-evaluator/src/stdlib/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/mod.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/mod.rs
@@ -12,7 +12,7 @@
 pub fn std_format(s: State, str: IStr, vals: Val) -> Result<String> {
 	s.push(
 		CallLocation::native(),
-		|| format!("std.format of {}", str),
+		|| format!("std.format of {str}"),
 		|| {
 			Ok(match vals {
 				Val::Arr(vals) => format_arr(s.clone(), &str, &vals.evaluated(s.clone())?)?,
modifiedcrates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/trace/mod.rs
+++ b/crates/jrsonnet-evaluator/src/trace/mod.rs
@@ -16,12 +16,9 @@
 }
 
 impl PathResolver {
-	/// Will return Self::Relative(cwd), or Self::Absolute on cwd failure
+	/// Will return `Self::Relative(cwd)`, or `Self::Absolute` on cwd failure
 	pub fn new_cwd_fallback() -> Self {
-		match std::env::current_dir() {
-			Ok(v) => Self::Relative(v),
-			Err(_) => Self::Absolute,
-		}
+		std::env::current_dir().map_or(Self::Absolute, Self::Relative)
 	}
 	pub fn resolve(&self, from: &Path) -> String {
 		match self {
@@ -97,10 +94,10 @@
 			use std::fmt::Write;
 
 			writeln!(out)?;
-			let mut n = match path.source_path().path() {
-				Some(r) => self.resolver.resolve(r),
-				None => path.source_path().to_string(),
-			};
+			let mut n = path.source_path().path().map_or_else(
+				|| path.source_path().to_string(),
+				|r| self.resolver.resolve(r),
+			);
 			let mut offset = error.location.offset;
 			let is_eof = if offset >= path.code().len() {
 				offset = path.code().len().saturating_sub(1);
@@ -119,7 +116,7 @@
 
 			write!(n, ":").unwrap();
 			print_code_location(&mut n, &location, &location).unwrap();
-			write!(out, "{:<p$}{}", "", n, p = self.padding,)?;
+			write!(out, "{:<p$}{n}", "", p = self.padding)?;
 		}
 		let file_names = error
 			.trace()
@@ -185,10 +182,10 @@
 			let desc = &item.desc;
 			if let Some(source) = &item.location {
 				let start_end = source.0.map_source_locations(&[source.1, source.2]);
-				let resolved_path = match source.0.source_path().path() {
-					Some(r) => r.display().to_string(),
-					None => source.0.source_path().to_string(),
-				};
+				let resolved_path = source.0.source_path().path().map_or_else(
+					|| source.0.source_path().to_string(),
+					|r| r.display().to_string(),
+				);
 
 				write!(
 					out,
@@ -196,7 +193,7 @@
 					desc, resolved_path, start_end[0].line, start_end[0].column,
 				)?;
 			} else {
-				write!(out, "    during {}", desc)?;
+				write!(out, "    during {desc}")?;
 			}
 		}
 		Ok(())
@@ -252,7 +249,7 @@
 					desc,
 				)?;
 			} else {
-				write!(out, "{}", desc)?;
+				write!(out, "{desc}")?;
 			}
 		}
 		Ok(())
@@ -280,10 +277,10 @@
 			.take(end.line_end_offset - end.line_start_offset)
 			.collect();
 
-		let origin = match origin.source_path().path() {
-			Some(r) => self.resolver.resolve(r),
-			None => origin.source_path().to_string(),
-		};
+		let origin = origin.source_path().path().map_or_else(
+			|| origin.source_path().to_string(),
+			|r| self.resolver.resolve(r),
+		);
 		let snippet = Snippet {
 			opt: FormatOptions {
 				color: true,
@@ -308,7 +305,7 @@
 		};
 
 		let dl = DisplayList::from(snippet);
-		write!(out, "{}", dl)?;
+		write!(out, "{dl}")?;
 
 		Ok(())
 	}
modifiedcrates/jrsonnet-evaluator/src/typed/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/mod.rs
+++ b/crates/jrsonnet-evaluator/src/typed/mod.rs
@@ -21,8 +21,8 @@
 	UnionFailed(ComplexValType, TypeLocErrorList),
 	#[error(
 		"number out of bounds: {0} not in {}..{}",
-		.1.map(|v|v.to_string()).unwrap_or_else(|| "".to_owned()),
-		.2.map(|v|v.to_string()).unwrap_or_else(|| "".to_owned()),
+		.1.map(|v|v.to_string()).unwrap_or_default(),
+		.2.map(|v|v.to_string()).unwrap_or_default(),
 	)]
 	BoundsFailed(f64, Option<f64>, Option<f64>),
 }
@@ -65,7 +65,7 @@
 				writeln!(f)?;
 			}
 			out.clear();
-			write!(out, "{}", err)?;
+			write!(out, "{err}")?;
 
 			for (i, line) in out.lines().enumerate() {
 				if line.trim().is_empty() {
@@ -77,7 +77,7 @@
 					writeln!(f)?;
 					write!(f, "    ")?;
 				}
-				write!(f, "{}", line)?;
+				write!(f, "{line}")?;
 			}
 		}
 		Ok(())
@@ -125,8 +125,8 @@
 impl Display for ValuePathItem {
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		match self {
-			Self::Field(name) => write!(f, ".{:?}", name)?,
-			Self::Index(idx) => write!(f, "[{}]", idx)?,
+			Self::Field(name) => write!(f, ".{name:?}")?,
+			Self::Index(idx) => write!(f, "[{idx}]")?,
 		}
 		Ok(())
 	}
@@ -138,7 +138,7 @@
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		write!(f, "self")?;
 		for elem in self.0.iter().rev() {
-			write!(f, "{}", elem)?;
+			write!(f, "{elem}")?;
 		}
 		Ok(())
 	}
@@ -171,7 +171,7 @@
 					for (i, item) in a.iter(s.clone()).enumerate() {
 						push_type_description(
 							s.clone(),
-							|| format!("array index {}", i),
+							|| format!("array index {i}"),
 							|| ValuePathItem::Index(i as u64),
 							|| elem_type.check(s.clone(), &item.clone()?),
 						)?;
@@ -185,7 +185,7 @@
 					for (i, item) in a.iter(s.clone()).enumerate() {
 						push_type_description(
 							s.clone(),
-							|| format!("array index {}", i),
+							|| format!("array index {i}"),
 							|| ValuePathItem::Index(i as u64),
 							|| elem_type.check(s.clone(), &item.clone()?),
 						)?;
@@ -200,7 +200,7 @@
 						if let Some(got_v) = obj.get(s.clone(), (*k).into())? {
 							push_type_description(
 								s.clone(),
-								|| format!("property {}", k),
+								|| format!("property {k}"),
 								|| ValuePathItem::Field((*k).into()),
 								|| v.check(s.clone(), &got_v),
 							)?;
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -292,7 +292,7 @@
 				if index >= v.to() {
 					return Ok(None);
 				}
-				v.inner.get(s, index as usize)
+				v.inner.get(s, index)
 			}
 		}
 	}
@@ -332,7 +332,7 @@
 				if index >= s.to() {
 					return None;
 				}
-				s.inner.get_lazy(index as usize)
+				s.inner.get_lazy(index)
 			}
 		}
 	}
@@ -531,8 +531,9 @@
 	}
 }
 
-#[cfg(target_pointer_width = "64")]
-static_assertions::assert_eq_size!(Val, [u8; 32]);
+// Broken between stable and nightly, as there is new layout size optimization
+// #[cfg(target_pointer_width = "64")]
+// static_assertions::assert_eq_size!(Val, [u8; 24]);
 
 impl Val {
 	pub const fn as_bool(&self) -> Option<bool> {
modifiedcrates/jrsonnet-stdlib/src/encoding.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/encoding.rs
+++ b/crates/jrsonnet-stdlib/src/encoding.rs
@@ -28,7 +28,7 @@
 
 #[builtin]
 pub fn builtin_base64_decode_bytes(input: IStr) -> Result<IBytes> {
-	Ok(base64::decode(&input.as_bytes())
+	Ok(base64::decode(input.as_bytes())
 		.map_err(|_| RuntimeError("bad base64".into()))?
 		.as_slice()
 		.into())
@@ -36,6 +36,6 @@
 
 #[builtin]
 pub fn builtin_base64_decode(input: IStr) -> Result<String> {
-	let bytes = base64::decode(&input.as_bytes()).map_err(|_| RuntimeError("bad base64".into()))?;
+	let bytes = base64::decode(input.as_bytes()).map_err(|_| RuntimeError("bad base64".into()))?;
 	Ok(String::from_utf8(bytes).map_err(|_| RuntimeError("bad utf8".into()))?)
 }
modifiedcrates/jrsonnet-stdlib/src/hash.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/hash.rs
+++ b/crates/jrsonnet-stdlib/src/hash.rs
@@ -2,5 +2,5 @@
 
 #[builtin]
 pub fn builtin_md5(str: IStr) -> Result<String> {
-	Ok(format!("{:x}", md5::compute(&str.as_bytes())))
+	Ok(format!("{:x}", md5::compute(str.as_bytes())))
 }
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -366,7 +366,7 @@
 
 #[builtin]
 fn builtin_substr(str: IStr, from: usize, len: usize) -> Result<String> {
-	Ok(str.chars().skip(from as usize).take(len as usize).collect())
+	Ok(str.chars().skip(from).take(len).collect())
 }
 
 #[builtin(fields(
@@ -380,7 +380,7 @@
 		.ext_vars
 		.get(&x)
 		.cloned()
-		.ok_or(UndefinedExternalVariable(x))?
+		.ok_or_else(|| UndefinedExternalVariable(x))?
 		.evaluate_arg(s.clone(), ctx, true)?
 		.evaluate(s)?))
 }
@@ -402,7 +402,7 @@
 
 #[builtin]
 fn builtin_char(n: u32) -> Result<char> {
-	Ok(std::char::from_u32(n as u32).ok_or(InvalidUnicodeCodepointGot(n as u32))?)
+	Ok(std::char::from_u32(n).ok_or_else(|| InvalidUnicodeCodepointGot(n))?)
 }
 
 #[builtin(fields(