git.delta.rocks / jrsonnet / refs/commits / 3f8fb69418f4

difftreelog

style increase clippy linting level

Lach2020-08-25parent: #d13245a.patch.diff
in: master

15 files changed

modifiedcrates/jrsonnet-evaluator/src/builtin/format.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/builtin/format.rs
1//! faster std.format impl2#![allow(clippy::too_many_arguments)]34use crate::{error::Error::*, throw, LocError, ObjValue, Result, Val, ValType};56#[derive(Debug, Clone)]7pub enum FormatError {8	TruncatedFormatCode,9	UnrecognizedConversionType(char),1011	NotEnoughValues,1213	CannotUseStarWidthWithObject,14	MappingKeysRequired,15	NoSuchFormatField(Rc<str>),16}1718impl From<FormatError> for LocError {19	fn from(e: FormatError) -> Self {20		Self::new(Format(e))21	}22}2324use std::rc::Rc;25use FormatError::*;2627type ParseResult<'t, T> = std::result::Result<(T, &'t str), FormatError>;2829pub fn try_parse_mapping_key(str: &str) -> ParseResult<&str> {30	if str.is_empty() {31		return Err(TruncatedFormatCode);32	}33	let bytes = str.as_bytes();34	if bytes[0] == b'(' {35		let mut i = 1;36		while i < bytes.len() {37			if bytes[i] == b')' {38				return Ok((&str[1..i as usize], &str[i as usize + 1..]));39			}40			i += 1;41		}42		Err(TruncatedFormatCode)43	} else {44		Ok(("", str))45	}46}4748#[cfg(test)]49pub mod tests_key {50	use super::*;5152	#[test]53	fn parse_key() {54		assert_eq!(55			try_parse_mapping_key("(hello ) world").unwrap(),56			("hello ", " world")57		);58		assert_eq!(try_parse_mapping_key("() world").unwrap(), ("", " world"));59		assert_eq!(try_parse_mapping_key(" world").unwrap(), ("", " world"));60		assert_eq!(61			try_parse_mapping_key(" () world").unwrap(),62			("", " () world")63		);64	}6566	#[test]67	#[should_panic]68	fn parse_key_missing_start() {69		try_parse_mapping_key("").unwrap();70	}7172	#[test]73	#[should_panic]74	fn parse_key_missing_end() {75		try_parse_mapping_key("(   ").unwrap();76	}77}7879#[derive(Default, Debug)]80pub struct CFlags {81	pub alt: bool,82	pub zero: bool,83	pub left: bool,84	pub blank: bool,85	pub sign: bool,86}8788pub fn try_parse_cflags(str: &str) -> ParseResult<CFlags> {89	if str.is_empty() {90		return Err(TruncatedFormatCode);91	}92	let bytes = str.as_bytes();93	let mut i = 0;94	let mut out = CFlags::default();95	loop {96		if bytes.len() == i {97			return Err(TruncatedFormatCode);98		}99		match bytes[i] {100			b'#' => out.alt = true,101			b'0' => out.zero = true,102			b'-' => out.left = true,103			b' ' => out.blank = true,104			b'+' => out.sign = true,105			_ => break,106		}107		i += 1;108	}109	Ok((out, &str[i..]))110}111112#[derive(Debug, PartialEq)]113pub enum Width {114	Star,115	Fixed(usize),116}117pub fn try_parse_field_width(str: &str) -> ParseResult<Width> {118	if str.is_empty() {119		return Err(TruncatedFormatCode);120	}121	let bytes = str.as_bytes();122	if bytes[0] == b'*' {123		return Ok((Width::Star, &str[1..]));124	}125	let mut out: usize = 0;126	let mut digits = 0;127	while let Some(digit) = (bytes[digits] as char).to_digit(10) {128		out *= 10;129		out += digit as usize;130		digits += 1;131		if digits == bytes.len() {132			return Err(TruncatedFormatCode);133		}134	}135	Ok((Width::Fixed(out), &str[digits..]))136}137138pub fn try_parse_precision(str: &str) -> ParseResult<Option<Width>> {139	if str.is_empty() {140		return Err(TruncatedFormatCode);141	}142	let bytes = str.as_bytes();143	if bytes[0] == b'.' {144		try_parse_field_width(&str[1..]).map(|(r, s)| (Some(r), s))145	} else {146		Ok((None, str))147	}148}149150// Only skips151pub fn try_parse_length_modifier(str: &str) -> ParseResult<()> {152	if str.is_empty() {153		return Err(TruncatedFormatCode);154	}155	let bytes = str.as_bytes();156	let mut idx = 0;157	while bytes[idx] == b'h' || bytes[idx] == b'l' || bytes[idx] == b'L' {158		idx += 1;159		if bytes.len() == idx {160			return Err(TruncatedFormatCode);161		}162	}163	Ok(((), &str[idx..]))164}165166#[derive(Debug, PartialEq)]167pub enum ConvTypeV {168	Decimal,169	Octal,170	Hexadecimal,171	Scientific,172	Float,173	Shorter,174	Char,175	String,176	Percent,177}178pub struct ConvType {179	v: ConvTypeV,180	caps: bool,181}182183pub fn parse_conversion_type(str: &str) -> ParseResult<ConvType> {184	if str.is_empty() {185		return Err(TruncatedFormatCode);186	}187188	let code = str.as_bytes()[0];189	let v: (ConvTypeV, bool) = match code {190		b'd' | b'i' | b'u' => (ConvTypeV::Decimal, false),191		b'o' => (ConvTypeV::Octal, false),192		b'x' => (ConvTypeV::Hexadecimal, false),193		b'X' => (ConvTypeV::Hexadecimal, true),194		b'e' => (ConvTypeV::Scientific, false),195		b'E' => (ConvTypeV::Scientific, true),196		b'f' => (ConvTypeV::Float, false),197		b'F' => (ConvTypeV::Float, true),198		b'g' => (ConvTypeV::Shorter, false),199		b'G' => (ConvTypeV::Shorter, true),200		b'c' => (ConvTypeV::Char, false),201		b's' => (ConvTypeV::String, false),202		b'%' => (ConvTypeV::Percent, false),203		c => return Err(UnrecognizedConversionType(c as char)),204	};205206	Ok((ConvType { v: v.0, caps: v.1 }, &str[1..]))207}208209#[derive(Debug)]210pub struct Code<'s> {211	mkey: &'s str,212	cflags: CFlags,213	width: Width,214	precision: Option<Width>,215	convtype: ConvTypeV,216	caps: bool,217}218pub fn parse_code(str: &str) -> ParseResult<Code> {219	if str.is_empty() {220		return Err(TruncatedFormatCode);221	}222	let (mkey, str) = try_parse_mapping_key(str)?;223	let (cflags, str) = try_parse_cflags(str)?;224	let (width, str) = try_parse_field_width(str)?;225	let (precision, str) = try_parse_precision(str)?;226	let (_, str) = try_parse_length_modifier(str)?;227	let (convtype, str) = parse_conversion_type(str)?;228229	Ok((230		Code {231			mkey,232			cflags,233			width,234			precision,235			convtype: convtype.v,236			caps: convtype.caps,237		},238		str,239	))240}241242#[derive(Debug)]243pub enum Element<'s> {244	String(&'s str),245	Code(Code<'s>),246}247pub fn parse_codes(mut str: &str) -> Result<Vec<Element>> {248	let mut bytes = str.as_bytes();249	let mut out = vec![];250	let mut offset = 0;251252	loop {253		while offset != bytes.len() && bytes[offset] != b'%' {254			offset += 1;255		}256		if offset != 0 {257			out.push(Element::String(&str[0..offset]));258		}259		if offset == bytes.len() {260			return Ok(out);261		}262		str = &str[offset + 1..];263		let (code, nstr) = parse_code(str)?;264		str = nstr;265		bytes = str.as_bytes();266		offset = 0;267268		out.push(Element::Code(code))269	}270}271272const NUMBERS: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyz";273274#[inline]275pub fn render_integer(276	out: &mut String,277	iv: i64,278	padding: usize,279	precision: usize,280	blank: bool,281	sign: bool,282	radix: i64,283	prefix: &str,284	caps: bool,285) {286	// Digit char indexes in reverse order, i.e287	// for radix = 16 and n = 12f: [15, 2, 1]288	let digits = if iv == 0 {289		vec![0u8]290	} else {291		let mut v = iv.abs();292		let mut nums = Vec::with_capacity(1);293		while v > 0 {294			nums.push((v % radix) as u8);295			v /= radix;296		}297		nums298	};299	let neg = iv < 0;300	let zp = padding.saturating_sub(if neg || blank || sign { 1 } else { 0 });301	let zp2 = zp302		.max(precision)303		.saturating_sub(prefix.len() + digits.len());304305	if neg {306		out.push('-')307	} else if sign {308		out.push('+');309	} else if blank {310		out.push(' ');311	}312313	out.reserve(zp2);314	for _ in 0..zp2 {315		out.push('0');316	}317	out.push_str(&prefix);318319	for digit in digits.into_iter().rev() {320		let ch = NUMBERS[digit as usize] as char;321		out.push(if caps { ch.to_ascii_uppercase() } else { ch });322	}323}324325pub fn render_decimal(326	out: &mut String,327	iv: i64,328	padding: usize,329	precision: usize,330	blank: bool,331	sign: bool,332) {333	render_integer(out, iv, padding, precision, blank, sign, 10, "", false)334}335pub fn render_octal(336	out: &mut String,337	iv: i64,338	padding: usize,339	precision: usize,340	alt: bool,341	blank: bool,342	sign: bool,343) {344	render_integer(345		out,346		iv,347		padding,348		precision,349		blank,350		sign,351		8,352		if alt && iv != 0 { "0" } else { "" },353		false,354	)355}356pub fn render_hexadecimal(357	out: &mut String,358	iv: i64,359	padding: usize,360	precision: usize,361	alt: bool,362	blank: bool,363	sign: bool,364	caps: bool,365) {366	render_integer(367		out,368		iv,369		padding,370		precision,371		blank,372		sign,373		16,374		match (alt, caps) {375			(true, true) => "0X",376			(true, false) => "0x",377			(false, _) => "",378		},379		caps,380	)381}382383pub fn render_float(384	out: &mut String,385	n: f64,386	mut padding: usize,387	precision: usize,388	blank: bool,389	sign: bool,390	ensure_pt: bool,391	trailing: bool,392) {393	let dot_size = if precision == 0 && !ensure_pt { 0 } else { 1 };394	padding = padding.saturating_sub(dot_size + precision);395	render_decimal(out, n.floor() as i64, padding, 0, blank, sign);396	if precision == 0 {397		if ensure_pt {398			out.push('.');399		}400		return;401	}402	let frac = (n.fract() * 10.0_f64.powf(precision as f64) + 0.5).floor();403	if trailing || frac > 0.0 {404		out.push('.');405		let mut frac_str = String::new();406		render_decimal(&mut frac_str, frac as i64, precision, 0, false, false);407		let mut trim = frac_str.len();408		if !trailing {409			for b in frac_str.as_bytes().iter().rev() {410				if *b == b'0' {411					trim -= 1;412				}413			}414		}415		out.push_str(&frac_str[..trim]);416	} else if ensure_pt {417		out.push('.');418	}419}420421pub fn render_float_sci(422	out: &mut String,423	n: f64,424	mut padding: usize,425	precision: usize,426	blank: bool,427	sign: bool,428	ensure_pt: bool,429	trailing: bool,430	caps: bool,431) {432	let exponent = n.log10().floor();433	let mantissa = if exponent as i16 == -324 {434		n * 10.0 / 10.0_f64.powf(exponent + 1.0)435	} else {436		n / 10.0_f64.powf(exponent)437	};438	let mut exponent_str = String::new();439	render_decimal(&mut exponent_str, exponent as i64, 3, 0, false, true);440441	// +1 for e442	padding = padding.saturating_sub(exponent_str.len() + 1);443444	render_float(445		out, mantissa, padding, precision, blank, sign, ensure_pt, trailing,446	);447	out.push(if caps { 'E' } else { 'e' });448	out.push_str(&exponent_str);449}450451pub fn format_code(452	out: &mut String,453	value: &Val,454	code: &Code,455	width: usize,456	precision: Option<usize>,457) -> Result<()> {458	let clfags = &code.cflags;459	let (fpprec, iprec) = match precision {460		Some(v) => (v, v),461		None => (6, 0),462	};463	let padding = if clfags.zero && !clfags.left {464		width465	} else {466		0467	};468469	// TODO: If left padded, can optimize by writing directly to out470	let mut tmp_out = String::new();471472	match code.convtype {473		ConvTypeV::String => tmp_out.push_str(&value.clone().to_string()?),474		ConvTypeV::Decimal => {475			let value = value.clone().try_cast_num("%d/%u/%i requires number")?;476			render_decimal(477				&mut tmp_out,478				value as i64,479				padding,480				iprec,481				clfags.blank,482				clfags.sign,483			);484		}485		ConvTypeV::Octal => {486			let value = value.clone().try_cast_num("%o requires number")?;487			render_octal(488				&mut tmp_out,489				value as i64,490				padding,491				iprec,492				clfags.alt,493				clfags.blank,494				clfags.sign,495			);496		}497		ConvTypeV::Hexadecimal => {498			let value = value.clone().try_cast_num("%x/%X requires number")?;499			render_hexadecimal(500				&mut tmp_out,501				value as i64,502				padding,503				iprec,504				clfags.alt,505				clfags.blank,506				clfags.sign,507				code.caps,508			);509		}510		ConvTypeV::Scientific => {511			let value = value.clone().try_cast_num("%e/%E requires number")?;512			render_float_sci(513				&mut tmp_out,514				value,515				padding,516				fpprec,517				clfags.blank,518				clfags.sign,519				clfags.alt,520				true,521				code.caps,522			);523		}524		ConvTypeV::Float => {525			let value = value.clone().try_cast_num("%e/%E requires number")?;526			render_float(527				&mut tmp_out,528				value,529				padding,530				fpprec,531				clfags.blank,532				clfags.sign,533				clfags.alt,534				true,535			);536		}537		ConvTypeV::Shorter => {538			let value = value.clone().try_cast_num("%g/%G requires number")?;539			let exponent = value.log10().floor();540			if exponent < -4.0 || exponent >= fpprec as f64 {541				render_float_sci(542					&mut tmp_out,543					value,544					padding,545					fpprec - 1,546					clfags.blank,547					clfags.sign,548					clfags.alt,549					clfags.alt,550					code.caps,551				);552			} else {553				let digits_before_pt = 1.max(exponent as usize + 1);554				render_float(555					&mut tmp_out,556					value,557					padding,558					fpprec - digits_before_pt,559					clfags.blank,560					clfags.sign,561					clfags.alt,562					clfags.alt,563				);564			}565		}566		ConvTypeV::Char => match value.clone().unwrap_if_lazy()? {567			Val::Num(n) => tmp_out.push(568				std::char::from_u32(n as u32)569					.ok_or_else(|| InvalidUnicodeCodepointGot(n as u32))?,570			),571			Val::Str(s) => {572				if s.chars().count() != 1 {573					throw!(RuntimeError(574						format!("%c expected 1 char string, got {}", s.chars().count()).into(),575					));576				}577				tmp_out.push_str(&s);578			}579			_ => {580				throw!(TypeMismatch(581					"%c requires number/string",582					vec![ValType::Num, ValType::Str],583					value.value_type()?,584				));585			}586		},587		ConvTypeV::Percent => tmp_out.push('%'),588	};589590	let padding = width.saturating_sub(tmp_out.len());591592	if !clfags.left {593		for _ in 0..padding {594			out.push(' ');595		}596	}597	out.push_str(&tmp_out);598	if clfags.left {599		for _ in 0..padding {600			out.push(' ');601		}602	}603604	Ok(())605}606607pub fn format_arr(str: &str, mut values: &[Val]) -> Result<String> {608	let codes = parse_codes(&str)?;609	let mut out = String::new();610611	for code in codes {612		match code {613			Element::String(s) => {614				out.push_str(s);615			}616			Element::Code(c) => {617				let width = match c.width {618					Width::Star => {619						if values.is_empty() {620							throw!(NotEnoughValues);621						}622						let value = &values[0];623						values = &values[1..];624						value.clone().try_cast_num("field width")? as usize625					}626					Width::Fixed(n) => n,627				};628				let precision = match c.precision {629					Some(Width::Star) => {630						if values.is_empty() {631							throw!(NotEnoughValues);632						}633						let value = &values[0];634						values = &values[1..];635						Some(value.clone().try_cast_num("field precision")? as usize)636					}637					Some(Width::Fixed(n)) => Some(n),638					None => None,639				};640641				// %% should not consume a value642				let value = if c.convtype == ConvTypeV::Percent {643					&Val::Null644				} else {645					if values.is_empty() {646						throw!(NotEnoughValues);647					}648					let value = &values[0];649					values = &values[1..];650					value651				};652653				format_code(&mut out, value, &c, width, precision)?;654			}655		}656	}657658	Ok(out)659}660661pub fn format_obj(str: &str, values: &ObjValue) -> Result<String> {662	let codes = parse_codes(&str)?;663	let mut out = String::new();664665	for code in codes {666		match code {667			Element::String(s) => {668				out.push_str(s);669			}670			Element::Code(c) => {671				// TODO: Operate on ref672				let f: Rc<str> = c.mkey.into();673				let width = match c.width {674					Width::Star => {675						throw!(CannotUseStarWidthWithObject);676					}677					Width::Fixed(n) => n,678				};679				let precision = match c.precision {680					Some(Width::Star) => {681						throw!(CannotUseStarWidthWithObject);682					}683					Some(Width::Fixed(n)) => Some(n),684					None => None,685				};686687				let value = if c.convtype == ConvTypeV::Percent {688					Val::Null689				} else {690					if f.is_empty() {691						throw!(MappingKeysRequired);692					}693					if let Some(v) = values.get(f.clone())? {694						v695					} else {696						throw!(NoSuchFormatField(f));697					}698				};699700				format_code(&mut out, &value, &c, width, precision)?;701			}702		}703	}704705	Ok(out)706}707708#[cfg(test)]709pub mod test_format {710	use super::*;711712	#[test]713	fn parse() {714		assert_eq!(715			parse_codes(716				"How much error budget is left looking at our %.3f%% availability gurantees?"717			)718			.unwrap()719			.len(),720			4721		);722	}723724	#[test]725	fn octals() {726		assert_eq!(format_arr("%#o", &[Val::Num(8.0)]).unwrap(), "010");727		assert_eq!(format_arr("%#4o", &[Val::Num(8.0)]).unwrap(), " 010");728		assert_eq!(format_arr("%4o", &[Val::Num(8.0)]).unwrap(), "  10");729		assert_eq!(format_arr("%04o", &[Val::Num(8.0)]).unwrap(), "0010");730		assert_eq!(format_arr("%+4o", &[Val::Num(8.0)]).unwrap(), " +10");731		assert_eq!(format_arr("%+04o", &[Val::Num(8.0)]).unwrap(), "+010");732		assert_eq!(format_arr("%-4o", &[Val::Num(8.0)]).unwrap(), "10  ");733		assert_eq!(format_arr("%+-4o", &[Val::Num(8.0)]).unwrap(), "+10 ");734		assert_eq!(format_arr("%+-04o", &[Val::Num(8.0)]).unwrap(), "+10 ");735	}736737	#[test]738	fn percent_doesnt_consumes_values() {739		assert_eq!(740			format_arr(741				"How much error budget is left looking at our %.3f%% availability gurantees?",742				&[Val::Num(4.0)]743			)744			.unwrap(),745			"How much error budget is left looking at our 4.000% availability gurantees?"746		);747	}748}
modifiedcrates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/manifest.rs
@@ -20,7 +20,7 @@
 	pub mtype: ManifestType,
 }
 
