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

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2023-01-20parent: #974f2c1.patch.diff
in: master

16 files changed

modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -5,7 +5,7 @@
 
 use clap::{CommandFactory, Parser};
 use clap_complete::Shell;
-use jrsonnet_cli::{ManifestOpts, OutputOpts, TraceOpts, MiscOpts, TlaOpts, StdOpts, GcOpts};
+use jrsonnet_cli::{GcOpts, ManifestOpts, MiscOpts, OutputOpts, StdOpts, TlaOpts, TraceOpts};
 use jrsonnet_evaluator::{
 	apply_tla,
 	error::{Error as JrError, ErrorKind},
@@ -133,16 +133,14 @@
 
 fn main_catch(opts: Opts) -> bool {
 	let s = State::default();
-	let trace = opts
-		.trace
-		.trace_format();
+	let trace = opts.trace.trace_format();
 	if let Err(e) = main_real(&s, opts) {
 		if let Error::Evaluation(e) = e {
 			let mut out = String::new();
 			trace.write_trace(&mut out, &e).expect("format error");
 			eprintln!("{out}")
 		} else {
-			eprintln!("{}", e);
+			eprintln!("{e}");
 		}
 		return false;
 	}
@@ -150,7 +148,7 @@
 }
 
 fn main_real(s: &State, opts: Opts) -> Result<(), Error> {
-	let _gc_leak_guard= opts.gc.leak_on_exit();
+	let _gc_leak_guard = opts.gc.leak_on_exit();
 	let _gc_print_stats = opts.gc.stats_printer();
 	let _stack_depth_override = opts.misc.stack_size_override();
 
@@ -220,7 +218,7 @@
 	} else {
 		let output = val.manifest(manifest_format)?;
 		if !output.is_empty() {
-			println!("{}", output);
+			println!("{output}");
 		}
 	}
 
modifiedcrates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/lib.rs
+++ b/crates/jrsonnet-cli/src/lib.rs
@@ -6,7 +6,10 @@
 use std::{env, marker::PhantomData, path::PathBuf};
 
 use clap::Parser;
-use jrsonnet_evaluator::{error::Result, stack::{set_stack_depth_limit, StackDepthLimitOverrideGuard, limit_stack_depth}, FileImportResolver, State, ImportResolver};
+use jrsonnet_evaluator::{
+	stack::{limit_stack_depth, StackDepthLimitOverrideGuard},
+	FileImportResolver,
+};
 use jrsonnet_gcmodule::with_thread_object_space;
 pub use manifest::*;
 pub use stdlib::*;
@@ -71,6 +74,7 @@
 }
 impl GcOpts {
 	pub fn stats_printer(&self) -> Option<GcStatsPrinter> {
+		#[allow(clippy::unnecessary_lazy_evaluations/*, reason = "GcStatsPrinter has side-effect on Drop"*/)]
 		self.gc_print_stats.then(|| GcStatsPrinter {
 			collect_before_printing_stats: self.gc_collect_before_printing_stats,
 		})
@@ -96,7 +100,7 @@
 		eprintln!("=== GC STATS ===");
 		if self.collect_before_printing_stats {
 			let collected = jrsonnet_gcmodule::collect_thread_cycles();
-			eprintln!("Collected: {}", collected);
+			eprintln!("Collected: {collected}");
 		}
 		eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked())
 	}
modifiedcrates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -1,10 +1,8 @@
 use std::path::PathBuf;
 
 use clap::{Parser, ValueEnum};
-use jrsonnet_evaluator::{
-	error::Result,
-	manifest::{JsonFormat, ManifestFormat, StringFormat, ToStringFormat, YamlStreamFormat},
-	State,
+use jrsonnet_evaluator::manifest::{
+	JsonFormat, ManifestFormat, StringFormat, ToStringFormat, YamlStreamFormat,
 };
 use jrsonnet_stdlib::{TomlFormat, YamlFormat};
 
modifiedcrates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/stdlib.rs
+++ b/crates/jrsonnet-cli/src/stdlib.rs
@@ -1,7 +1,7 @@
 use std::{fs::read_to_string, str::FromStr};
 
 use clap::Parser;
-use jrsonnet_evaluator::{error::Result, tb, trace::PathResolver, State};
+use jrsonnet_evaluator::{error::Result, trace::PathResolver, State};
 use jrsonnet_stdlib::ContextInitializer;
 
 #[derive(Clone)]
@@ -49,7 +49,7 @@
 				name: out[0].into(),
 				value: content,
 			}),
