git.delta.rocks / jrsonnet / refs/commits / 11643ec5f009

difftreelog

style switch clippy to pedantic

Yaroslav Bolyukin2022-04-22parent: #b4a4398.patch.diff
in: master

25 files changed

modifiedcrates/jrsonnet-evaluator/src/builtin/format.rsdiffbeforeafterboth
after · crates/jrsonnet-evaluator/src/builtin/format.rs
1//! faster std.format impl2#![allow(clippy::too_many_arguments)]34use gcmodule::Trace;5use jrsonnet_interner::IStr;6use jrsonnet_types::ValType;7use thiserror::Error;89use crate::{error::Error::*, throw, typed::Typed, LocError, ObjValue, Result, State, Val};1011#[derive(Debug, Clone, Error, Trace)]12pub enum FormatError {13	#[error("truncated format code")]14	TruncatedFormatCode,15	#[error("unrecognized conversion type: {0}")]16	UnrecognizedConversionType(char),1718	#[error("not enough values")]19	NotEnoughValues,2021	#[error("cannot use * width with object")]22	CannotUseStarWidthWithObject,23	#[error("mapping keys required")]24	MappingKeysRequired,25	#[error("no such format field: {0}")]26	NoSuchFormatField(IStr),27}2829impl From<FormatError> for LocError {30	fn from(e: FormatError) -> Self {31		Self::new(Format(e))32	}33}3435use FormatError::*;3637type ParseResult<'t, T> = std::result::Result<(T, &'t str), FormatError>;3839pub fn try_parse_mapping_key(str: &str) -> ParseResult<&str> {40	if str.is_empty() {41		return Err(TruncatedFormatCode);42	}43	let bytes = str.as_bytes();44	if bytes[0] == b'(' {45		let mut i = 1;46		while i < bytes.len() {47			if bytes[i] == b')' {48				return Ok((&str[1..i as usize], &str[i as usize + 1..]));49			}50			i += 1;51		}52		Err(TruncatedFormatCode)53	} else {54		Ok(("", str))55	}56}5758#[cfg(test)]59pub mod tests_key {60	use super::*;6162	#[test]63	fn parse_key() {64		assert_eq!(65			try_parse_mapping_key("(hello ) world").unwrap(),66			("hello ", " world")67		);68		assert_eq!(try_parse_mapping_key("() world").unwrap(), ("", " world"));69		assert_eq!(try_parse_mapping_key(" world").unwrap(), ("", " world"));70		assert_eq!(71			try_parse_mapping_key(" () world").unwrap(),72			("", " () world")73		);74	}7576	#[test]77	#[should_panic]78	fn parse_key_missing_start() {79		try_parse_mapping_key("").unwrap();80	}8182	#[test]83	#[should_panic]84	fn parse_key_missing_end() {85		try_parse_mapping_key("(   ").unwrap();86	}87}8889#[allow(clippy::struct_excessive_bools)]90#[derive(Default, Debug)]91pub struct CFlags {92	pub alt: bool,93	pub zero: bool,94	pub left: bool,95	pub blank: bool,96	pub sign: bool,97}9899pub fn try_parse_cflags(str: &str) -> ParseResult<CFlags> {100	if str.is_empty() {101		return Err(TruncatedFormatCode);102	}103	let bytes = str.as_bytes();104	let mut i = 0;105	let mut out = CFlags::default();106	loop {107		if bytes.len() == i {108			return Err(TruncatedFormatCode);109		}110		match bytes[i] {111			b'#' => out.alt = true,112			b'0' => out.zero = true,113			b'-' => out.left = true,114			b' ' => out.blank = true,115			b'+' => out.sign = true,116			_ => break,117		}118		i += 1;119	}120	Ok((out, &str[i..]))121}122123#[derive(Debug, PartialEq)]124pub enum Width {125	Star,126	Fixed(usize),127}128pub fn try_parse_field_width(str: &str) -> ParseResult<Width> {129	if str.is_empty() {130		return Err(TruncatedFormatCode);131	}132	let bytes = str.as_bytes();133	if bytes[0] == b'*' {134		return Ok((Width::Star, &str[1..]));135	}136	let mut out: usize = 0;137	let mut digits = 0;138	while let Some(digit) = (bytes[digits] as char).to_digit(10) {139		out *= 10;140		out += digit as usize;141		digits += 1;142		if digits == bytes.len() {143			return Err(TruncatedFormatCode);144		}145	}146	Ok((Width::Fixed(out), &str[digits..]))147}148149pub fn try_parse_precision(str: &str) -> ParseResult<Option<Width>> {150	if str.is_empty() {151		return Err(TruncatedFormatCode);152	}153	let bytes = str.as_bytes();154	if bytes[0] == b'.' {155		try_parse_field_width(&str[1..]).map(|(r, s)| (Some(r), s))156	} else {157		Ok((None, str))158	}159}160161// Only skips162pub fn try_parse_length_modifier(str: &str) -> ParseResult<()> {163	if str.is_empty() {164		return Err(TruncatedFormatCode);165	}166	let bytes = str.as_bytes();167	let mut idx = 0;168	while bytes[idx] == b'h' || bytes[idx] == b'l' || bytes[idx] == b'L' {169		idx += 1;170		if bytes.len() == idx {171			return Err(TruncatedFormatCode);172		}173	}174	Ok(((), &str[idx..]))175}176177#[derive(Debug, PartialEq)]178pub enum ConvTypeV {179	Decimal,180	Octal,181	Hexadecimal,182	Scientific,183	Float,184	Shorter,185	Char,186	String,187	Percent,188}189pub struct ConvType {190	v: ConvTypeV,191	caps: bool,192}193194pub fn parse_conversion_type(str: &str) -> ParseResult<ConvType> {195	if str.is_empty() {196		return Err(TruncatedFormatCode);197	}198199	let code = str.as_bytes()[0];200	let v: (ConvTypeV, bool) = match code {201		b'd' | b'i' | b'u' => (ConvTypeV::Decimal, false),202		b'o' => (ConvTypeV::Octal, false),203		b'x' => (ConvTypeV::Hexadecimal, false),204		b'X' => (ConvTypeV::Hexadecimal, true),205		b'e' => (ConvTypeV::Scientific, false),206		b'E' => (ConvTypeV::Scientific, true),207		b'f' => (ConvTypeV::Float, false),208		b'F' => (ConvTypeV::Float, true),209		b'g' => (ConvTypeV::Shorter, false),210		b'G' => (ConvTypeV::Shorter, true),211		b'c' => (ConvTypeV::Char, false),212		b's' => (ConvTypeV::String, false),213		b'%' => (ConvTypeV::Percent, false),214		c => return Err(UnrecognizedConversionType(c as char)),215	};216217	Ok((ConvType { v: v.0, caps: v.1 }, &str[1..]))218}219220#[derive(Debug)]221pub struct Code<'s> {222	mkey: &'s str,223	cflags: CFlags,224	width: Width,225	precision: Option<Width>,226	convtype: ConvTypeV,227	caps: bool,228}229pub fn parse_code(str: &str) -> ParseResult<Code> {230	if str.is_empty() {231		return Err(TruncatedFormatCode);232	}233	let (mkey, str) = try_parse_mapping_key(str)?;234	let (cflags, str) = try_parse_cflags(str)?;235	let (width, str) = try_parse_field_width(str)?;236	let (precision, str) = try_parse_precision(str)?;237	let (_, str) = try_parse_length_modifier(str)?;238	let (convtype, str) = parse_conversion_type(str)?;239240	Ok((241		Code {242			mkey,243			cflags,244			width,245			precision,246			convtype: convtype.v,247			caps: convtype.caps,248		},249		str,250	))251}252253#[derive(Debug)]254pub enum Element<'s> {255	String(&'s str),256	Code(Code<'s>),257}258pub fn parse_codes(mut str: &str) -> Result<Vec<Element>> {259	let mut bytes = str.as_bytes();260	let mut out = vec![];261	let mut offset = 0;262263	loop {264		while offset != bytes.len() && bytes[offset] != b'%' {265			offset += 1;266		}267		if offset != 0 {268			out.push(Element::String(&str[0..offset]));269		}270		if offset == bytes.len() {271			return Ok(out);272		}273		str = &str[offset + 1..];274		let code;275		(code, str) = parse_code(str)?;276		bytes = str.as_bytes();277		offset = 0;278279		out.push(Element::Code(code));280	}281}282283const NUMBERS: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyz";284285#[inline]286pub fn render_integer(287	out: &mut String,288	iv: i64,289	padding: usize,290	precision: usize,291	blank: bool,292	sign: bool,293	radix: i64,294	prefix: &str,295	caps: bool,296) {297	// Digit char indexes in reverse order, i.e298	// for radix = 16 and n = 12f: [15, 2, 1]299	let digits = if iv == 0 {300		vec![0u8]301	} else {302		let mut v = iv.abs();303		let mut nums = Vec::with_capacity(1);304		while v > 0 {305			nums.push((v % radix) as u8);306			v /= radix;307		}308		nums309	};310	let neg = iv < 0;311	let zp = padding.saturating_sub(if neg || blank || sign { 1 } else { 0 });312	let zp2 = zp313		.max(precision)314		.saturating_sub(prefix.len() + digits.len());315316	if neg {317		out.push('-');318	} else if sign {319		out.push('+');320	} else if blank {321		out.push(' ');322	}323324	out.reserve(zp2);325	for _ in 0..zp2 {326		out.push('0');327	}328	out.push_str(prefix);329330	for digit in digits.into_iter().rev() {331		let ch = NUMBERS[digit as usize] as char;332		out.push(if caps { ch.to_ascii_uppercase() } else { ch });333	}334}335336pub fn render_decimal(337	out: &mut String,338	iv: i64,339	padding: usize,340	precision: usize,341	blank: bool,342	sign: bool,343) {344	render_integer(out, iv, padding, precision, blank, sign, 10, "", false);345}346pub fn render_octal(347	out: &mut String,348	iv: i64,349	padding: usize,350	precision: usize,351	alt: bool,352	blank: bool,353	sign: bool,354) {355	render_integer(356		out,357		iv,358		padding,359		precision,360		blank,361		sign,362		8,363		if alt && iv != 0 { "0" } else { "" },364		false,365	);366}367368#[allow(clippy::fn_params_excessive_bools)]369pub fn render_hexadecimal(370	out: &mut String,371	iv: i64,372	padding: usize,373	precision: usize,374	alt: bool,375	blank: bool,376	sign: bool,377	caps: bool,378) {379	render_integer(380		out,381		iv,382		padding,383		precision,384		blank,385		sign,386		16,387		match (alt, caps) {388			(true, true) => "0X",389			(true, false) => "0x",390			(false, _) => "",391		},392		caps,393	);394}395396#[allow(clippy::fn_params_excessive_bools)]397pub fn render_float(398	out: &mut String,399	n: f64,400	mut padding: usize,401	precision: usize,402	blank: bool,403	sign: bool,404	ensure_pt: bool,405	trailing: bool,406) {407	let dot_size = if precision == 0 && !ensure_pt { 0 } else { 1 };408	padding = padding.saturating_sub(dot_size + precision);409	render_decimal(out, n.floor() as i64, padding, 0, blank, sign);410	if precision == 0 {411		if ensure_pt {412			out.push('.');413		}414		return;415	}416	let frac = n417		.fract()418		.mul_add(10.0_f64.powf(precision as f64), 0.5)419		.floor();420	if trailing || frac > 0.0 {421		out.push('.');422		let mut frac_str = String::new();423		render_decimal(&mut frac_str, frac as i64, precision, 0, false, false);424		let mut trim = frac_str.len();425		if !trailing {426			for b in frac_str.as_bytes().iter().rev() {427				if *b == b'0' {428					trim -= 1;429				}430			}431		}432		out.push_str(&frac_str[..trim]);433	} else if ensure_pt {434		out.push('.');435	}436}437438#[allow(clippy::fn_params_excessive_bools)]439pub fn render_float_sci(440	out: &mut String,441	n: f64,442	mut padding: usize,443	precision: usize,444	blank: bool,445	sign: bool,446	ensure_pt: bool,447	trailing: bool,448	caps: bool,449) {450	let exponent = n.log10().floor();451	let mantissa = if exponent as i16 == -324 {452		n * 10.0 / 10.0_f64.powf(exponent + 1.0)453	} else {454		n / 10.0_f64.powf(exponent)455	};456	let mut exponent_str = String::new();457	render_decimal(&mut exponent_str, exponent as i64, 3, 0, false, true);458459	// +1 for e460	padding = padding.saturating_sub(exponent_str.len() + 1);461462	render_float(463		out, mantissa, padding, precision, blank, sign, ensure_pt, trailing,464	);465	out.push(if caps { 'E' } else { 'e' });466	out.push_str(&exponent_str);467}468469#[allow(clippy::too_many_lines)]470pub fn format_code(471	s: State,472	out: &mut String,473	value: &Val,474	code: &Code,475	width: usize,476	precision: Option<usize>,477) -> Result<()> {478	let clfags = &code.cflags;479	let (fpprec, iprec) = match precision {480		Some(v) => (v, v),481		None => (6, 0),482	};483	let padding = if clfags.zero && !clfags.left {484		width485	} else {486		0487	};488489	// TODO: If left padded, can optimize by writing directly to out490	let mut tmp_out = String::new();491492	match code.convtype {493		ConvTypeV::String => tmp_out.push_str(&value.clone().to_string(s)?),494		ConvTypeV::Decimal => {495			let value = f64::from_untyped(value.clone(), s)?;496			render_decimal(497				&mut tmp_out,498				value as i64,499				padding,500				iprec,501				clfags.blank,502				clfags.sign,503			);504		}505		ConvTypeV::Octal => {506			let value = f64::from_untyped(value.clone(), s)?;507			render_octal(508				&mut tmp_out,509				value as i64,510				padding,511				iprec,512				clfags.alt,513				clfags.blank,514				clfags.sign,515			);516		}517		ConvTypeV::Hexadecimal => {518			let value = f64::from_untyped(value.clone(), s)?;519			render_hexadecimal(520				&mut tmp_out,521				value as i64,522				padding,523				iprec,524				clfags.alt,525				clfags.blank,526				clfags.sign,527				code.caps,528			);529		}530		ConvTypeV::Scientific => {531			let value = f64::from_untyped(value.clone(), s)?;532			render_float_sci(533				&mut tmp_out,534				value,535				padding,536				fpprec,537				clfags.blank,538				clfags.sign,539				clfags.alt,540				true,541				code.caps,542			);543		}544		ConvTypeV::Float => {545			let value = f64::from_untyped(value.clone(), s)?;546			render_float(547				&mut tmp_out,548				value,549				padding,550				fpprec,551				clfags.blank,552				clfags.sign,553				clfags.alt,554				true,555			);556		}557		ConvTypeV::Shorter => {558			let value = f64::from_untyped(value.clone(), s)?;559			let exponent = value.log10().floor();560			if exponent < -4.0 || exponent >= fpprec as f64 {561				render_float_sci(562					&mut tmp_out,563					value,564					padding,565					fpprec - 1,566					clfags.blank,567					clfags.sign,568					clfags.alt,569					clfags.alt,570					code.caps,571				);572			} else {573				let digits_before_pt = 1.max(exponent as usize + 1);574				render_float(575					&mut tmp_out,576					value,577					padding,578					fpprec - digits_before_pt,579					clfags.blank,580					clfags.sign,581					clfags.alt,582					clfags.alt,583				);584			}585		}586		ConvTypeV::Char => match value.clone() {587			Val::Num(n) => tmp_out588				.push(std::char::from_u32(n as u32).ok_or(InvalidUnicodeCodepointGot(n as u32))?),589			Val::Str(s) => {590				if s.chars().count() != 1 {591					throw!(RuntimeError(592						format!("%c expected 1 char string, got {}", s.chars().count()).into(),593					));594				}595				tmp_out.push_str(&s);596			}597			_ => {598				throw!(TypeMismatch(599					"%c requires number/string",600					vec![ValType::Num, ValType::Str],601					value.value_type(),602				));603			}604		},605		ConvTypeV::Percent => tmp_out.push('%'),606	};607608	let padding = width.saturating_sub(tmp_out.len());609610	if !clfags.left {611		for _ in 0..padding {612			out.push(' ');613		}614	}615	out.push_str(&tmp_out);616	if clfags.left {617		for _ in 0..padding {618			out.push(' ');619		}620	}621622	Ok(())623}624625pub fn format_arr(s: State, str: &str, mut values: &[Val]) -> Result<String> {626	let codes = parse_codes(str)?;627	let mut out = String::new();628629	for code in codes {630		match code {631			Element::String(s) => {632				out.push_str(s);633			}634			Element::Code(c) => {635				let width = match c.width {636					Width::Star => {637						if values.is_empty() {638							throw!(NotEnoughValues);639						}640						let value = &values[0];641						values = &values[1..];642						usize::from_untyped(value.clone(), s.clone())?643					}644					Width::Fixed(n) => n,645				};646				let precision = match c.precision {647					Some(Width::Star) => {648						if values.is_empty() {649							throw!(NotEnoughValues);650						}651						let value = &values[0];652						values = &values[1..];653						Some(usize::from_untyped(value.clone(), s.clone())?)654					}655					Some(Width::Fixed(n)) => Some(n),656					None => None,657				};658659				// %% should not consume a value660				let value = if c.convtype == ConvTypeV::Percent {661					&Val::Null662				} else {663					if values.is_empty() {664						throw!(NotEnoughValues);665					}666					let value = &values[0];667					values = &values[1..];668					value669				};670671				format_code(s.clone(), &mut out, value, &c, width, precision)?;672			}673		}674	}675676	Ok(out)677}678679pub fn format_obj(s: State, str: &str, values: &ObjValue) -> Result<String> {680	let codes = parse_codes(str)?;681	let mut out = String::new();682683	for code in codes {684		match code {685			Element::String(s) => {686				out.push_str(s);687			}688			Element::Code(c) => {689				// TODO: Operate on ref690				let f: IStr = c.mkey.into();691				let width = match c.width {692					Width::Star => {693						throw!(CannotUseStarWidthWithObject);694					}695					Width::Fixed(n) => n,696				};697				let precision = match c.precision {698					Some(Width::Star) => {699						throw!(CannotUseStarWidthWithObject);700					}701					Some(Width::Fixed(n)) => Some(n),702					None => None,703				};704705				let value = if c.convtype == ConvTypeV::Percent {706					Val::Null707				} else {708					if f.is_empty() {709						throw!(MappingKeysRequired);710					}711					if let Some(v) = values.get(s.clone(), f.clone())? {712						v713					} else {714						throw!(NoSuchFormatField(f));715					}716				};717718				format_code(s.clone(), &mut out, &value, &c, width, precision)?;719			}720		}721	}722723	Ok(out)724}725726#[cfg(test)]727pub mod test_format {728	use super::*;729730	#[test]731	fn parse() {732		assert_eq!(733			parse_codes(734				"How much error budget is left looking at our %.3f%% availability gurantees?"735			)736			.unwrap()737			.len(),738			4739		);740	}741742	#[test]743	fn octals() {744		assert_eq!(format_arr("%#o", &[Val::Num(8.0)]).unwrap(), "010");745		assert_eq!(format_arr("%#4o", &[Val::Num(8.0)]).unwrap(), " 010");746		assert_eq!(format_arr("%4o", &[Val::Num(8.0)]).unwrap(), "  10");747		assert_eq!(format_arr("%04o", &[Val::Num(8.0)]).unwrap(), "0010");748		assert_eq!(format_arr("%+4o", &[Val::Num(8.0)]).unwrap(), " +10");749		assert_eq!(format_arr("%+04o", &[Val::Num(8.0)]).unwrap(), "+010");750		assert_eq!(format_arr("%-4o", &[Val::Num(8.0)]).unwrap(), "10  ");751		assert_eq!(format_arr("%+-4o", &[Val::Num(8.0)]).unwrap(), "+10 ");752		assert_eq!(format_arr("%+-04o", &[Val::Num(8.0)]).unwrap(), "+10 ");753	}754755	#[test]756	fn percent_doesnt_consumes_values() {757		assert_eq!(758			format_arr(759				"How much error budget is left looking at our %.3f%% availability gurantees?",760				&[Val::Num(4.0)]761			)762			.unwrap(),763			"How much error budget is left looking at our 4.000% availability gurantees?"764		);765	}766}
modifiedcrates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/manifest.rs
@@ -158,7 +158,7 @@
 			'\r' => buf.push_str("\\r"),
 			'\t' => buf.push_str("\\t"),
 			c if c < 32 as char || (c >= 127 as char && c <= 159 as char) => {
-				write!(buf, "\\u{:04x}", c as u32).unwrap()
+				write!(buf, "\\u{:04x}", c as u32).unwrap();
 			}
 			c => buf.push(c),
 		}