-pub(crate) fn manifest_json_ex(val: &Val, options: &ManifestJsonOptions<'_>) -> Result<String> {
+pub fn manifest_json_ex(val: &Val, options: &ManifestJsonOptions<'_>) -> Result<String> {
 	let mut out = String::new();
 	manifest_json_ex_buf(val, &mut out, &mut String::new(), options)?;
 	Ok(out)
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -16,6 +16,7 @@
 pub mod manifest;
 pub mod sort;
 
+#[allow(clippy::cognitive_complexity)]
 pub fn call_builtin(
 	context: Context,
 	loc: &Option<ExprLocation>,
@@ -23,7 +24,7 @@
 	name: &str,
 	args: &ArgsDesc,
 ) -> Result<Val> {
-	Ok(match (ns, &name as &str) {
+	Ok(match (ns, name as &str) {
 		// arr/string/function
 		("std", "length") => parse_args!(context, "std.length", args, 1, [
 			0, x: [Val::Str|Val::Arr|Val::Obj], vec![ValType::Str, ValType::Arr, ValType::Obj];
modifiedcrates/jrsonnet-evaluator/src/builtin/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/stdlib.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/stdlib.rs
@@ -22,7 +22,7 @@
 		}
 
 		jrsonnet_parser::parse(
-			&jrsonnet_stdlib::STDLIB_STR,
+			jrsonnet_stdlib::STDLIB_STR,
 			&ParserSettings {
 				loc_data: true,
 				file_name: Rc::new(PathBuf::from("std.jsonnet")),
modifiedcrates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -48,8 +48,8 @@
 		&self.0.super_obj
 	}
 
-	pub fn new() -> Context {
-		Context(Rc::new(ContextInternals {
+	pub fn new() -> Self {
+		Self(Rc::new(ContextInternals {
 			dollar: None,
 			this: None,
 			super_obj: None,
@@ -65,14 +65,14 @@
 			.cloned()
 			.ok_or_else(|| UnknownVariable(name))?)
 	}
-	pub fn into_future(self, ctx: FutureContext) -> Context {
+	pub fn into_future(self, ctx: FutureContext) -> Self {
 		{
 			ctx.0.borrow_mut().replace(self);
 		}
 		ctx.unwrap()
 	}
 
-	pub fn with_var(self, name: Rc<str>, value: Val) -> Context {
+	pub fn with_var(self, name: Rc<str>, value: Val) -> Self {
 		let mut new_bindings =
 			FxHashMap::with_capacity_and_hasher(1, BuildHasherDefault::default());
 		new_bindings.insert(name, resolved_lazy_val!(value));
@@ -85,7 +85,7 @@
 		new_dollar: Option<ObjValue>,
 		new_this: Option<ObjValue>,
 		new_super_obj: Option<ObjValue>,
-	) -> Context {
+	) -> Self {
 		match Rc::try_unwrap(self.0) {
 			Ok(mut ctx) => {
 				// Extended context aren't used by anything else, we can freely mutate it without cloning
@@ -101,7 +101,7 @@
 				if !new_bindings.is_empty() {
 					ctx.bindings = ctx.bindings.extend(new_bindings);
 				}
-				Context(Rc::new(ctx))
+				Self(Rc::new(ctx))
 			}
 			Err(ctx) => {
 				let dollar = new_dollar.or_else(|| ctx.dollar.clone());
@@ -112,7 +112,7 @@
 				} else {
 					ctx.bindings.clone().extend(new_bindings)
 				};
-				Context(Rc::new(ContextInternals {
+				Self(Rc::new(ContextInternals {
 					dollar,
 					this,
 					super_obj,
@@ -127,7 +127,7 @@
 		new_dollar: Option<ObjValue>,
 		new_this: Option<ObjValue>,
 		new_super_obj: Option<ObjValue>,
-	) -> Result<Context> {
+	) -> Result<Self> {
 		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 =
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -95,10 +95,10 @@
 		Self(Box::new((e, StackTrace(vec![]))))
 	}
 
-	pub fn error(&self) -> &Error {
+	pub const fn error(&self) -> &Error {
 		&(self.0).0
 	}
-	pub fn trace(&self) -> &StackTrace {
+	pub const fn trace(&self) -> &StackTrace {
 		&(self.0).1
 	}
 	pub fn trace_mut(&mut self) -> &mut StackTrace {
modifiedcrates/jrsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate.rs
@@ -82,9 +82,9 @@
 	})
 }
 
-pub(crate) fn evaluate_add_op(a: &Val, b: &Val) -> Result<Val> {
+pub fn evaluate_add_op(a: &Val, b: &Val) -> Result<Val> {
 	Ok(match (a, b) {
-		(Val::Str(v1), Val::Str(v2)) => Val::Str(((**v1).to_owned() + &v2).into()),
+		(Val::Str(v1), Val::Str(v2)) => Val::Str(((**v1).to_owned() + v2).into()),
 
 		// Can't use generic json serialization way, because it depends on number to string concatenation (std.jsonnet:890)
 		(Val::Num(n), Val::Str(o)) => Val::Str(format!("{}{}", n, o).into()),
@@ -111,7 +111,7 @@
 	b: &LocExpr,
 ) -> Result<Val> {
 	Ok(
-		match (evaluate(context.clone(), &a)?.unwrap_if_lazy()?, op, b) {
+		match (evaluate(context.clone(), a)?.unwrap_if_lazy()?, op, b) {
 			(Val::Bool(true), BinaryOpType::Or, _o) => Val::Bool(true),
 			(Val::Bool(false), BinaryOpType::And, _o) => Val::Bool(false),
 			(a, op, eb) => {
@@ -194,14 +194,14 @@
 	Ok(match specs.get(0) {
 		None => Some(vec![value(context)?]),
 		Some(CompSpec::IfSpec(IfSpecData(cond))) => {
-			if evaluate(context.clone(), &cond)?.try_cast_bool("if spec")? {
+			if evaluate(context.clone(), cond)?.try_cast_bool("if spec")? {
 				evaluate_comp(context, value, &specs[1..])?
 			} else {
 				None
 			}
 		}
 		Some(CompSpec::ForSpec(ForSpecData(var, expr))) => {
-			match evaluate(context.clone(), &expr)?.unwrap_if_lazy()? {
+			match evaluate(context.clone(), expr)?.unwrap_if_lazy()? {
 				Val::Arr(list) => {
 					let mut out = Vec::new();
 					for item in list.iter() {
@@ -258,7 +258,7 @@
 				visibility,
 				value,
 			}) => {
-				let name = evaluate_field_name(context.clone(), &name)?;
+				let name = evaluate_field_name(context.clone(), name)?;
 				if name.is_none() {
 					continue;
 				}
@@ -286,7 +286,7 @@
 				value,
 				..
 			}) => {
-				let name = evaluate_field_name(context.clone(), &name)?;
+				let name = evaluate_field_name(context.clone(), name)?;
 				if name.is_none() {
 					continue;
 				}
@@ -320,7 +320,7 @@
 
 pub fn evaluate_object(context: Context, object: &ObjBody) -> Result<ObjValue> {
 	Ok(match object {
-		ObjBody::MemberList(members) => evaluate_member_list_object(context, &members)?,
+		ObjBody::MemberList(members) => evaluate_member_list_object(context, members)?,
 		ObjBody::ObjComp(obj) => {
 			let future_this = FutureObjValue::new();
 			let mut new_members = HashMap::new();
@@ -437,7 +437,7 @@
 		Parened(e) => evaluate(context, e)?,
 		Str(v) => Val::Str(v.clone()),
 		Num(v) => Val::new_checked_num(*v)?,
-		BinaryOp(v1, o, v2) => evaluate_binary_op_special(context, &v1, *o, &v2)?,
+		BinaryOp(v1, o, v2) => evaluate_binary_op_special(context, v1, *o, v2)?,
 		UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(context, v)?)?,
 		Var(name) => push(
 			loc,
@@ -461,7 +461,7 @@
 				(Val::Obj(v), Val::Str(s)) => {
 					let sn = s.clone();
 					push(
-						&loc,
+						loc,
 						|| format!("field <{}> access", sn),
 						|| {
 							if let Some(v) = v.get(s.clone())? {
@@ -563,7 +563,7 @@
 				&value.1,
 				|| "assertion condition".to_owned(),
 				|| {
-					evaluate(context.clone(), &value)?
+					evaluate(context.clone(), value)?
 						.try_cast_bool("assertion condition should be of type `boolean`")
 				},
 			)?;
@@ -576,7 +576,7 @@
 			}
 		}
 		ErrorStmt(e) => push(
-			&loc,
+			loc,
 			|| "error statement".to_owned(),
 			|| {
 				throw!(RuntimeError(
@@ -610,7 +610,7 @@
 			push(
 				loc,
 				|| format!("import {:?}", path),
-				|| with_state(|s| s.import_file(&import_location, path)),
+				|| with_state(|s| s.import_file(import_location, path)),
 			)?
 		}
 		ImportStr(path) => {
@@ -620,7 +620,7 @@
 				.0;
 			let import_location = Rc::make_mut(&mut tmp);
 			import_location.pop();
-			Val::Str(with_state(|s| s.import_file_str(&import_location, path))?)
+			Val::Str(with_state(|s| s.import_file_str(import_location, path))?)
 		}
 		Literal(LiteralType::Super) => throw!(StandaloneSuper),
 	})
modifiedcrates/jrsonnet-evaluator/src/function.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function.rs
+++ b/crates/jrsonnet-evaluator/src/function.rs
@@ -75,7 +75,7 @@
 		let idx = params
 			.iter()
 			.position(|p| *p.0 == **name)
-			.ok_or_else(|| UnknownFunctionParameter((&name as &str).to_owned()))?;
+			.ok_or_else(|| UnknownFunctionParameter((name as &str).to_owned()))?;
 
 		if idx >= params.len() {
 			throw!(TooManyArgsFunctionHas(params.len()));
@@ -111,7 +111,7 @@
 	Ok(body_ctx.unwrap_or(ctx).extend(out, None, None, None))
 }
 
-pub(crate) fn place_args(
+pub fn place_args(
 	ctx: Context,
 	body_ctx: Option<Context>,
 	params: &ParamsDesc,
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/import.rs
+++ b/crates/jrsonnet-evaluator/src/import.rs
@@ -41,6 +41,7 @@
 		panic!("`as_any($self)` is not supported by dummy resolver")
 	}
 }
+#[allow(clippy::use_self)]
 impl Default for Box<dyn ImportResolver> {
 	fn default() -> Self {
 		Box::new(DummyImportResolver)
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -14,10 +14,10 @@
 	type Error = LocError;
 	fn try_from(v: &Val) -> Result<Self> {
 		Ok(match v {
-			Val::Bool(b) => Value::Bool(*b),
-			Val::Null => Value::Null,
-			Val::Str(s) => Value::String((&s as &str).into()),
-			Val::Num(n) => Value::Number(if n.fract() <= f64::EPSILON {
+			Val::Bool(b) => Self::Bool(*b),
+			Val::Null => Self::Null,
+			Val::Str(s) => Self::String((s as &str).into()),
+			Val::Num(n) => Self::Number(if n.fract() <= f64::EPSILON {
 				(*n as i64).into()
 			} else {
 				Number::from_f64(*n).expect("to json number")
@@ -28,7 +28,7 @@
 				for item in a.iter() {
 					out.push(item.try_into()?);
 				}
-				Value::Array(out)
+				Self::Array(out)
 			}
 			Val::Obj(o) => {
 				let mut out = Map::new();
@@ -38,7 +38,7 @@
 						(&o.get(key)?.expect("field exists")).try_into()?,
 					);
 				}
-				Value::Object(out)
+				Self::Object(out)
 			}
 			Val::Func(_) => throw!(RuntimeError("tried to manifest function".into())),
 		})
@@ -48,16 +48,16 @@
 impl From<&Value> for Val {
 	fn from(v: &Value) -> Self {
 		match v {
-			Value::Null => Val::Null,
-			Value::Bool(v) => Val::Bool(*v),
-			Value::Number(n) => Val::Num(n.as_f64().expect("as f64")),
-			Value::String(s) => Val::Str((s as &str).into()),
+			Value::Null => Self::Null,
+			Value::Bool(v) => Self::Bool(*v),
+			Value::Number(n) => Self::Num(n.as_f64().expect("as f64")),
+			Value::String(s) => Self::Str((s as &str).into()),
 			Value::Array(a) => {
 				let mut out = Vec::with_capacity(a.len());
 				for v in a {
 					out.push(v.into());
 				}
-				Val::Arr(Rc::new(out))
+				Self::Arr(Rc::new(out))
 			}
 			Value::Object(o) => {
 				let mut entries = HashMap::with_capacity(o.len());
@@ -72,7 +72,7 @@
 						},
 					);
 				}
-				Val::Obj(ObjValue::new(None, Rc::new(entries)))
+				Self::Obj(ObjValue::new(None, Rc::new(entries)))
 			}
 		}
 	}
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -1,5 +1,6 @@
 #![cfg_attr(feature = "unstable", feature(stmt_expr_attributes))]
 #![allow(macro_expanded_macro_exports_accessed_by_absolute_paths)]
+#![warn(clippy::all, clippy::nursery)]
 
 mod builtin;
 mod ctx;
@@ -49,8 +50,8 @@
 impl LazyBinding {
 	pub fn evaluate(&self, this: Option<ObjValue>, super_obj: Option<ObjValue>) -> Result<LazyVal> {
 		match self {
-			LazyBinding::Bindable(v) => v(this, super_obj),
-			LazyBinding::Bound(v) => Ok(v.clone()),
+			Self::Bindable(v) => v(this, super_obj),
+			Self::Bound(v) => Ok(v.clone()),
 		}
 	}
 }
@@ -77,7 +78,7 @@
 }
 impl Default for EvaluationSettings {
 	fn default() -> Self {
-		EvaluationSettings {
+		Self {
 			max_stack: 200,
 			max_trace: 20,
 			globals: Default::default(),
@@ -130,7 +131,7 @@
 	f: impl FnOnce() -> Result<T>,
 ) -> Result<T> {
 	if let Some(v) = e {
-		with_state(|s| s.push(&v, frame_desc, f))
+		with_state(|s| s.push(v, frame_desc, f))
 	} else {
 		f()
 	}
@@ -359,10 +360,10 @@
 /// Raw methods evaluate passed values but don't perform TLA execution
 impl EvaluationState {
 	pub fn evaluate_file_raw(&self, name: &PathBuf) -> Result<Val> {
-		self.run_in_state(|| self.import_file(&std::env::current_dir().expect("cwd"), &name))
+		self.run_in_state(|| self.import_file(&std::env::current_dir().expect("cwd"), name))
 	}
 	pub fn evaluate_file_raw_nocwd(&self, name: &PathBuf) -> Result<Val> {
-		self.run_in_state(|| self.import_file(&PathBuf::from("."), &name))
+		self.run_in_state(|| self.import_file(&PathBuf::from("."), name))
 	}
 	/// Parses and evaluates the given snippet
 	pub fn evaluate_snippet_raw(&self, source: Rc<PathBuf>, code: Rc<str>) -> Result<Val> {
modifiedcrates/jrsonnet-evaluator/src/map.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/map.rs
+++ b/crates/jrsonnet-evaluator/src/map.rs
@@ -15,10 +15,10 @@
 		match Rc::try_unwrap(self.0) {
 			Ok(mut map) => {
 				map.current.extend(new_layer);
-				LayeredHashMap(Rc::new(map))
+				Self(Rc::new(map))
 			}
-			Err(this) => LayeredHashMap(Rc::new(LayeredHashMapInternals {
-				parent: Some(LayeredHashMap(this)),
+			Err(this) => Self(Rc::new(LayeredHashMapInternals {
+				parent: Some(Self(this)),
 				current: new_layer,
 			})),
 		}
@@ -31,20 +31,20 @@
 	{
 		(self.0)
 			.current
-			.get(&key)
+			.get(key)
 			.or_else(|| self.0.parent.as_ref().and_then(|p| p.get(key)))
 	}
 }
 
 impl<K: Hash, V> Clone for LayeredHashMap<K, V> {
 	fn clone(&self) -> Self {
-		LayeredHashMap(self.0.clone())
+		Self(self.0.clone())
 	}
 }
 
 impl<K: Hash + Eq, V> Default for LayeredHashMap<K, V> {
 	fn default() -> Self {
-		LayeredHashMap(Rc::new(LayeredHashMapInternals {
+		Self(Rc::new(LayeredHashMapInternals {
 			parent: None,
 			current: FxHashMap::default(),
 		}))
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -47,23 +47,20 @@
 }
 
 impl ObjValue {
-	pub fn new(
-		super_obj: Option<ObjValue>,
-		this_entries: Rc<HashMap<Rc<str>, ObjMember>>,
-	) -> ObjValue {
-		ObjValue(Rc::new(ObjValueInternals {
+	pub fn new(super_obj: Option<Self>, this_entries: Rc<HashMap<Rc<str>, ObjMember>>) -> Self {
+		Self(Rc::new(ObjValueInternals {
 			super_obj,
 			this_entries,
 			value_cache: RefCell::new(HashMap::new()),
 		}))
 	}
-	pub fn new_empty() -> ObjValue {
+	pub fn new_empty() -> Self {
 		Self::new(None, Rc::new(HashMap::new()))
 	}
-	pub fn with_super(&self, super_obj: ObjValue) -> ObjValue {
+	pub fn with_super(&self, super_obj: Self) -> Self {
 		match &self.0.super_obj {
-			None => ObjValue::new(Some(super_obj), self.0.this_entries.clone()),
-			Some(v) => ObjValue::new(Some(v.with_super(super_obj)), self.0.this_entries.clone()),
+			None => Self::new(Some(super_obj), self.0.this_entries.clone()),
+			Some(v) => Self::new(Some(v.with_super(super_obj)), self.0.this_entries.clone()),
 		}
 	}
 	pub fn enum_fields(&self, handler: &impl Fn(&Rc<str>, &Visibility)) {
@@ -71,7 +68,7 @@
 			s.enum_fields(handler);
 		}
 		for (name, member) in self.0.this_entries.iter() {
-			handler(&name, &member.visibility);
+			handler(name, &member.visibility);
 		}
 	}
 	pub fn fields_visibility(&self) -> IndexMap<Rc<str>, bool> {
@@ -107,7 +104,7 @@
 	pub fn get(&self, key: Rc<str>) -> Result<Option<Val>> {
 		Ok(self.get_raw(key, self)?)
 	}
-	pub(crate) fn get_raw(&self, key: Rc<str>, real_this: &ObjValue) -> Result<Option<Val>> {
+	pub(crate) fn get_raw(&self, key: Rc<str>, real_this: &Self) -> Result<Option<Val>> {
 		let cache_key = (key.clone(), Rc::as_ptr(&real_this.0) as usize);
 
 		if let Some(v) = self.0.value_cache.borrow().get(&cache_key) {
@@ -135,7 +132,7 @@
 			.insert(cache_key, value.clone());
 		Ok(value)
 	}
-	fn evaluate_this(&self, v: &ObjMember, real_this: &ObjValue) -> Result<Val> {
+	fn evaluate_this(&self, v: &ObjMember, real_this: &Self) -> Result<Val> {
 		Ok(v.invoke
 			.evaluate(Some(real_this.clone()), self.0.super_obj.clone())?
 			.evaluate()?)
modifiedcrates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/trace/mod.rs
+++ b/crates/jrsonnet-evaluator/src/trace/mod.rs
@@ -17,9 +17,9 @@
 impl PathResolver {
 	pub fn resolve(&self, from: &PathBuf) -> String {
 		match self {
-			PathResolver::FileName => from.file_name().unwrap().to_string_lossy().into_owned(),
-			PathResolver::Absolute => from.to_string_lossy().into_owned(),
-			PathResolver::Relative(base) => {
+			Self::FileName => from.file_name().unwrap().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();
 				}
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -25,10 +25,10 @@
 pub struct LazyVal(Rc<RefCell<LazyValInternals>>);
 impl LazyVal {
 	pub fn new(f: Box<dyn Fn() -> Result<Val>>) -> Self {
-		LazyVal(Rc::new(RefCell::new(LazyValInternals::Waiting(f))))
+		Self(Rc::new(RefCell::new(LazyValInternals::Waiting(f))))
 	}
 	pub fn new_resolved(val: Val) -> Self {
-		LazyVal(Rc::new(RefCell::new(LazyValInternals::Computed(val))))
+		Self(Rc::new(RefCell::new(LazyValInternals::Computed(val))))
 	}
 	pub fn evaluate(&self) -> Result<Val> {
 		let new_value = match &*self.0.borrow() {
@@ -84,22 +84,22 @@
 impl PartialEq for FuncVal {
 	fn eq(&self, other: &Self) -> bool {
 		match (self, other) {
-			(FuncVal::Normal(a), FuncVal::Normal(b)) => a == b,
-			(FuncVal::Intrinsic(ans, an), FuncVal::Intrinsic(bns, bn)) => ans == bns && an == bn,
-			(FuncVal::NativeExt(an, _), FuncVal::NativeExt(bn, _)) => an == bn,
+			(Self::Normal(a), Self::Normal(b)) => a == b,
+			(Self::Intrinsic(ans, an), Self::Intrinsic(bns, bn)) => ans == bns && an == bn,
+			(Self::NativeExt(an, _), Self::NativeExt(bn, _)) => an == bn,
 			(..) => false,
 		}
 	}
 }
 impl FuncVal {
 	pub fn is_ident(&self) -> bool {
-		matches!(&self, FuncVal::Intrinsic(ns, n) if ns as &str == "std" && n as &str == "id")
+		matches!(&self, Self::Intrinsic(ns, n) if ns as &str == "std" && n as &str == "id")
 	}
 	pub fn name(&self) -> Rc<str> {
 		match self {
-			FuncVal::Normal(normal) => normal.name.clone(),
-			FuncVal::Intrinsic(ns, name) => format!("intrinsic.{}.{}", ns, name).into(),
-			FuncVal::NativeExt(n, _) => format!("native.{}", n).into(),
+			Self::Normal(normal) => normal.name.clone(),
+			Self::Intrinsic(ns, name) => format!("intrinsic.{}.{}", ns, name).into(),
+			Self::NativeExt(n, _) => format!("native.{}", n).into(),
 		}
 	}
 	pub fn evaluate(
@@ -110,7 +110,7 @@
 		tailstrict: bool,
 	) -> Result<Val> {
 		match self {
-			FuncVal::Normal(func) => {
+			Self::Normal(func) => {
 				let ctx = parse_function_call(
 					call_ctx,
 					Some(func.ctx.clone()),
@@ -120,8 +120,8 @@
 				)?;
 				evaluate(ctx, &func.body)
 			}
-			FuncVal::Intrinsic(ns, name) => call_builtin(call_ctx, loc, &ns, &name, args),
-			FuncVal::NativeExt(_name, handler) => {
+			Self::Intrinsic(ns, name) => call_builtin(call_ctx, loc, ns, name, args),
+			Self::NativeExt(_name, handler) => {
 				let args = parse_function_call(call_ctx, None, &handler.params, args, true)?;
 				let mut out_args = Vec::with_capacity(handler.params.len());
 				for p in handler.params.0.iter() {
@@ -139,7 +139,7 @@
 		tailstrict: bool,
 	) -> Result<Val> {
 		match self {
-			FuncVal::Normal(func) => {
+			Self::Normal(func) => {
 				let ctx = parse_function_call_map(
 					call_ctx,
 					Some(func.ctx.clone()),
@@ -149,19 +149,19 @@
 				)?;
 				evaluate(ctx, &func.body)
 			}
-			FuncVal::Intrinsic(_, _) => todo!(),
-			FuncVal::NativeExt(_, _) => todo!(),
+			Self::Intrinsic(_, _) => todo!(),
+			Self::NativeExt(_, _) => todo!(),
 		}
 	}
 
 	pub fn evaluate_values(&self, call_ctx: Context, args: &[Val]) -> Result<Val> {
 		match self {
-			FuncVal::Normal(func) => {
+			Self::Normal(func) => {
 				let ctx = place_args(call_ctx, Some(func.ctx.clone()), &func.params, args)?;
 				evaluate(ctx, &func.body)
 			}
-			FuncVal::Intrinsic(_, _) => todo!(),
-			FuncVal::NativeExt(_, _) => todo!(),
+			Self::Intrinsic(_, _) => todo!(),
+			Self::NativeExt(_, _) => todo!(),
 		}
 	}
 }
@@ -177,7 +177,7 @@
 	Func,
 }
 impl ValType {
-	pub fn name(&self) -> &'static str {
+	pub const fn name(&self) -> &'static str {
 		use ValType::*;
 		match self {
 			Bool => "boolean",
@@ -227,9 +227,9 @@
 impl Val {
 	/// Creates `Val::Num` after checking for numeric overflow.
 	/// As numbers are `f64`, we can just check for their finity.
-	pub fn new_checked_num(num: f64) -> Result<Val> {
+	pub fn new_checked_num(num: f64) -> Result<Self> {
 		if num.is_finite() {
-			Ok(Val::Num(num))
+			Ok(Self::Num(num))
 		} else {
 			throw!(RuntimeError("overflow".into()))
 		}
@@ -245,24 +245,24 @@
 	}
 	pub fn try_cast_bool(self, context: &'static str) -> Result<bool> {
 		self.assert_type(context, ValType::Bool)?;
-		Ok(matches_unwrap!(self.unwrap_if_lazy()?, Val::Bool(v), v))
+		Ok(matches_unwrap!(self.unwrap_if_lazy()?, Self::Bool(v), v))
 	}
 	pub fn try_cast_str(self, context: &'static str) -> Result<Rc<str>> {
 		self.assert_type(context, ValType::Str)?;
-		Ok(matches_unwrap!(self.unwrap_if_lazy()?, Val::Str(v), v))
+		Ok(matches_unwrap!(self.unwrap_if_lazy()?, Self::Str(v), v))
 	}
 	pub fn try_cast_num(self, context: &'static str) -> Result<f64> {
 		self.assert_type(context, ValType::Num)?;
-		Ok(matches_unwrap!(self.unwrap_if_lazy()?, Val::Num(v), v))
+		Ok(matches_unwrap!(self.unwrap_if_lazy()?, Self::Num(v), v))
 	}
 	pub fn inplace_unwrap(&mut self) -> Result<()> {
-		while let Val::Lazy(lazy) = self {
+		while let Self::Lazy(lazy) = self {
 			*self = lazy.evaluate()?;
 		}
 		Ok(())
 	}
 	pub fn unwrap_if_lazy(&self) -> Result<Self> {
-		Ok(if let Val::Lazy(v) = self {
+		Ok(if let Self::Lazy(v) = self {
 			v.evaluate()?.unwrap_if_lazy()?
 		} else {
 			self.clone()
@@ -270,27 +270,27 @@
 	}
 	pub fn value_type(&self) -> Result<ValType> {
 		Ok(match self {
-			Val::Str(..) => ValType::Str,
-			Val::Num(..) => ValType::Num,
-			Val::Arr(..) => ValType::Arr,
-			Val::Obj(..) => ValType::Obj,
-			Val::Bool(_) => ValType::Bool,
-			Val::Null => ValType::Null,
-			Val::Func(..) => ValType::Func,
-			Val::Lazy(_) => self.clone().unwrap_if_lazy()?.value_type()?,
+			Self::Str(..) => ValType::Str,
+			Self::Num(..) => ValType::Num,
+			Self::Arr(..) => ValType::Arr,
+			Self::Obj(..) => ValType::Obj,
+			Self::Bool(_) => ValType::Bool,
+			Self::Null => ValType::Null,
+			Self::Func(..) => ValType::Func,
+			Self::Lazy(_) => self.clone().unwrap_if_lazy()?.value_type()?,
 		})
 	}
 
 	pub fn to_string(&self) -> Result<Rc<str>> {
 		Ok(match self.unwrap_if_lazy()? {
-			Val::Bool(true) => "true".into(),
-			Val::Bool(false) => "false".into(),
-			Val::Null => "null".into(),
-			Val::Str(s) => s,
+			Self::Bool(true) => "true".into(),
+			Self::Bool(false) => "false".into(),
+			Self::Null => "null".into(),
+			Self::Str(s) => s,
 			v => manifest_json_ex(
 				&v,
 				&ManifestJsonOptions {
-					padding: &"",
+					padding: "",
 					mtype: ManifestType::ToString,
 				},
 			)?
@@ -301,7 +301,7 @@
 	/// Expects value to be object, outputs (key, manifested value) pairs
 	pub fn manifest_multi(&self, ty: &ManifestFormat) -> Result<Vec<(Rc<str>, Rc<str>)>> {
 		let obj = match self {
-			Val::Obj(obj) => obj,
+			Self::Obj(obj) => obj,
 			_ => throw!(MultiManifestOutputIsNotAObject),
 		};
 		let keys = obj.visible_fields();
@@ -319,7 +319,7 @@
 	/// Expects value to be array, outputs manifested values
 	pub fn manifest_stream(&self, ty: &ManifestFormat) -> Result<Vec<Rc<str>>> {
 		let arr = match self {
-			Val::Arr(a) => a,
+			Self::Arr(a) => a,
 			_ => throw!(StreamManifestOutputIsNotAArray),
 		};
 		let mut out = Vec::with_capacity(arr.len());
@@ -333,7 +333,7 @@
 		Ok(match ty {
 			ManifestFormat::YamlStream(format) => {
 				let arr = match self {
-					Val::Arr(a) => a,
+					Self::Arr(a) => a,
 					_ => throw!(StreamManifestOutputIsNotAArray),
 				};
 				let mut out = String::new();
@@ -358,7 +358,7 @@
 			ManifestFormat::Yaml(padding) => self.to_yaml(*padding)?,
 			ManifestFormat::Json(padding) => self.to_json(*padding)?,
 			ManifestFormat::String => match self {
-				Val::Str(s) => s.clone(),
+				Self::Str(s) => s.clone(),
 				_ => throw!(StringManifestOutputIsNotAString),
 			},
 		})
@@ -384,7 +384,7 @@
 	#[cfg(feature = "faster")]
 	pub fn to_std_json(&self, padding: usize) -> Result<Rc<str>> {
 		manifest_json_ex(
-			&self,
+			self,
 			&ManifestJsonOptions {
 				padding: &" ".repeat(padding),
 				mtype: ManifestType::Std,
@@ -441,7 +441,7 @@
 	}
 }
 
-fn is_function_like(val: &Val) -> bool {
+const fn is_function_like(val: &Val) -> bool {
 	matches!(val, Val::Func(_))
 }