-			Err(e) => Err(format!("{}", e)),
+			Err(e) => Err(format!("{e}")),
 		}
 	}
 }
@@ -86,8 +86,7 @@
 		if self.no_stdlib {
 			return Ok(None);
 		}
-		let ctx =
-			ContextInitializer::new(s.clone(), PathResolver::new_cwd_fallback());
+		let ctx = ContextInitializer::new(s.clone(), PathResolver::new_cwd_fallback());
 		for ext in self.ext_str.iter() {
 			ctx.add_ext_str((&ext.name as &str).into(), (&ext.value as &str).into());
 		}
modifiedcrates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -3,7 +3,7 @@
 	error::{ErrorKind, Result},
 	function::TlaArg,
 	gc::GcHashMap,
-	IStr, State,
+	IStr,
 };
 use jrsonnet_parser::{ParserSettings, Source};
 
modifiedcrates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/trace.rs
+++ b/crates/jrsonnet-cli/src/trace.rs
@@ -1,9 +1,5 @@
 use clap::{Parser, ValueEnum};
-use jrsonnet_evaluator::{
-	error::Result,
-	trace::{CompactFormat, ExplainingFormat, PathResolver, TraceFormat},
-	State,
-};
+use jrsonnet_evaluator::trace::{CompactFormat, ExplainingFormat, PathResolver, TraceFormat};
 
 #[derive(PartialEq, Eq, ValueEnum, Clone)]
 pub enum TraceFormatName {
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/error.rs
1use std::{2	fmt::{Debug, Display},3	path::PathBuf,4};56use jrsonnet_gcmodule::Trace;7use jrsonnet_interner::IStr;8use jrsonnet_parser::{BinaryOpType, ExprLocation, LocExpr, Source, SourcePath, UnaryOpType};9use jrsonnet_types::ValType;10use thiserror::Error;1112use crate::{function::CallLocation, stdlib::format::FormatError, typed::TypeLocError};1314fn format_found(list: &[IStr], what: &str) -> String {15	if list.is_empty() {16		return String::new();17	}18	let mut out = String::new();19	out.push_str("\nThere is ");20	out.push_str(what);21	if list.len() > 1 {22		out.push('s');23	}24	out.push_str(" with similar name");25	if list.len() > 1 {26		out.push('s');27	}28	out.push_str(" present: ");29	for (i, v) in list.iter().enumerate() {30		if i != 0 {31			out.push_str(", ");32		}33		out.push_str(v as &str);34	}35	out36}3738fn format_signature(sig: &FunctionSignature) -> String {39	let mut out = String::new();40	out.push_str("\nFunction has the following signature: ");41	out.push('(');42	if sig.is_empty() {43		out.push_str("/*no arguments*/");44	} else {45		for (i, (name, has_default)) in sig.iter().enumerate() {46			if i != 0 {47				out.push_str(", ");48			}49			if let Some(name) = name {50				out.push_str(name);51			} else {52				out.push_str("<unnamed>");53			}54			if *has_default {55				out.push_str(" = <default>");56			}57		}58	}59	out.push(')');60	out61}6263const fn format_empty_str(str: &str) -> &str {64	if str.is_empty() {65		"\"\" (empty string)"66	} else {67		str68	}69}7071type FunctionSignature = Vec<(Option<IStr>, bool)>;7273/// Possible errors74#[allow(missing_docs)]75#[derive(Error, Debug, Clone, Trace)]76#[non_exhaustive]77pub enum ErrorKind {78	#[error("intrinsic not found: {0}")]79	IntrinsicNotFound(IStr),8081	#[error("operator {0} does not operate on type {1}")]82	UnaryOperatorDoesNotOperateOnType(UnaryOpType, ValType),83	#[error("binary operation {1} {0} {2} is not implemented")]84	BinaryOperatorDoesNotOperateOnValues(BinaryOpType, ValType, ValType),8586	#[error("no top level object in this context")]87	NoTopLevelObjectFound,88	#[error("self is only usable inside objects")]89	CantUseSelfOutsideOfObject,90	#[error("no super found")]91	NoSuperFound,9293	#[error("for loop can only iterate over arrays")]94	InComprehensionCanOnlyIterateOverArray,9596	#[error("array out of bounds: {0} is not within [0,{1})")]97	ArrayBoundsError(usize, usize),98	#[error("string out of bounds: {0} is not within [0,{1})")]99	StringBoundsError(usize, usize),100101	#[error("assert failed: {}", format_empty_str(.0))]102	AssertionFailed(IStr),103104	#[error("variable is not defined: {0}{}", format_found(.1, "variable"))]105	VariableIsNotDefined(IStr, Vec<IStr>),106	#[error("duplicate local var: {0}")]107	DuplicateLocalVar(IStr),108109	#[error("type mismatch: expected {}, got {2} {0}", .1.iter().map(|e| format!("{e}")).collect::<Vec<_>>().join(", "))]110	TypeMismatch(&'static str, Vec<ValType>, ValType),111	#[error("no such field: {}{}", format_empty_str(.0), format_found(.1, "field"))]112	NoSuchField(IStr, Vec<IStr>),113114	#[error("only functions can be called, got {0}")]115	OnlyFunctionsCanBeCalledGot(ValType),116	#[error("parameter {0} is not defined")]117	UnknownFunctionParameter(String),118	#[error("argument {0} is already bound")]119	BindingParameterASecondTime(IStr),120	#[error("too many args, function has {0}{}", format_signature(.1))]121	TooManyArgsFunctionHas(usize, FunctionSignature),122	#[error("function argument is not passed: {}{}", .0.as_ref().map_or("<unnamed>", IStr::as_str), format_signature(.1))]123	FunctionParameterNotBoundInCall(Option<IStr>, FunctionSignature),124125	#[error("external variable is not defined: {0}")]126	UndefinedExternalVariable(IStr),127128	#[error("field name should be string, got {0}")]129	FieldMustBeStringGot(ValType),130	#[error("duplicate field name: {}", format_empty_str(.0))]131	DuplicateFieldName(IStr),132133	#[error("attempted to index array with string {}", format_empty_str(.0))]134	AttemptedIndexAnArrayWithString(IStr),135	#[error("{0} index type should be {1}, got {2}")]136	ValueIndexMustBeTypeGot(ValType, ValType, ValType),137	#[error("cant index into {0}")]138	CantIndexInto(ValType),139	#[error("{0} is not indexable")]140	ValueIsNotIndexable(ValType),141142	#[error("super can't be used standalone")]143	StandaloneSuper,144145	#[error("can't resolve {1} from {0}")]146	ImportFileNotFound(SourcePath, String),147	#[error("can't resolve absolute {0}")]148	AbsoluteImportFileNotFound(PathBuf),149	#[error("resolved file not found: {:?}", .0)]150	ResolvedFileNotFound(SourcePath),151	#[error("can't import {0}: is a directory")]152	ImportIsADirectory(SourcePath),153	#[error("imported file is not valid utf-8: {0:?}")]154	ImportBadFileUtf8(SourcePath),155	#[error("import io error: {0}")]156	ImportIo(String),157	#[error("tried to import {1} from {0}, but imports are not supported")]158	ImportNotSupported(SourcePath, String),159	#[error("tried to import {0}, but absolute imports are not supported")]160	AbsoluteImportNotSupported(PathBuf),161	#[error("can't import from virtual file")]162	CantImportFromVirtualFile,163	#[error(164		"syntax error: expected {}, got {:?}",165		.error.expected,166		.path.code().chars().nth(error.location.offset)167		.map_or_else(|| "EOF".into(), |c| c.to_string())168	)]169	ImportSyntaxError {170		path: Source,171		#[trace(skip)]172		error: Box<jrsonnet_parser::ParseError>,173	},174175	#[error("runtime error: {}", format_empty_str(.0))]176	RuntimeError(IStr),177	#[error("stack overflow, try to reduce recursion, or set --max-stack to bigger value")]178	StackOverflow,179	#[error("infinite recursion detected")]180	InfiniteRecursionDetected,181	#[error("tried to index by fractional value")]182	FractionalIndex,183	#[error("attempted to divide by zero")]184	DivisionByZero,185186	#[error("string manifest output is not an string")]187	StringManifestOutputIsNotAString,188	#[error("stream manifest output is not an array")]189	StreamManifestOutputIsNotAArray,190	#[error("multi manifest output is not an object")]191	MultiManifestOutputIsNotAObject,192193	#[error("cant recurse stream manifest")]194	StreamManifestOutputCannotBeRecursed,195	#[error("stream manifest output cannot consist of raw strings")]196	StreamManifestCannotNestString,197198	#[error("{}", format_empty_str(.0))]199	ImportCallbackError(String),200	#[error("invalid unicode codepoint: {0}")]201	InvalidUnicodeCodepointGot(u32),202203	#[error("format error: {0}")]204	Format(#[from] FormatError),205	#[error("type error: {0}")]206	TypeError(TypeLocError),207208	#[cfg(feature = "anyhow-error")]209	#[error(transparent)]210	Other(Rc<anyhow::Error>),211}212213#[cfg(feature = "anyhow-error")]214impl From<anyhow::Error> for Error {215	fn from(e: anyhow::Error) -> Self {216		Self::new(ErrorKind::Other(Rc::new(e)))217	}218}219220impl From<ErrorKind> for Error {221	fn from(e: ErrorKind) -> Self {222		Self::new(e)223	}224}225226/// Single stack trace frame227#[derive(Clone, Debug, Trace)]228pub struct StackTraceElement {229	/// Source of this frame230	/// Some frames only act as description, without attached source231	pub location: Option<ExprLocation>,232	/// Frame description233	pub desc: String,234}235#[derive(Debug, Clone, Trace)]236pub struct StackTrace(pub Vec<StackTraceElement>);237238#[derive(Clone, Trace)]239pub struct Error(Box<(ErrorKind, StackTrace)>);240impl Error {241	pub fn new(e: ErrorKind) -> Self {242		Self(Box::new((e, StackTrace(vec![]))))243	}244245	pub const fn error(&self) -> &ErrorKind {246		&(self.0).0247	}248	pub fn error_mut(&mut self) -> &mut ErrorKind {249		&mut (self.0).0250	}251	pub const fn trace(&self) -> &StackTrace {252		&(self.0).1253	}254	pub fn trace_mut(&mut self) -> &mut StackTrace {255		&mut (self.0).1256	}257}258impl Display for Error {259	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {260		writeln!(f, "{}", self.0 .0)?;261		for el in &self.0 .1 .0 {262			write!(f, "\t{}", el.desc)?;263			if let Some(loc) = &el.location {264				write!(f, "at {}", loc.0 .0 .0)?;265				loc.0.map_source_locations(&[loc.1, loc.2]);266			}267			writeln!(f)?;268		}269		Ok(())270	}271}272impl Debug for Error {273	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {274		f.debug_tuple("LocError").field(&self.0).finish()275	}276}277278pub trait ErrorSource {279	fn to_location(self) -> Option<ExprLocation>;280}281impl ErrorSource for &LocExpr {282	fn to_location(self) -> Option<ExprLocation> {283		Some(self.1.clone())284	}285}286impl ErrorSource for &ExprLocation {287	fn to_location(self) -> Option<ExprLocation> {288		Some(self.clone())289	}290}291impl ErrorSource for CallLocation<'_> {292	fn to_location(self) -> Option<ExprLocation> {293		self.0.cloned()294	}295}296297pub type Result<V, E = Error> = std::result::Result<V, E>;298pub trait ResultExt: Sized {299	#[must_use]300	fn with_description<O: Into<String>>(self, msg: impl FnOnce() -> O) -> Self;301	#[must_use]302	fn description(self, msg: &str) -> Self {303		self.with_description(|| msg)304	}305306	#[must_use]307	fn with_description_src<O: Into<String>>(308		self,309		src: impl ErrorSource,310		msg: impl FnOnce() -> O,311	) -> Self;312	#[must_use]313	fn description_src(self, src: impl ErrorSource, msg: &str) -> Self {314		self.with_description_src(src, || msg)315	}316}317impl<T> ResultExt for Result<T, Error> {318	fn with_description<O: Into<String>>(mut self, msg: impl FnOnce() -> O) -> Self {319		if let Err(e) = &mut self {320			let trace = e.trace_mut();321			trace.0.push(StackTraceElement {322				location: None,323				desc: msg().into(),324			});325		}326		self327	}328329	fn with_description_src<O: Into<String>>(330		mut self,331		src: impl ErrorSource,332		msg: impl FnOnce() -> O,333	) -> Self {334		if let Err(e) = &mut self {335			let trace = e.trace_mut();336			trace.0.push(StackTraceElement {337				location: src.to_location(),338				desc: msg().into(),339			});340		}341		self342	}343}344345#[macro_export]346macro_rules! throw {347	($w:ident$(::$i:ident)*$(($($tt:tt)*))?) => {348		return Err($w$(::$i)*$(($($tt)*))?.into())349	};350	($l:literal) => {351		return Err($crate::error::ErrorKind::RuntimeError($l.into()).into())352	};353	($l:literal, $($tt:tt)*) => {354		return Err($crate::error::ErrorKind::RuntimeError(format!($l, $($tt)*).into()).into())355	};356}
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs
@@ -104,28 +104,15 @@
 					}
 				}
 			} else {
-				{
-					let ai = a.iter();
-					let bi = b.iter();
+				let ai = a.iter();
+				let bi = b.iter();
 
-					for (a, b) in ai.zip(bi) {
-						let ord = evaluate_compare_op(&a?, &b?, op)?;
-						if !ord.is_eq() {
-							return Ok(ord);
-						}
+				for (a, b) in ai.zip(bi) {
+					let ord = evaluate_compare_op(&a?, &b?, op)?;
+					if !ord.is_eq() {
+						return Ok(ord);
 					}
 				}
-				// {
-				// 	let ai = a.iter_expl();
-				// 	let bi = b.iter_expl();
-
-				// 	for (a, b) in ai.zip(bi) {
-				// 		let ord = evaluate_compare_op(&a?, &b?, op)?;
-				// 		if !ord.is_eq() {
-				// 			return Ok(ord);
-				// 		}
-				// 	}
-				// }
 			}
 			a.len().cmp(&b.len())
 		}
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -36,6 +36,7 @@
 	clippy::use_self,
 	// https://github.com/rust-lang/rust-clippy/issues/8539
 	clippy::iter_with_drain,
+	clippy::type_repetition_in_bounds,
 	// ci is being run with nightly, but library should work on stable
 	clippy::missing_const_for_fn,
 )]
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -54,7 +54,7 @@
 
 #[cfg(feature = "exp-preserve-order")]
 mod ordering {
-	use std::cmp::Reverse;
+	use std::cmp::{Ordering, Reverse};
 
 	use jrsonnet_gcmodule::Trace;
 
@@ -81,12 +81,10 @@
 			Self(Reverse(depth), index)
 		}
 		pub fn collide(self, other: Self) -> Self {
-			if self.0 .0 > other.0 .0 {
-				self
-			} else if self.0 .0 < other.0 .0 {
-				other
-			} else {
-				unreachable!("object can't have two fields with same name")
+			match self.0 .0.cmp(&other.0 .0) {
+				Ordering::Greater => self,
+				Ordering::Less => other,
+				Ordering::Equal => unreachable!("object can't have two fields with the same name"),
 			}
 		}
 	}