@@ -194,7 +194,7 @@
 	pub preserve_order: bool,
 }
 
-/// From https://github.com/chyh1990/yaml-rust/blob/da52a68615f2ecdd6b7e4567019f280c433c1521/src/emitter.rs#L289
+/// From <https://github.com/chyh1990/yaml-rust/blob/da52a68615f2ecdd6b7e4567019f280c433c1521/src/emitter.rs#L289>
 /// With added date check
 fn yaml_needs_quotes(string: &str) -> bool {
 	fn need_quotes_spaces(string: &str) -> bool {
@@ -227,6 +227,8 @@
 	manifest_yaml_ex_buf(s, val, &mut out, &mut String::new(), options)?;
 	Ok(out)
 }
+
+#[allow(clippy::too_many_lines)]
 fn manifest_yaml_ex_buf(
 	s: State,
 	val: &Val,
@@ -238,9 +240,9 @@
 	match val {
 		Val::Bool(v) => {
 			if *v {
-				buf.push_str("true")
+				buf.push_str("true");
 			} else {
-				buf.push_str("false")
+				buf.push_str("false");
 			}
 		}
 		Val::Null => buf.push_str("null"),
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -1,3 +1,6 @@
+// All builtins should return results
+#![allow(clippy::unnecessary_wraps)]
+
 use std::collections::HashMap;
 
 use format::{format_arr, format_obj};
@@ -173,7 +176,7 @@
 fn builtin_make_array(s: State, sz: usize, func: FuncVal) -> Result<VecVal> {
 	let mut out = Vec::with_capacity(sz);
 	for i in 0..sz {
-		out.push(func.evaluate_simple(s.clone(), &[i as f64].as_slice())?)
+		out.push(func.evaluate_simple(s.clone(), &[i as f64].as_slice())?);
 	}
 	Ok(VecVal(Cc::new(out)))
 }
@@ -420,7 +423,7 @@
 				match func.evaluate_simple(s.clone(), &[Any(el)].as_slice())? {
 					Val::Arr(o) => {
 						for oe in o.iter(s.clone()) {
-							out.push(oe?)
+							out.push(oe?);
 						}
 					}
 					_ => throw!(RuntimeError(
@@ -707,7 +710,7 @@
 #[jrsonnet_macros::builtin]
 fn builtin_count(s: State, arr: Vec<Any>, v: Any) -> Result<usize> {
 	let mut count = 0;
-	for item in arr.iter() {
+	for item in &arr {
 		if equals(s.clone(), &item.0, &v.0)? {
 			count += 1;
 		}
modifiedcrates/jrsonnet-evaluator/src/builtin/sort.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/sort.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/sort.rs
@@ -53,10 +53,10 @@
 		match (i, sort_type) {
 			(Val::Str(_), SortKeyType::Unknown) => sort_type = SortKeyType::String,
 			(Val::Num(_), SortKeyType::Unknown) => sort_type = SortKeyType::Number,
-			(Val::Str(_), SortKeyType::String) => {}
-			(Val::Str(_), _) => throw!(SortError::SortElementsShouldHaveEqualType),
-			(Val::Num(_), SortKeyType::Number) => {}
-			(Val::Num(_), _) => throw!(SortError::SortElementsShouldHaveEqualType),
+			(Val::Str(_), SortKeyType::String) | (Val::Num(_), SortKeyType::Number) => {}
+			(Val::Str(_) | Val::Num(_), _) => {
+				throw!(SortError::SortElementsShouldHaveEqualType)
+			}
 			_ => throw!(SortError::SortKeyShouldBeStringOrNumber),
 		}
 	}
@@ -91,19 +91,19 @@
 		Ok(Cc::new(vk.into_iter().map(|v| v.0).collect()))
 	} else {
 		// Fast path, identity key getter
-		let mut mvalues = (*values).clone();
-		let sort_type = get_sort_type(&mut mvalues, |k| k)?;
+		let mut values = (*values).clone();
+		let sort_type = get_sort_type(&mut values, |k| k)?;
 		match sort_type {
-			SortKeyType::Number => mvalues.sort_unstable_by_key(|v| match v {
+			SortKeyType::Number => values.sort_unstable_by_key(|v| match v {
 				Val::Num(n) => NonNaNf64(*n),
 				_ => unreachable!(),
 			}),
-			SortKeyType::String => mvalues.sort_unstable_by_key(|v| match v {
+			SortKeyType::String => values.sort_unstable_by_key(|v| match v {
 				Val::Str(s) => s.clone(),
 				_ => unreachable!(),
 			}),
 			SortKeyType::Unknown => unreachable!(),
 		};
-		Ok(Cc::new(mvalues))
+		Ok(Cc::new(values))
 	}
 }
modifiedcrates/jrsonnet-evaluator/src/builtin/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/stdlib.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/stdlib.rs
@@ -24,5 +24,5 @@
 }
 
 pub fn get_parsed_stdlib() -> LocExpr {
-	PARSED_STDLIB.with(|t| t.clone())
+	PARSED_STDLIB.with(Clone::clone)
 }
modifiedcrates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -79,6 +79,7 @@
 	pub fn contains_binding(&self, name: IStr) -> bool {
 		self.0.bindings.contains_key(&name)
 	}
+	#[must_use]
 	pub fn into_future(self, ctx: FutureWrapper<Self>) -> Self {
 		{
 			ctx.0.borrow_mut().replace(self);
@@ -86,16 +87,19 @@
 		ctx.unwrap()
 	}
 
+	#[must_use]
 	pub fn with_var(self, name: IStr, value: Val) -> Self {
 		let mut new_bindings = GcHashMap::with_capacity(1);
 		new_bindings.insert(name, LazyVal::new_resolved(value));
 		self.extend(new_bindings, None, None, None)
 	}
 
+	#[must_use]
 	pub fn with_this_super(self, new_this: ObjValue, new_super_obj: Option<ObjValue>) -> Self {
 		self.extend(GcHashMap::new(), None, Some(new_this), new_super_obj)
 	}
 
+	#[must_use]
 	pub fn extend(
 		self,
 		new_bindings: GcHashMap<IStr, LazyVal>,
@@ -119,6 +123,7 @@
 			bindings,
 		}))
 	}
+	#[must_use]
 	pub fn extend_bound(self, new_bindings: GcHashMap<IStr, LazyVal>) -> Self {
 		let new_this = self.0.this.clone();
 		let new_super_obj = self.0.super_obj.clone();
@@ -135,7 +140,7 @@
 		let this = new_this.or_else(|| self.0.this.clone());
 		let super_obj = new_super_obj.or_else(|| self.0.super_obj.clone());
 		let mut new = GcHashMap::with_capacity(new_bindings.len());
-		for (k, v) in new_bindings.0.into_iter() {
+		for (k, v) in new_bindings.0 {
 			new.insert(k, v.evaluate(s.clone(), this.clone(), super_obj.clone())?);
 		}
 		Ok(self.extend(new, new_dollar, this, super_obj))
modifiedcrates/jrsonnet-evaluator/src/dynamic.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/dynamic.rs
+++ b/crates/jrsonnet-evaluator/src/dynamic.rs
@@ -8,12 +8,16 @@
 	pub fn new() -> Self {
 		Self(Cc::new(RefCell::new(None)))
 	}
+	/// # Panics
+	/// If wrapper is filled already
 	pub fn fill(self, value: T) {
 		assert!(self.0.borrow().is_none(), "wrapper is filled already");
 		self.0.borrow_mut().replace(value);
 	}
 }
 impl<T: Clone + Trace + 'static> FutureWrapper<T> {
+	/// # Panics
+	/// If wrapper is not yet filled
 	pub fn unwrap(&self) -> T {
 		self.0.borrow().as_ref().cloned().unwrap()
 	}
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -96,7 +96,8 @@
 	#[error(
 		"syntax error: expected {}, got {:?}",
 		.error.expected,
-		.source_code.chars().nth(error.location.offset).map(|c| c.to_string()).unwrap_or_else(|| "EOF".into())
+		.source_code.chars().nth(error.location.offset)
+		.map_or_else(|| "EOF".into(), |c| c.to_string())
 	)]
 	ImportSyntaxError {
 		#[skip_trace]
@@ -190,7 +191,7 @@
 impl Debug for LocError {
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		writeln!(f, "{}", self.0 .0)?;
-		for el in self.0 .1 .0.iter() {
+		for el in &self.0 .1 .0 {
 			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
@@ -23,8 +23,6 @@
 pub fn evaluate_binding_in_future(b: &BindSpec, fctx: FutureWrapper<Context>) -> LazyVal {
 	let b = b.clone();
 	if let Some(params) = &b.params {
-		let params = params.clone();
-
 		#[derive(Trace)]
 		struct LazyMethodBinding {
 			fctx: FutureWrapper<Context>,
@@ -43,6 +41,8 @@
 			}
 		}
 
+		let params = params.clone();
+
 		LazyVal::new(TraceBox(Box::new(LazyMethodBinding {
 			fctx,
 			name: b.name.clone(),
@@ -69,11 +69,10 @@
 	}
 }
 
+#[allow(clippy::too_many_lines)]
 pub fn evaluate_binding(b: &BindSpec, cctx: ContextCreator) -> (IStr, LazyBinding) {
 	let b = b.clone();
 	if let Some(params) = &b.params {
-		let params = params.clone();
-
 		#[derive(Trace)]
 		struct BindableMethodLazyVal {
 			this: Option<ObjValue>,
@@ -121,6 +120,8 @@
 			}
 		}
 
+		let params = params.clone();
+
 		(
 			b.name.clone(),
 			LazyBinding::Bindable(Cc::new(TraceBox(Box::new(BindableMethod {
@@ -227,7 +228,7 @@
 		None => callback(ctx)?,
 		Some(CompSpec::IfSpec(IfSpecData(cond))) => {
 			if bool::from_untyped(evaluate(s.clone(), ctx.clone(), cond)?, s.clone())? {
-				evaluate_comp(s, ctx, &specs[1..], callback)?
+				evaluate_comp(s, ctx, &specs[1..], callback)?;
 			}
 		}
 		Some(CompSpec::ForSpec(ForSpecData(var, expr))) => {
@@ -239,7 +240,7 @@
 							ctx.clone().with_var(var.clone(), item?.clone()),
 							&specs[1..],
 							callback,
-						)?
+						)?;
 					}
 				}
 				_ => throw!(InComprehensionCanOnlyIterateOverArray),
@@ -249,6 +250,7 @@
 	Ok(())
 }
 
+#[allow(clippy::too_many_lines)]
 pub fn evaluate_member_list_object(s: State, ctx: Context, members: &[Member]) -> Result<ObjValue> {
 	let new_bindings = FutureWrapper::new();
 	let future_this = FutureWrapper::new();
@@ -278,12 +280,6 @@
 				visibility,
 				value,
 			}) => {
-				let name = evaluate_field_name(s.clone(), ctx.clone(), name)?;
-				if name.is_none() {
-					continue;
-				}
-				let name = name.unwrap();
-
 				#[derive(Trace)]
 				struct ObjMemberBinding {
 					cctx: ContextCreator,
@@ -305,6 +301,14 @@
 						)?))
 					}
 				}
+
+				let name = evaluate_field_name(s.clone(), ctx.clone(), name)?;
+				let name = if let Some(name) = name {
+					name
+				} else {
+					continue;
+				};
+
 				builder
 					.member(name.clone())
 					.with_add(*plus)
@@ -325,11 +329,6 @@
 				value,
 				..
 			}) => {
-				let name = evaluate_field_name(s.clone(), ctx.clone(), name)?;
-				if name.is_none() {
-					continue;
-				}
-				let name = name.unwrap();
 				#[derive(Trace)]
 				struct ObjMemberBinding {
 					cctx: ContextCreator,
@@ -352,6 +351,13 @@
 						)))
 					}
 				}
+
+				let name = if let Some(name) = evaluate_field_name(s.clone(), ctx.clone(), name)? {
+					name
+				} else {
+					continue;
+				};
+
 				builder
 					.member(name.clone())
 					.hide()
@@ -505,24 +511,24 @@
 					throw!(AssertionFailed(
 						evaluate(s.clone(), ctx, msg)?.to_string(s.clone())?
 					));
-				} else {
-					throw!(AssertionFailed(Val::Null.to_string(s.clone())?));
 				}
+				throw!(AssertionFailed(Val::Null.to_string(s.clone())?));
 			},
-		)?
+		)?;
 	}
 	Ok(())
 }
 
-pub fn evaluate_named(s: State, ctx: Context, lexpr: &LocExpr, name: IStr) -> Result<Val> {
+pub fn evaluate_named(s: State, ctx: Context, expr: &LocExpr, name: IStr) -> Result<Val> {
 	use Expr::*;
-	let LocExpr(expr, _loc) = lexpr;
-	Ok(match &**expr {
+	let LocExpr(raw_expr, _loc) = expr;
+	Ok(match &**raw_expr {
 		Function(params, body) => evaluate_method(ctx, name, params.clone(), body.clone()),
-		_ => evaluate(s, ctx, lexpr)?,
+		_ => evaluate(s, ctx, expr)?,
 	})
 }
 
+#[allow(clippy::too_many_lines)]
 pub fn evaluate(s: State, ctx: Context, expr: &LocExpr) -> Result<Val> {
 	use Expr::*;
 	let LocExpr(expr, loc) = expr;
@@ -532,10 +538,11 @@
 			Val::Obj(ctx.this().clone().ok_or(CantUseSelfOutsideOfObject)?)
 		}
 		Literal(LiteralType::Super) => Val::Obj(
-			ctx.super_obj()
-				.clone()
-				.ok_or(NoSuperFound)?
-				.with_this(ctx.this().clone().unwrap()),
+			ctx.super_obj().clone().ok_or(NoSuperFound)?.with_this(
+				ctx.this()
+					.clone()
+					.expect("if super exists - then this should to"),
+			),
 		),
 		Literal(LiteralType::Dollar) => {
 			Val::Obj(ctx.dollar().clone().ok_or(NoTopLevelObjectFound)?)
@@ -699,9 +706,6 @@
 			}
 		}
 		Slice(value, desc) => {
-			let indexable = evaluate(s.clone(), ctx.clone(), value)?;
-			let loc = CallLocation::new(loc);
-
 			fn parse_idx<T: Typed>(
 				loc: CallLocation,
 				s: State,
@@ -720,6 +724,9 @@
 				}
 			}
 
+			let indexable = evaluate(s.clone(), ctx.clone(), value)?;
+			let loc = CallLocation::new(loc);
+
 			let start = parse_idx(loc, s.clone(), &ctx, &desc.start, "start")?;
 			let end = parse_idx(loc, s.clone(), &ctx, &desc.end, "end")?;
 			let step = parse_idx(loc, s, &ctx, &desc.step, "step")?;
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs
@@ -1,3 +1,5 @@
+use std::cmp::Ordering;
+
 use jrsonnet_parser::{BinaryOpType, LocExpr, UnaryOpType};
 
 use crate::{
@@ -11,7 +13,7 @@
 	Ok(match (op, b) {
 		(Not, Bool(v)) => Bool(!v),
 		(Minus, Num(n)) => Num(-*n),
-		(BitNot, Num(n)) => Num(!(*n as i32) as f64),
+		(BitNot, Num(n)) => Num(f64::from(!(*n as i32))),
 		(op, o) => throw!(UnaryOperatorDoesNotOperateOnType(op, o.value_type())),
 	})
 }
@@ -22,8 +24,8 @@
 		(Str(v1), Str(v2)) => Str(((**v1).to_owned() + v2).into()),
 
 		// Can't use generic json serialization way, because it depends on number to string concatenation (std.jsonnet:890)
-		(Num(n), Str(o)) => Str(format!("{}{}", n, o).into()),
-		(Str(o), Num(n)) => Str(format!("{}{}", o, n).into()),
+		(Num(a), Str(b)) => Str(format!("{a}{b}").into()),
+		(Str(a), Num(b)) => Str(format!("{a}{b}").into()),
 
 		(Str(a), o) => Str(format!("{}{}", a, o.clone().to_string(s)?).into()),
 		(o, Str(a)) => Str(format!("{}{}", o.clone().to_string(s)?, a).into()),
@@ -47,7 +49,12 @@
 pub fn evaluate_mod_op(s: State, a: &Val, b: &Val) -> Result<Val> {
 	use Val::*;
 	match (a, b) {
-		(Num(a), Num(b)) => Ok(Num(a % b)),
+		(Num(a), Num(b)) => {
+			if *b == 0.0 {
+				throw!(DivisionByZero)
+			}
+			Ok(Num(a % b))
+		}
 		(Str(str), vals) => {
 			String::into_untyped(std_format(s.clone(), str.clone(), vals.clone())?, s)
 		}
@@ -75,6 +82,32 @@
 	})
 }
 
+pub fn evaluate_compare_op(s: State, a: &Val, op: BinaryOpType, b: &Val) -> Result<Ordering> {
+	use Val::*;
+	Ok(match (a, b) {
+		(Str(a), Str(b)) => a.cmp(b),
+		(Num(a), Num(b)) => a.partial_cmp(b).expect("jsonnet numbers are non NaN"),
+		(Arr(a), Arr(b)) => {
+			let ai = a.iter(s.clone());
+			let bi = b.iter(s.clone());
+
+			for (a, b) in ai.zip(bi) {
+				let ord = evaluate_compare_op(s.clone(), &a?, op, &b?)?;
+				if !ord.is_eq() {
+					return Ok(ord);
+				}
+			}
+
+			a.len().cmp(&b.len())
+		}
+		(_, _) => throw!(BinaryOperatorDoesNotOperateOnValues(
+			op,
+			a.value_type(),
+			b.value_type()
+		)),
+	})
+}
+
 pub fn evaluate_binary_op_normal(s: State, a: &Val, op: BinaryOpType, b: &Val) -> Result<Val> {
 	use BinaryOpType::*;
 	use Val::*;
@@ -84,6 +117,11 @@
 		(a, Eq, b) => Bool(equals(s, a, b)?),
 		(a, Neq, b) => Bool(!equals(s, a, b)?),
 
+		(a, Lt, b) => Bool(evaluate_compare_op(s, a, Lt, b)?.is_lt()),
+		(a, Gt, b) => Bool(evaluate_compare_op(s, a, Gt, b)?.is_gt()),
+		(a, Lte, b) => Bool(evaluate_compare_op(s, a, Lte, b)?.is_le()),
+		(a, Gte, b) => Bool(evaluate_compare_op(s, a, Gte, b)?.is_ge()),
+
 		(Str(a), In, Obj(obj)) => Bool(obj.has_field_ex(a.clone(), true)),
 		(a, Mod, b) => evaluate_mod_op(s, a, b)?,
 
@@ -92,17 +130,11 @@
 		// Bool X Bool
 		(Bool(a), And, Bool(b)) => Bool(*a && *b),
 		(Bool(a), Or, Bool(b)) => Bool(*a || *b),
-
-		// Str X Str
-		(Str(v1), Lt, Str(v2)) => Bool(v1 < v2),
-		(Str(v1), Gt, Str(v2)) => Bool(v1 > v2),
-		(Str(v1), Lte, Str(v2)) => Bool(v1 <= v2),
-		(Str(v1), Gte, Str(v2)) => Bool(v1 >= v2),
 
 		// Num X Num
 		(Num(v1), Mul, Num(v2)) => Val::new_checked_num(v1 * v2)?,
 		(Num(v1), Div, Num(v2)) => {
-			if *v2 <= f64::EPSILON {
+			if *v2 == 0.0 {
 				throw!(DivisionByZero)
 			}
 			Val::new_checked_num(v1 / v2)?
@@ -110,25 +142,20 @@
 
 		(Num(v1), Sub, Num(v2)) => Val::new_checked_num(v1 - v2)?,
 
-		(Num(v1), Lt, Num(v2)) => Bool(v1 < v2),
-		(Num(v1), Gt, Num(v2)) => Bool(v1 > v2),
-		(Num(v1), Lte, Num(v2)) => Bool(v1 <= v2),
-		(Num(v1), Gte, Num(v2)) => Bool(v1 >= v2),
-
-		(Num(v1), BitAnd, Num(v2)) => Num(((*v1 as i32) & (*v2 as i32)) as f64),
-		(Num(v1), BitOr, Num(v2)) => Num(((*v1 as i32) | (*v2 as i32)) as f64),
-		(Num(v1), BitXor, Num(v2)) => Num(((*v1 as i32) ^ (*v2 as i32)) as f64),
+		(Num(v1), BitAnd, Num(v2)) => Num(f64::from((*v1 as i32) & (*v2 as i32))),
+		(Num(v1), BitOr, Num(v2)) => Num(f64::from((*v1 as i32) | (*v2 as i32))),
+		(Num(v1), BitXor, Num(v2)) => Num(f64::from((*v1 as i32) ^ (*v2 as i32))),
 		(Num(v1), Lhs, Num(v2)) => {
 			if *v2 < 0.0 {
 				throw!(RuntimeError("shift by negative exponent".into()))
 			}
-			Num(((*v1 as i32) << (*v2 as i32)) as f64)
+			Num(f64::from((*v1 as i32) << (*v2 as i32)))
 		}
 		(Num(v1), Rhs, Num(v2)) => {
 			if *v2 < 0.0 {
 				throw!(RuntimeError("shift by negative exponent".into()))
 			}
-			Num(((*v1 as i32) >> (*v2 as i32)) as f64)
+			Num(f64::from((*v1 as i32) >> (*v2 as i32)))
 		}
 
 		_ => throw!(BinaryOperatorDoesNotOperateOnValues(
modifiedcrates/jrsonnet-evaluator/src/function.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function.rs
+++ b/crates/jrsonnet-evaluator/src/function.rs
@@ -145,7 +145,7 @@
 		tailstrict: bool,
 		handler: &mut dyn FnMut(&IStr, LazyVal) -> Result<()>,
 	) -> Result<()> {
-		for (name, arg) in self.named.iter() {
+		for (name, arg) in &self.named {
 			handler(
 				name,
 				if tailstrict {
@@ -162,8 +162,8 @@
 	}
 
 	fn named_names(&self, handler: &mut dyn FnMut(&IStr)) {
-		for (name, _) in self.named.iter() {
-			handler(name)
+		for (name, _) in &self.named {
+			handler(name);
 		}
 	}
 }
@@ -231,7 +231,7 @@
 	}
 }
 
-impl<A: ArgLike> ArgsLike for HashMap<IStr, A> {
+impl<A: ArgLike, S> ArgsLike for HashMap<IStr, A, S> {
 	fn unnamed_len(&self) -> usize {
 		0
 	}
@@ -325,7 +325,7 @@
 	}
 
 	fn named_names(&self, handler: &mut dyn FnMut(&IStr)) {
-		(*self).named_names(handler)
+		(*self).named_names(handler);
 	}
 }
 
@@ -381,18 +381,13 @@
 			if passed_args.contains_key(&param.0.clone()) {
 				continue;
 			}
-			LazyVal::new(TraceBox(Box::new(EvaluateNamedLazyVal {
-				ctx: fctx.clone(),
-				name: param.0.clone(),
-				value: param.1.clone().unwrap(),
-			})));
 
 			defaults.insert(
 				param.0.clone(),
 				LazyVal::new(TraceBox(Box::new(EvaluateNamedLazyVal {
 					ctx: fctx.clone(),
 					name: param.0.clone(),
-					value: param.1.clone().unwrap(),
+					value: param.1.clone().expect("default exists"),
 				}))),
 			);
 			filled_args += 1;
@@ -447,7 +442,7 @@
 	// const INST: &'static Self;
 }
 
-/// You shouldn't probally use this function, use jrsonnet_macros::builtin instead
+/// You shouldn't probally use this function, use `jrsonnet_macros::builtin` instead
 ///
 /// ## Parameters
 /// * `ctx`: used for passed argument expressions' execution and for body execution (if `body_ctx` is not set)
@@ -518,10 +513,6 @@
 /// Creates Context, which has all argument default values applied
 /// and with unbound values causing error to be returned
 pub fn parse_default_function_call(body_ctx: Context, params: &ParamsDesc) -> Context {
-	let fctx = Context::new_future();
-
-	let mut bindings = GcHashMap::new();
-
 	#[derive(Trace)]
 	struct DependsOnUnbound(IStr);
 	impl LazyValValue for DependsOnUnbound {
@@ -530,6 +521,10 @@
 		}
 	}
 
+	let fctx = Context::new_future();
+
+	let mut bindings = GcHashMap::new();
+
 	for param in params.iter() {
 		if let Some(v) = &param.1 {
 			bindings.insert(
modifiedcrates/jrsonnet-evaluator/src/gc.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/gc.rs
+++ b/crates/jrsonnet-evaluator/src/gc.rs
@@ -1,6 +1,7 @@
 /// Macros to help deal with Gc
 use std::{
 	borrow::{Borrow, BorrowMut},
+	collections::{HashMap, HashSet},
 	hash::BuildHasherDefault,
 	ops::{Deref, DerefMut},
 };
@@ -14,7 +15,7 @@
 
 impl<T: ?Sized + Trace> Trace for TraceBox<T> {
 	fn trace(&self, tracer: &mut Tracer) {
-		self.0.trace(tracer)
+		self.0.trace(tracer);
 	}
 
 	fn is_type_tracked() -> bool {
@@ -70,7 +71,7 @@
 pub struct GcHashSet<V>(pub FxHashSet<V>);
 impl<V> GcHashSet<V> {
 	pub fn new() -> Self {
-		Self(Default::default())
+		Self(HashSet::default())
 	}
 	pub fn with_capacity(capacity: usize) -> Self {
 		Self(FxHashSet::with_capacity_and_hasher(
@@ -111,7 +112,7 @@
 pub struct GcHashMap<K, V>(pub FxHashMap<K, V>);
 impl<K, V> GcHashMap<K, V> {
 	pub fn new() -> Self {
-		Self(Default::default())
+		Self(HashMap::default())
 	}
 	pub fn with_capacity(capacity: usize) -> Self {
 		Self(FxHashMap::with_capacity_and_hasher(
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/import.rs
+++ b/crates/jrsonnet-evaluator/src/import.rs
@@ -79,7 +79,7 @@
 		if direct.exists() {
 			Ok(direct.into())
 		} else {
-			for library_path in self.library_paths.iter() {
+			for library_path in &self.library_paths {
 				let mut cloned = library_path.clone();
 				cloned.push(path);
 				if cloned.exists() {
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -1,7 +1,22 @@
-#![warn(clippy::all, clippy::nursery)]
+#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
 #![allow(
 	macro_expanded_macro_exports_accessed_by_absolute_paths,
-	clippy::ptr_arg
+	clippy::ptr_arg,
+	// Too verbose
+	clippy::must_use_candidate,
+	// A lot of functions pass around errors thrown by code
+	clippy::missing_errors_doc,
+	// A lot of pointers have interior Rc
+	clippy::needless_pass_by_value,
+	// Its fine
+	clippy::wildcard_imports,
+	clippy::enum_glob_use,
+	clippy::module_name_repetitions,
+	// TODO: fix individual issues, however this works as intended almost everywhere
+	clippy::cast_precision_loss,
+	clippy::cast_possible_wrap,
+	clippy::cast_possible_truncation,
+	clippy::cast_sign_loss,
 )]
 
 // For jrsonnet-macros
@@ -105,10 +120,10 @@
 		Self {
 			max_stack: 200,
 			max_trace: 20,
-			globals: Default::default(),
-			ext_vars: Default::default(),
-			ext_natives: Default::default(),
-			tla_vars: Default::default(),
+			globals: HashMap::default(),
+			ext_vars: HashMap::default(),
+			ext_natives: HashMap::default(),
+			tla_vars: HashMap::default(),
 			import_resolver: Box::new(DummyImportResolver),
 			manifest_format: ManifestFormat::Json {
 				padding: 4,
@@ -161,7 +176,7 @@
 		if self.0.is_empty() {
 			return result;
 		}
-		for item in self.0.iter() {
+		for item in &self.0 {
 			if item.loc.belongs_to(loc) {
 				let mut collected = item.collected.borrow_mut();
 				let (depth, vals) = collected.entry(stack_generation).or_default();
@@ -198,7 +213,7 @@
 		)
 		.map_err(|error| ImportSyntaxError {
 			error: Box::new(error),
-			path: path.to_owned(),
+			path: path.clone(),
 			source_code: source_code.clone(),
 		})?;
 		self.add_parsed_file(path, source_code, parsed.clone())?;
@@ -210,7 +225,7 @@
 		self.data_mut()
 			.files
 			.get_mut(name)
-			.unwrap()
+			.expect("file not found")
 			.evaluated
 			.take();
 	}
@@ -246,7 +261,11 @@
 		line: usize,
 		column: usize,
 	) -> Option<usize> {
-		location_to_offset(&self.get_source(file).unwrap(), line, column)
+		location_to_offset(
+			&self.get_source(file).expect("file not found"),
+			line,
+			column,
+		)
 	}
 	pub fn import_file(&self, from: &Path, path: &Path) -> Result<Val> {
 		let file_path = self.resolve_file(from, path)?;
@@ -312,8 +331,10 @@
 			STDLIB_STR.to_owned().into(),
 			builtin::get_parsed_stdlib(),
 		)
-		.unwrap();
-		let val = self.evaluate_loaded_file_raw(&std_path).unwrap();
+		.expect("stdlib is correct");
+		let val = self
+			.evaluate_loaded_file_raw(&std_path)
+			.expect("stdlib is correct");
 		self.settings_mut().globals.insert("std".into(), val);
 		self
 	}
@@ -342,9 +363,8 @@
 				// Error creation uses data, so i drop guard here
 				drop(data);
 				throw!(StackOverflow);
-			} else {
-				*stack_depth += 1;
 			}
+			*stack_depth += 1;
 		}
 		let result = f();
 		{
@@ -376,9 +396,8 @@
 				// Error creation uses data, so i drop guard here
 				drop(data);
 				throw!(StackOverflow);
-			} else {
-				*stack_depth += 1;
 			}
+			*stack_depth += 1;
 		}
 		let mut result = f();
 		{
@@ -411,9 +430,8 @@
 				// Error creation uses data, so i drop guard here
 				drop(data);
 				throw!(StackOverflow);
-			} else {
-				*stack_depth += 1;
 			}
+			*stack_depth += 1;
 		}
 		let result = f();
 		{
@@ -431,6 +449,8 @@
 		result
 	}
 
+	/// # Panics
+	/// In case of formatting failure
 	pub fn stringify_err(&self, e: &LocError) -> String {
 		let mut out = String::new();
 		self.settings()
@@ -1232,49 +1252,5 @@
 		assert_eval!(r#"std.assertEqual(std.count([], ""), 0)"#);
 		assert_eval!(r#"std.assertEqual(std.count(["a", "b", "a"], "d"), 0)"#);
 		assert_eval!(r#"std.assertEqual(std.count(["a", "b", "a"], "a"), 2)"#);
-	}
-
-	mod derive_typed {
-		use std::path::PathBuf;
-
-		use crate::{typed::Typed, State};
-
-		#[derive(PartialEq, Debug, Typed)]
-		struct MyTyped {
-			a: u32,
-			#[typed(rename = "b")]
-			c: String,
-		}
-
-		#[test]
-		fn test() {
-			let es = State::default();
-			let val = eval!("{a: 14, b: 'Hello, world!'}");
-			let typed = MyTyped::try_from(val).unwrap();
-
-			assert_eq!(
-				typed,
-				MyTyped {
-					a: 14,
-					c: "Hello, world!".to_string()
-				}
-			);
-			es.settings_mut()
-				.globals
-				.insert("mytyped".into(), typed.try_into().unwrap());
-
-			let v = es
-				.evaluate_snippet_raw(
-					PathBuf::from("raw.jsonnet").into(),
-					"
-				mytyped == {a: 14, b: 'Hello, world!'}
-			"
-					.into(),
-				)
-				.unwrap()
-				.as_bool()
-				.unwrap();
-			assert!(v)
-		}
 	}
 }
modifiedcrates/jrsonnet-evaluator/src/map.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/map.rs
+++ b/crates/jrsonnet-evaluator/src/map.rs
@@ -34,8 +34,7 @@
 				.0
 				.parent
 				.as_ref()
-				.map(|p| p.contains_key(key))
-				.unwrap_or(false)
+				.map_or(false, |p| p.contains_key(key))
 	}
 }
 
modifiedcrates/jrsonnet-evaluator/src/native.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/native.rs
+++ b/crates/jrsonnet-evaluator/src/native.rs
@@ -37,7 +37,7 @@
 	fn call(&self, s: State, ctx: Context, loc: CallLocation, args: &dyn ArgsLike) -> Result<Val> {
 		let args = parse_builtin_call(s.clone(), ctx, &self.params, args, true)?;
 		let mut out_args = Vec::with_capacity(self.params.len());
-		for p in self.params.iter() {
+		for p in &self.params {
 			out_args.push(args[&p.name].evaluate(s.clone())?);
 		}
 		self.handler.call(s, loc.0.map(|l| l.0.clone()), &out_args)
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -2,6 +2,7 @@
 	cell::RefCell,
 	fmt::Debug,
 	hash::{Hash, Hasher},
+	ptr::addr_of,
 };
 
 use gcmodule::{Cc, Trace, Weak};
@@ -20,6 +21,11 @@
 
 #[cfg(not(feature = "exp-preserve-order"))]
 mod ordering {
+	#![allow(
+		// This module works as stub for preserve-order feature
+		clippy::unused_self,
+	)]
+
 	use gcmodule::Trace;
 
 	#[derive(Clone, Copy, Default, Debug, Trace)]
@@ -89,6 +95,7 @@
 
 use ordering::*;
 
+#[allow(clippy::module_name_repetitions)]
 #[derive(Debug, Trace)]
 pub struct ObjMember {
 	pub add: bool,
@@ -113,6 +120,7 @@
 	Errored(LocError),
 }
 
+#[allow(clippy::module_name_repetitions)]
 #[derive(Trace)]
 #[force_tracking]
 pub struct ObjValueInternals {
@@ -136,10 +144,11 @@
 impl Eq for WeakObjValue {}
 impl Hash for WeakObjValue {
 	fn hash<H: Hasher>(&self, hasher: &mut H) {
-		hasher.write_usize(weak_raw(self.0.clone()) as usize)
+		hasher.write_usize(weak_raw(self.0.clone()) as usize);
 	}
 }
 
+#[allow(clippy::module_name_repetitions)]
 #[derive(Clone, Trace)]
 pub struct ObjValue(pub(crate) Cc<ObjValueInternals>);
 impl Debug for ObjValue {
@@ -178,6 +187,7 @@
 	pub fn new_empty() -> Self {
 		Self::new(None, Cc::new(GcHashMap::new()), Cc::new(Vec::new()))
 	}
+	#[must_use]
 	pub fn extend_from(&self, super_obj: Self) -> Self {
 		match &self.0.super_obj {
 			None => Self::new(
@@ -200,6 +210,8 @@
 	pub fn extend_field(&mut self, name: IStr) -> ObjMemberBuilder<ExtendBuilder> {
 		ObjMemberBuilder::new(ExtendBuilder(self), name, FieldIndex::default())
 	}
+
+	#[must_use]
 	pub fn with_this(&self, this_obj: Self) -> Self {
 		Self(Cc::new(ObjValueInternals {
 			super_obj: self.0.super_obj.clone(),
@@ -222,11 +234,7 @@
 		if !self.0.this_entries.is_empty() {
 			return false;
 		}
-		self.0
-			.super_obj
-			.as_ref()
-			.map(|s| s.is_empty())
-			.unwrap_or(true)
+		self.0.super_obj.as_ref().map_or(true, Self::is_empty)
 	}
 
 	/// Run callback for every field found in object
@@ -254,15 +262,15 @@
 			let new_sort_key = FieldSortKey::new(depth, member.original_index);
 			match member.visibility {
 				Visibility::Normal => {
-					let entry = out.entry(name.to_owned());
+					let entry = out.entry(name.clone());
 					let v = entry.or_insert((true, new_sort_key));
 					v.1 = new_sort_key;
 				}
 				Visibility::Hidden => {
-					out.insert(name.to_owned(), (false, new_sort_key));
+					out.insert(name.clone(), (false, new_sort_key));
 				}
 				Visibility::Unhide => {
-					out.insert(name.to_owned(), (true, new_sort_key));
+					out.insert(name.clone(), (true, new_sort_key));
 				}
 			};
 			false
@@ -356,8 +364,7 @@
 	}
 	pub fn has_field(&self, name: IStr) -> bool {
 		self.field_visibility(name)
-			.map(|v| v.is_visible())
-			.unwrap_or(false)
+			.map_or(false, |v| v.is_visible())
 	}
 
 	pub fn get(&self, s: State, key: IStr) -> Result<Option<Val>> {
@@ -459,10 +466,11 @@
 impl Eq for ObjValue {}
 impl Hash for ObjValue {
 	fn hash<H: Hasher>(&self, hasher: &mut H) {
-		hasher.write_usize(&*self.0 as *const _ as usize)
+		hasher.write_usize(addr_of!(*self.0) as usize);
 	}
 }
 
+#[allow(clippy::module_name_repetitions)]
 pub struct ObjValueBuilder {
 	super_obj: Option<ObjValue>,
 	map: GcHashMap<IStr, ObjMember>,
@@ -510,6 +518,7 @@
 	}
 }
 
+#[allow(clippy::module_name_repetitions)]
 #[must_use = "value not added unless binding() was called"]
 pub struct ObjMemberBuilder<Kind> {
 	kind: Kind,
@@ -583,7 +592,7 @@
 				CallLocation(location.as_ref()),
 				|| format!("field <{}> initializtion", name.clone()),
 				|| throw!(DuplicateFieldName(name.clone())),
-			)?
+			)?;
 		}
 		Ok(())
 	}
@@ -592,14 +601,14 @@
 pub struct ExtendBuilder<'v>(&'v mut ObjValue);
 impl<'v> ObjMemberBuilder<ExtendBuilder<'v>> {
 	pub fn value(self, value: Val) {
-		self.binding(LazyBinding::Bound(LazyVal::new_resolved(value)))
+		self.binding(LazyBinding::Bound(LazyVal::new_resolved(value)));
 	}
 	pub fn bindable(self, bindable: TraceBox<dyn Bindable>) {
-		self.binding(LazyBinding::Bindable(Cc::new(bindable)))
+		self.binding(LazyBinding::Bindable(Cc::new(bindable)));
 	}
 	pub fn binding(self, binding: LazyBinding) {
 		let (receiver, name, member) = self.build_member(binding);
 		let new = receiver.0.clone();
-		*receiver.0 = new.extend_with_raw_member(name, member)
+		*receiver.0 = new.extend_with_raw_member(name, member);
 	}
 }
modifiedcrates/jrsonnet-evaluator/src/trace/location.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/trace/location.rs
+++ b/crates/jrsonnet-evaluator/src/trace/location.rs
@@ -1,3 +1,4 @@
+#[allow(clippy::module_name_repetitions)]
 #[derive(Clone, PartialEq, Debug)]
 pub struct CodeLocation {
 	pub offset: usize,
@@ -9,6 +10,7 @@
 	pub line_end_offset: usize,
 }
 
+#[allow(clippy::module_name_repetitions)]
 pub fn location_to_offset(mut file: &str, mut line: usize, column: usize) -> Option<usize> {
 	let mut offset = 0;
 	while line > 1 {
@@ -21,13 +23,14 @@
 	Some(offset)
 }
 
+#[allow(clippy::module_name_repetitions)]
 pub fn offset_to_location(file: &str, offsets: &[usize]) -> Vec<CodeLocation> {
 	if offsets.is_empty() {
 		return vec![];
 	}
 	let mut line = 1;
 	let mut column = 1;
-	let max_offset = *offsets.iter().max().unwrap();
+	let max_offset = *offsets.iter().max().expect("offsets is not empty");
 
 	let mut offset_map = offsets
 		.iter()
modifiedcrates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/trace/mod.rs
+++ b/crates/jrsonnet-evaluator/src/trace/mod.rs
@@ -19,14 +19,18 @@
 impl PathResolver {
 	pub fn resolve(&self, from: &Path) -> String {
 		match self {
-			Self::FileName => from.file_name().unwrap().to_string_lossy().into_owned(),
+			Self::FileName => from
+				.file_name()
+				.expect("file name exists")
+				.to_string_lossy()
+				.into_owned(),
 			Self::Absolute => from.to_string_lossy().into_owned(),
 			Self::Relative(base) => {
 				if from.is_relative() {
 					return from.to_string_lossy().into_owned();
 				}
 				pathdiff::diff_paths(from, base)
-					.unwrap()
+					.expect("base is absolute")
 					.to_string_lossy()
 					.into_owned()
 			}
@@ -35,6 +39,7 @@
 }
 
 /// Implements pretty-printing of traces
+#[allow(clippy::module_name_repetitions)]
 pub trait TraceFormat {
 	fn write_trace(
 		&self,
@@ -88,8 +93,9 @@
 			error,
 		} = error.error()
 		{
+			use std::fmt::Write;
+
 			writeln!(out)?;
-			use std::fmt::Write;
 			let mut n = self.resolver.resolve(path);
 			let mut offset = error.location.offset;
 			let is_eof = if offset >= source_code.len() {
@@ -134,7 +140,7 @@
 		let align = file_names
 			.iter()
 			.flatten()
-			.map(|e| e.len())
+			.map(String::len)
 			.max()
 			.unwrap_or(0);
 		for (el, file) in error.trace().0.iter().zip(file_names) {
@@ -166,7 +172,7 @@
 		error: &LocError,
 	) -> Result<(), std::fmt::Error> {
 		write!(out, "{}", error.error())?;
-		for item in error.trace().0.iter() {
+		for item in &error.trace().0 {
 			writeln!(out)?;
 			let desc = &item.desc;
 			if let Some(source) = &item.location {
@@ -227,7 +233,7 @@
 			)?;
 		}
 		let trace = &error.trace();
-		for item in trace.0.iter() {
+		for item in &trace.0 {
 			writeln!(out)?;
 			let desc = &item.desc;
 			if let Some(source) = &item.location {
@@ -273,7 +279,7 @@
 		let snippet = Snippet {
 			opt: FormatOptions {
 				color: true,
-				..Default::default()
+				..FormatOptions::default()
 			},
 			title: None,
 			footer: vec![],
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/conversions.rs
+++ b/crates/jrsonnet-evaluator/src/typed/conversions.rs
@@ -38,6 +38,7 @@
 				<Self as Typed>::TYPE.check(s, &value)?;
 				match value {
 					Val::Num(n) => {
+						#[allow(clippy::float_cmp)]
 						if n.trunc() != n {
 							throw!(RuntimeError(
 								format!(
@@ -95,6 +96,7 @@
 				<Self as Typed>::TYPE.check(s, &value)?;
 				match value {
 					Val::Num(n) => {
+						#[allow(clippy::float_cmp)]
 						if n.trunc() != n {
 							throw!(RuntimeError(
 								format!(
@@ -160,7 +162,7 @@
 impl Typed for usize {
 	// It is possible to store 54 bits of precision in f64, but leaving u32::MAX here for compatibility
 	const TYPE: &'static ComplexValType =
-		&ComplexValType::BoundedNumber(Some(0.0), Some(4294967295.0));
+		&ComplexValType::BoundedNumber(Some(0.0), Some(u32::MAX as f64));
 
 	fn into_untyped(value: Self, _: State) -> Result<Val> {
 		if value > u32::MAX as Self {
@@ -173,6 +175,7 @@
 		<Self as Typed>::TYPE.check(s, &value)?;
 		match value {
 			Val::Num(n) => {
+				#[allow(clippy::float_cmp)]
 				if n.trunc() != n {
 					throw!(RuntimeError(
 						"cannot convert number with fractional part to usize".into()
@@ -263,7 +266,7 @@
 }
 
 /// To be used in Vec<Any>
-/// Regular Val can't be used here, because it has wrong TryFrom::Error type
+/// Regular Val can't be used here, because it has wrong `TryFrom::Error` type
 #[derive(Clone)]
 pub struct Any(pub Val);
 
@@ -279,7 +282,7 @@
 	}
 }
 
-/// Specialization, provides faster TryFrom<VecVal> for Val
+/// Specialization, provides faster `TryFrom<VecVal>` for Val
 pub struct VecVal(pub Cc<Vec<Val>>);
 
 impl Typed for VecVal {
@@ -310,22 +313,20 @@
 	}
 
 	fn from_untyped(value: Val, s: State) -> Result<Self> {
+		if let Val::Arr(ArrValue::Bytes(bytes)) = value {
+			return Ok(Self(bytes));
+		}
+		<Self as Typed>::TYPE.check(s.clone(), &value)?;
 		match value {
-			Val::Arr(ArrValue::Bytes(bytes)) => Ok(Self(bytes)),
-			_ => {
-				<Self as Typed>::TYPE.check(s.clone(), &value)?;
-				match value {
-					Val::Arr(a) => {
-						let mut out = Vec::with_capacity(a.len());
-						for e in a.iter(s.clone()) {
-							let r = e?;
-							out.push(u8::from_untyped(r, s.clone())?);
-						}
-						Ok(Self(out.into()))
-					}
-					_ => unreachable!(),
+			Val::Arr(a) => {
+				let mut out = Vec::with_capacity(a.len());
+				for e in a.iter(s.clone()) {
+					let r = e?;
+					out.push(u8::from_untyped(r, s.clone())?);
 				}
+				Ok(Self(out.into()))
 			}
+			_ => unreachable!(),
 		}
 	}
 }
modifiedcrates/jrsonnet-evaluator/src/typed/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/mod.rs
+++ b/crates/jrsonnet-evaluator/src/typed/mod.rs
@@ -71,11 +71,11 @@
 				if line.trim().is_empty() {
 					continue;
 				}
-				if i != 0 {
+				if i == 0 {
+					write!(f, "  - ")?;
+				} else {
 					writeln!(f)?;
 					write!(f, "    ")?;
-				} else {
-					write!(f, "  - ")?;
 				}
 				write!(f, "{}", line)?;
 			}
@@ -94,7 +94,7 @@
 		Ok(_) => Ok(()),
 		Err(mut e) => {
 			if let Error::TypeError(e) = &mut e.error_mut() {
-				(e.1).0.push(path())
+				(e.1).0.push(path());
 			}
 			Err(e)
 		}
@@ -145,6 +145,7 @@
 }
 
 impl CheckType for ComplexValType {
+	#[allow(clippy::too_many_lines)]
 	fn check(&self, s: State, value: &Val) -> Result<()> {
 		match self {
 			Self::Any => Ok(()),
@@ -202,7 +203,7 @@
 								|| format!("property {}", k),
 								|| ValuePathItem::Field((*k).into()),
 								|| v.check(s.clone(), &got_v),
-							)?
+							)?;
 						} else {
 							return Err(
 								TypeError::MissingProperty((*k).into(), self.clone()).into()
@@ -245,13 +246,13 @@
 			}
 			Self::Sum(types) => {
 				for ty in types.iter() {
-					ty.check(s.clone(), value)?
+					ty.check(s.clone(), value)?;
 				}
 				Ok(())
 			}
 			Self::SumRef(types) => {
 				for ty in types.iter() {
-					ty.check(s.clone(), value)?
+					ty.check(s.clone(), value)?;
 				}
 				Ok(())
 			}
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -32,6 +32,7 @@
 	Pending,
 }
 
+#[allow(clippy::module_name_repetitions)]
 #[derive(Clone, Trace)]
 pub struct LazyVal(Cc<RefCell<LazyValInternals>>);
 impl LazyVal {
@@ -50,7 +51,7 @@
 			LazyValInternals::Computed(v) => return Ok(v.clone()),
 			LazyValInternals::Errored(e) => return Err(e.clone()),
 			LazyValInternals::Pending => return Err(InfiniteRecursionDetected.into()),
-			_ => (),
+			LazyValInternals::Waiting(..) => (),
 		};
 		let value = if let LazyValInternals::Waiting(value) =
 			std::mem::replace(&mut *self.0.borrow_mut(), LazyValInternals::Pending)
@@ -114,6 +115,7 @@
 	}
 }
 
+#[allow(clippy::module_name_repetitions)]
 #[derive(Trace, Clone)]
 pub enum FuncVal {
 	/// Plain function implemented in jsonnet
@@ -225,10 +227,10 @@
 		let rem = diff % self.step();
 		let div = diff / self.step();
 
-		if rem != 0 {
+		if rem == 0 {
+			div
+		} else {
 			div + 1
-		} else {
-			div
 		}
 	}
 }
@@ -248,11 +250,17 @@
 	pub fn new_eager() -> Self {
 		Self::Eager(Cc::new(Vec::new()))
 	}
+
+	/// # Panics
+	/// If a > b
 	pub fn new_range(a: i32, b: i32) -> Self {
 		assert!(a <= b);
 		Self::Range(a, b)
 	}
 
+	/// # Panics
+	/// If passed numbers are incorrect
+	#[must_use]
 	pub fn slice(self, from: Option<usize>, to: Option<usize>, step: Option<usize>) -> Self {
 		let len = self.len();
 		let from = from.unwrap_or(0);
@@ -289,7 +297,7 @@
 		match self {
 			Self::Bytes(i) => i
 				.get(index)
-				.map_or(Ok(None), |v| Ok(Some(Val::Num(*v as f64)))),
+				.map_or(Ok(None), |v| Ok(Some(Val::Num(f64::from(*v))))),
 			Self::Lazy(vec) => {
 				if let Some(v) = vec.get(index) {
 					Ok(Some(v.evaluate(s)?))
@@ -333,7 +341,7 @@
 		match self {
 			Self::Bytes(i) => i
 				.get(index)
-				.map(|b| LazyVal::new_resolved(Val::Num(*b as f64))),
+				.map(|b| LazyVal::new_resolved(Val::Num(f64::from(*b)))),
 			Self::Lazy(vec) => vec.get(index).cloned(),
 			Self::Eager(vec) => vec.get(index).cloned().map(LazyVal::new_resolved),
 			Self::Extended(v) => {
@@ -374,7 +382,7 @@
 			Self::Bytes(i) => {
 				let mut out = Vec::with_capacity(i.len());
 				for v in i.iter() {
-					out.push(Val::Num(*v as f64));
+					out.push(Val::Num(f64::from(*v)));
 				}
 				Cc::new(out)
 			}
@@ -396,7 +404,7 @@
 			Self::Range(a, b) => {
 				let mut out = Vec::with_capacity(self.len());
 				for i in *a..*b {
-					out.push(Val::Num(i as f64));
+					out.push(Val::Num(f64::from(i)));
 				}
 				Cc::new(out)
 			}
@@ -414,7 +422,7 @@
 					.take(v.to() - v.from())
 					.step_by(v.step())
 				{
-					out.push(v.evaluate(s.clone())?)
+					out.push(v.evaluate(s.clone())?);
 				}
 				Cc::new(out)
 			}
@@ -423,28 +431,27 @@
 
 	pub fn iter(&self, s: State) -> impl DoubleEndedIterator<Item = Result<Val>> + '_ {
 		(0..self.len()).map(move |idx| match self {
-			Self::Bytes(b) => Ok(Val::Num(b[idx] as f64)),
+			Self::Bytes(b) => Ok(Val::Num(f64::from(b[idx]))),
 			Self::Lazy(l) => l[idx].evaluate(s.clone()),
 			Self::Eager(e) => Ok(e[idx].clone()),
-			Self::Extended(_) => self.get(s.clone(), idx).map(|e| e.unwrap()),
-			Self::Range(..) => self.get(s.clone(), idx).map(|e| e.unwrap()),
-			Self::Reversed(..) => self.get(s.clone(), idx).map(|e| e.unwrap()),
-			Self::Slice(..) => self.get(s.clone(), idx).map(|e| e.unwrap()),
+			Self::Extended(..) | Self::Range(..) | Self::Reversed(..) | Self::Slice(..) => {
+				self.get(s.clone(), idx).map(|e| e.expect("idx < len"))
+			}
 		})
 	}
 
 	pub fn iter_lazy(&self) -> impl DoubleEndedIterator<Item = LazyVal> + '_ {
 		(0..self.len()).map(move |idx| match self {
-			Self::Bytes(b) => LazyVal::new_resolved(Val::Num(b[idx] as f64)),
+			Self::Bytes(b) => LazyVal::new_resolved(Val::Num(f64::from(b[idx]))),
 			Self::Lazy(l) => l[idx].clone(),
 			Self::Eager(e) => LazyVal::new_resolved(e[idx].clone()),
-			Self::Extended(_) => self.get_lazy(idx).unwrap(),
-			Self::Range(..) => self.get_lazy(idx).unwrap(),
-			Self::Reversed(..) => self.get_lazy(idx).unwrap(),
-			Self::Slice(..) => self.get_lazy(idx).unwrap(),
+			Self::Slice(..) | Self::Extended(..) | Self::Range(..) | Self::Reversed(..) => {
+				self.get_lazy(idx).expect("idx < len")
+			}
 		})
 	}
 
+	#[must_use]
 	pub fn reversed(self) -> Self {
 		Self::Reversed(Box::new(self))
 	}
@@ -493,6 +500,7 @@
 	}
 }
 
+#[allow(clippy::module_name_repetitions)]
 pub enum IndexableVal {
 	Str(IStr),
 	Arr(ArrValue),
@@ -708,7 +716,7 @@
 				preserve_order,
 			},
 		)
-		.map(|s| s.into())
+		.map(Into::into)
 	}
 
 	/// Calls `std.manifestJson`
@@ -730,7 +738,7 @@
 				preserve_order,
 			},
 		)
-		.map(|s| s.into())
+		.map(Into::into)
 	}
 
 	pub fn to_yaml(
@@ -751,7 +759,7 @@
 				preserve_order,
 			},
 		)
-		.map(|s| s.into())
+		.map(Into::into)
 	}
 	pub fn into_indexable(self) -> Result<IndexableVal> {
 		Ok(match self {
@@ -824,8 +832,8 @@
 			for field in fields {
 				if !equals(
 					s.clone(),
-					&a.get(s.clone(), field.clone())?.unwrap(),
-					&b.get(s.clone(), field)?.unwrap(),
+					&a.get(s.clone(), field.clone())?.expect("field exists"),
+					&b.get(s.clone(), field)?.expect("field exists"),
 				)? {
 					return Ok(false);
 				}
modifiedcrates/jrsonnet-evaluator/tests/common.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/tests/common.rs
+++ b/crates/jrsonnet-evaluator/tests/common.rs
@@ -12,6 +12,15 @@
 }
 
 #[macro_export]
+macro_rules! ensure {
+	($v:expr $(,)?) => {
+		if !$v {
+			::jrsonnet_evaluator::throw_runtime!("assertion failed: {}", stringify!($v))
+		}
+	};
+}
+
+#[macro_export]
 macro_rules! ensure_val_eq {
 	($s:expr, $a:expr, $b:expr) => {{
 		if !::jrsonnet_evaluator::val::equals($s.clone(), &$a.clone(), &$b.clone())? {
addedcrates/jrsonnet-evaluator/tests/sanity.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/jrsonnet-evaluator/tests/sanity.rs
@@ -0,0 +1,46 @@
+use std::path::PathBuf;
+
+use jrsonnet_evaluator::{error::Result, throw_runtime, State, Val};
+
+mod common;
+
+#[test]
+fn assert_positive() -> Result<()> {
+	let s = State::default();
+	s.with_stdlib();
+
+	let v = s.evaluate_snippet_raw(PathBuf::new().into(), "assert 1 == 1: 'fail'; null".into())?;
+	ensure_val_eq!(s.clone(), v, Val::Null);
+	let v = s.evaluate_snippet_raw(PathBuf::new().into(), "std.assertEqual(1, 1)".into())?;
+	ensure_val_eq!(s.clone(), v, Val::Bool(true));
+
+	Ok(())
+}
+
+#[test]
+fn assert_negative() -> Result<()> {
+	let s = State::default();
+	s.with_stdlib();
+
+	{
+		let e = match s
+			.evaluate_snippet_raw(PathBuf::new().into(), "assert 1 == 2: 'fail'; null".into())
+		{
+			Ok(_) => throw_runtime!("assertion should fail"),
+			Err(e) => e,
+		};
+		let e = s.stringify_err(&e);
+		ensure!(e.starts_with("assert failed: fail\n"));
+	}
+	{
+		let e = match s.evaluate_snippet_raw(PathBuf::new().into(), "std.assertEqual(1, 2)".into())
+		{
+			Ok(_) => throw_runtime!("assertion should fail"),
+			Err(e) => e,
+		};
+		let e = s.stringify_err(&e);
+		ensure!(e.starts_with("runtime error: Assertion failed. 1 != 2"))
+	}
+
+	Ok(())
+}
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-macros/src/lib.rs
+++ b/crates/jrsonnet-macros/src/lib.rs
@@ -157,8 +157,8 @@
 			});
 		}
 
-		match &ty as &Type {
-			Type::Reference(r) if type_is_path(&r.elem, &name).is_some() => return Ok(Self::This),
+		match ty as &Type {
+			Type::Reference(r) if type_is_path(&r.elem, name).is_some() => return Ok(Self::This),
 			_ => {}
 		}
 
@@ -465,14 +465,13 @@
 					"strategy should be set when flattening Option",
 				));
 			}
-		} else {
-			if attr.flatten_ok {
-				return Err(Error::new(
-					field.span(),
-					"flatten(ok) is only useable on optional fields",
-				));
-			}
+		} else if attr.flatten_ok {
+			return Err(Error::new(
+				field.span(),
+				"flatten(ok) is only useable on optional fields",
+			));
 		}
+
 		Ok(Self {
 			attr,
 			ident,