@@ -188,6 +186,12 @@
 	pub fn new_empty() -> Self {
 		Self::new(None, Cc::new(GcHashMap::new()), Cc::new(Vec::new()))
 	}
+	pub fn builder() -> ObjValueBuilder {
+		ObjValueBuilder::new()
+	}
+	pub fn builder_with_capacity(capacity: usize) -> ObjValueBuilder {
+		ObjValueBuilder::with_capacity(capacity)
+	}
 	#[must_use]
 	pub fn extend_from(&self, sup: Self) -> Self {
 		match &self.0.sup {
@@ -304,7 +308,7 @@
 						break;
 					}
 					fields[j] = fields[k].clone();
-					j = k
+					j = k;
 				}
 				fields[j] = x;
 			}
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -33,6 +33,7 @@
 	Pending,
 }
 
+/// Lazily evaluated value
 #[allow(clippy::module_name_repetitions)]
 #[derive(Clone, Trace)]
 pub struct Thunk<T: Trace>(Cc<RefCell<ThunkInner<T>>>);
@@ -57,6 +58,13 @@
 		self.evaluate()?;
 		Ok(())
 	}
+
+	/// Evaluate thunk, or return cached value
+	///
+	/// # Errors
+	///
+	/// - Lazy value evaluation returned error
+	/// - This method was called during inner value evaluation
 	pub fn evaluate(&self) -> Result<T> {
 		match &*self.0.borrow() {
 			ThunkInner::Computed(v) => return Ok(v.clone()),
@@ -132,7 +140,7 @@
 	}
 }
 
-/// Represents a Jsonnet value, which can be spliced or indexed (string or array).
+/// Represents a Jsonnet value, which can be sliced or indexed (string or array).
 #[allow(clippy::module_name_repetitions)]
 pub enum IndexableVal {
 	/// String.
@@ -247,6 +255,16 @@
 		}
 	}
 }
+impl From<&str> for StrValue {
+	fn from(value: &str) -> Self {
+		Self::Flat(value.into())
+	}
+}
+impl From<String> for StrValue {
+	fn from(value: String) -> Self {
+		Self::Flat(value.into())
+	}
+}
 impl Display for StrValue {
 	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 		match self {
modifiedcrates/jrsonnet-parser/src/source.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/source.rs
+++ b/crates/jrsonnet-parser/src/source.rs
@@ -33,8 +33,8 @@
 		}
 		fn dyn_eq(&self, other: &dyn $T) -> bool {
 			let Some(other) = other.as_any().downcast_ref::<Self>() else {
-												return false
-											};
+				return false
+			};
 			let this = <Self as $T>::as_any(self)
 				.downcast_ref::<Self>()
 				.expect("restricted by impl");
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -211,7 +211,7 @@
 				locs[0].line
 			);
 		}
-		eprintln!(" {}", value);
+		eprintln!(" {value}");
 	}
 }
 
@@ -229,7 +229,7 @@
 }
 
 fn extvar_source(name: &str, code: impl Into<IStr>) -> Source {
-	let source_name = format!("<extvar:{}>", name);
+	let source_name = format!("<extvar:{name}>");
 	Source::new_virtual(source_name.into(), code.into())
 }
 
modifiedcrates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/misc.rs
+++ b/crates/jrsonnet-stdlib/src/misc.rs
@@ -46,7 +46,7 @@
 		.ext_natives
 		.get(&x)
 		.cloned()
-		.map_or(Val::Null, |v| Val::Func(FuncVal::Builtin(v.clone())))
+		.map_or(Val::Null, |v| Val::Func(FuncVal::Builtin(v)))
 }
 
 #[builtin(fields(
modifiedcrates/jrsonnet-stdlib/src/parse.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/parse.rs
+++ b/crates/jrsonnet-stdlib/src/parse.rs
@@ -8,7 +8,7 @@
 #[builtin]
 pub fn builtin_parse_json(str: IStr) -> Result<Val> {
 	let value: Val = serde_json::from_str(&str)
-		.map_err(|e| RuntimeError(format!("failed to parse json: {}", e).into()))?;
+		.map_err(|e| RuntimeError(format!("failed to parse json: {e}").into()))?;
 	Ok(value)
 }
 
@@ -22,7 +22,7 @@
 	let mut out = vec![];
 	for item in value {
 		let val = Val::deserialize(item)
-			.map_err(|e| RuntimeError(format!("failed to parse yaml: {}", e).into()))?;
+			.map_err(|e| RuntimeError(format!("failed to parse yaml: {e}").into()))?;
 		out.push(val);
 	}
 	Ok(if out.is_empty() {
modifiedcrates/jrsonnet-types/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-types/src/lib.rs
+++ b/crates/jrsonnet-types/src/lib.rs
@@ -150,7 +150,7 @@
 		if should_add_braces {
 			write!(f, "(")?;
 		}
-		write!(f, "{}", v)?;
+		write!(f, "{v}")?;
 		if should_add_braces {
 			write!(f, ")")?;
 		}
@@ -162,7 +162,7 @@
 	if *a == ComplexValType::Any {
 		write!(f, "array")?
 	} else {
-		write!(f, "Array<{}>", a)?
+		write!(f, "Array<{a}>")?
 	}
 	Ok(())
 }
@@ -171,7 +171,7 @@
 	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::Simple(s) => write!(f, "{s}")?,
 			ComplexValType::Char => write!(f, "char")?,
 			ComplexValType::BoundedNumber(a, b) => write!(
 				f,
@@ -187,7 +187,7 @@
 					if i != 0 {
 						write!(f, ", ")?;
 					}
-					write!(f, "{}: {}", k, v)?;
+					write!(f, "{k}: {v}")?;
 				}
 				write!(f, "}}")?;
 			}