git.delta.rocks / jrsonnet / refs/commits / 80f37a416bf7

difftreelog

style enforce import style

Yaroslav Bolyukin2022-04-20parent: #4c00868.patch.diff
in: master

38 files changed

modified.rustfmt.tomldiffbeforeafterboth
--- a/.rustfmt.toml
+++ b/.rustfmt.toml
@@ -1 +1,3 @@
 hard_tabs = true
+imports_granularity = "crate"
+group_imports = "stdexternalcrate"
modifiedbindings/jsonnet/src/import.rsdiffbeforeafterboth
before · bindings/jsonnet/src/import.rs
1//! Import resolution manipulation utilities23use jrsonnet_evaluator::{4	error::{Error::*, Result},5	throw, EvaluationState, ImportResolver,6};7use std::{8	any::Any,9	cell::RefCell,10	collections::HashMap,11	ffi::{c_void, CStr, CString},12	fs::File,13	io::Read,14	os::raw::{c_char, c_int},15	path::{Path, PathBuf},16	ptr::null_mut,17	rc::Rc,18};1920pub type JsonnetImportCallback = unsafe extern "C" fn(21	ctx: *mut c_void,22	base: *const c_char,23	rel: *const c_char,24	found_here: *mut *const c_char,25	success: &mut c_int,26) -> *mut c_char;2728/// Resolves imports using callback29pub struct CallbackImportResolver {30	cb: JsonnetImportCallback,31	ctx: *mut c_void,32	out: RefCell<HashMap<PathBuf, Vec<u8>>>,33}34impl ImportResolver for CallbackImportResolver {35	fn resolve_file(&self, from: &Path, path: &Path) -> Result<Rc<Path>> {36		let base = CString::new(from.to_str().unwrap()).unwrap().into_raw();37		let rel = CString::new(path.to_str().unwrap()).unwrap().into_raw();38		let found_here: *mut c_char = null_mut();39		let mut success: i32 = 0;40		let result_ptr = unsafe {41			(self.cb)(42				self.ctx,43				base,44				rel,45				&mut (found_here as *const _),46				&mut success,47			)48		};49		// Release memory occipied by arguments passed50		unsafe {51			let _ = CString::from_raw(base);52			let _ = CString::from_raw(rel);53		}54		let result_raw = unsafe { CStr::from_ptr(result_ptr) };55		let result_str = result_raw.to_str().unwrap();56		assert!(success == 0 || success == 1);57		if success == 0 {58			unsafe { CString::from_raw(result_ptr) };59			let result = result_str.to_owned();60			throw!(ImportCallbackError(result));61		}6263		let found_here_raw = unsafe { CStr::from_ptr(found_here) };64		let found_here_buf = PathBuf::from(found_here_raw.to_str().unwrap());65		unsafe {66			let _ = CString::from_raw(found_here);67		}6869		let mut out = self.out.borrow_mut();70		if !out.contains_key(&found_here_buf) {71			out.insert(found_here_buf.clone(), result_str.into());72			unsafe { CString::from_raw(result_ptr) };73		}7475		Ok(found_here_buf.into())76	}77	fn load_file_contents(&self, resolved: &Path) -> Result<Vec<u8>> {78		Ok(self.out.borrow().get(resolved).unwrap().clone())79	}8081	unsafe fn as_any(&self) -> &dyn Any {82		self83	}84}8586/// # Safety87#[no_mangle]88pub unsafe extern "C" fn jsonnet_import_callback(89	vm: &EvaluationState,90	cb: JsonnetImportCallback,91	ctx: *mut c_void,92) {93	vm.set_import_resolver(Box::new(CallbackImportResolver {94		cb,95		ctx,96		out: RefCell::new(HashMap::new()),97	}))98}99100/// Standard FS import resolver101#[derive(Default)]102pub struct NativeImportResolver {103	library_paths: RefCell<Vec<PathBuf>>,104}105impl NativeImportResolver {106	fn add_jpath(&self, path: PathBuf) {107		self.library_paths.borrow_mut().push(path);108	}109}110impl ImportResolver for NativeImportResolver {111	fn resolve_file(&self, from: &Path, path: &Path) -> Result<Rc<Path>> {112		let mut new_path = from.to_owned();113		new_path.push(path);114		if new_path.exists() {115			Ok(new_path.into())116		} else {117			for library_path in self.library_paths.borrow().iter() {118				let mut cloned = library_path.clone();119				cloned.push(path);120				if cloned.exists() {121					return Ok(cloned.into());122				}123			}124			throw!(ImportFileNotFound(from.to_owned(), path.to_owned()))125		}126	}127	fn load_file_contents(&self, id: &Path) -> Result<Vec<u8>> {128		let mut file = File::open(id).map_err(|_e| ResolvedFileNotFound(id.to_owned()))?;129		let mut out = Vec::new();130		file.read_to_end(&mut out)131			.map_err(|e| ImportIo(e.to_string()))?;132		Ok(out)133	}134	unsafe fn as_any(&self) -> &dyn Any {135		self136	}137}138139/// # Safety140///141/// This function is safe, if received v is a pointer to normal C string142#[no_mangle]143pub unsafe extern "C" fn jsonnet_jpath_add(vm: &EvaluationState, v: *const c_char) {144	let cstr = CStr::from_ptr(v);145	let path = PathBuf::from(cstr.to_str().unwrap());146	let any_resolver = &vm.settings().import_resolver;147	let resolver = any_resolver148		.as_any()149		.downcast_ref::<NativeImportResolver>()150		.expect("jpaths are not compatible with callback imports!");151	resolver.add_jpath(path);152}
after · bindings/jsonnet/src/import.rs
1//! Import resolution manipulation utilities23use std::{4	any::Any,5	cell::RefCell,6	collections::HashMap,7	ffi::{c_void, CStr, CString},8	fs::File,9	io::Read,10	os::raw::{c_char, c_int},11	path::{Path, PathBuf},12	ptr::null_mut,13	rc::Rc,14};1516use jrsonnet_evaluator::{17	error::{Error::*, Result},18	throw, EvaluationState, ImportResolver,19};2021pub type JsonnetImportCallback = unsafe extern "C" fn(22	ctx: *mut c_void,23	base: *const c_char,24	rel: *const c_char,25	found_here: *mut *const c_char,26	success: &mut c_int,27) -> *mut c_char;2829/// Resolves imports using callback30pub struct CallbackImportResolver {31	cb: JsonnetImportCallback,32	ctx: *mut c_void,33	out: RefCell<HashMap<PathBuf, Vec<u8>>>,34}35impl ImportResolver for CallbackImportResolver {36	fn resolve_file(&self, from: &Path, path: &Path) -> Result<Rc<Path>> {37		let base = CString::new(from.to_str().unwrap()).unwrap().into_raw();38		let rel = CString::new(path.to_str().unwrap()).unwrap().into_raw();39		let found_here: *mut c_char = null_mut();40		let mut success: i32 = 0;41		let result_ptr = unsafe {42			(self.cb)(43				self.ctx,44				base,45				rel,46				&mut (found_here as *const _),47				&mut success,48			)49		};50		// Release memory occipied by arguments passed51		unsafe {52			let _ = CString::from_raw(base);53			let _ = CString::from_raw(rel);54		}55		let result_raw = unsafe { CStr::from_ptr(result_ptr) };56		let result_str = result_raw.to_str().unwrap();57		assert!(success == 0 || success == 1);58		if success == 0 {59			unsafe { CString::from_raw(result_ptr) };60			let result = result_str.to_owned();61			throw!(ImportCallbackError(result));62		}6364		let found_here_raw = unsafe { CStr::from_ptr(found_here) };65		let found_here_buf = PathBuf::from(found_here_raw.to_str().unwrap());66		unsafe {67			let _ = CString::from_raw(found_here);68		}6970		let mut out = self.out.borrow_mut();71		if !out.contains_key(&found_here_buf) {72			out.insert(found_here_buf.clone(), result_str.into());73			unsafe { CString::from_raw(result_ptr) };74		}7576		Ok(found_here_buf.into())77	}78	fn load_file_contents(&self, resolved: &Path) -> Result<Vec<u8>> {79		Ok(self.out.borrow().get(resolved).unwrap().clone())80	}8182	unsafe fn as_any(&self) -> &dyn Any {83		self84	}85}8687/// # Safety88#[no_mangle]89pub unsafe extern "C" fn jsonnet_import_callback(90	vm: &EvaluationState,91	cb: JsonnetImportCallback,92	ctx: *mut c_void,93) {94	vm.set_import_resolver(Box::new(CallbackImportResolver {95		cb,96		ctx,97		out: RefCell::new(HashMap::new()),98	}))99}100101/// Standard FS import resolver102#[derive(Default)]103pub struct NativeImportResolver {104	library_paths: RefCell<Vec<PathBuf>>,105}106impl NativeImportResolver {107	fn add_jpath(&self, path: PathBuf) {108		self.library_paths.borrow_mut().push(path);109	}110}111impl ImportResolver for NativeImportResolver {112	fn resolve_file(&self, from: &Path, path: &Path) -> Result<Rc<Path>> {113		let mut new_path = from.to_owned();114		new_path.push(path);115		if new_path.exists() {116			Ok(new_path.into())117		} else {118			for library_path in self.library_paths.borrow().iter() {119				let mut cloned = library_path.clone();120				cloned.push(path);121				if cloned.exists() {122					return Ok(cloned.into());123				}124			}125			throw!(ImportFileNotFound(from.to_owned(), path.to_owned()))126		}127	}128	fn load_file_contents(&self, id: &Path) -> Result<Vec<u8>> {129		let mut file = File::open(id).map_err(|_e| ResolvedFileNotFound(id.to_owned()))?;130		let mut out = Vec::new();131		file.read_to_end(&mut out)132			.map_err(|e| ImportIo(e.to_string()))?;133		Ok(out)134	}135	unsafe fn as_any(&self) -> &dyn Any {136		self137	}138}139140/// # Safety141///142/// This function is safe, if received v is a pointer to normal C string143#[no_mangle]144pub unsafe extern "C" fn jsonnet_jpath_add(vm: &EvaluationState, v: *const c_char) {145	let cstr = CStr::from_ptr(v);146	let path = PathBuf::from(cstr.to_str().unwrap());147	let any_resolver = &vm.settings().import_resolver;148	let resolver = any_resolver149		.as_any()150		.downcast_ref::<NativeImportResolver>()151		.expect("jpaths are not compatible with callback imports!");152	resolver.add_jpath(path);153}
modifiedbindings/jsonnet/src/interop.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/interop.rs
+++ b/bindings/jsonnet/src/interop.rs
@@ -1,12 +1,14 @@
 //! Jrsonnet specific additional binding helpers
 
-use crate::{import::jsonnet_import_callback, native::jsonnet_native_callback};
-use jrsonnet_evaluator::{EvaluationState, Val};
 use std::{
 	ffi::c_void,
 	os::raw::{c_char, c_int},
 };
 
+use jrsonnet_evaluator::{EvaluationState, Val};
+
+use crate::{import::jsonnet_import_callback, native::jsonnet_native_callback};
+
 extern "C" {
 	pub fn _jrsonnet_static_import_callback(
 		ctx: *mut c_void,
modifiedbindings/jsonnet/src/lib.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/lib.rs
+++ b/bindings/jsonnet/src/lib.rs
@@ -8,8 +8,6 @@
 pub mod val_modify;
 pub mod vars_tlas;
 
-use import::NativeImportResolver;
-use jrsonnet_evaluator::{EvaluationState, IStr, ManifestFormat, Val};
 use std::{
 	alloc::Layout,
 	ffi::{CStr, CString},
@@ -17,6 +15,9 @@
 	path::PathBuf,
 };
 
+use import::NativeImportResolver;
+use jrsonnet_evaluator::{EvaluationState, IStr, ManifestFormat, Val};
+
 /// WASM stub
 #[cfg(target_arch = "wasm32")]
 #[no_mangle]
modifiedbindings/jsonnet/src/native.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/native.rs
+++ b/bindings/jsonnet/src/native.rs
@@ -1,3 +1,11 @@
+use std::{
+	convert::TryFrom,
+	ffi::{c_void, CStr},
+	os::raw::{c_char, c_int},
+	path::Path,
+	rc::Rc,
+};
+
 use gcmodule::Cc;
 use jrsonnet_evaluator::{
 	error::{Error, LocError},
@@ -5,13 +13,6 @@
 	gc::TraceBox,
 	native::{NativeCallback, NativeCallbackHandler},
 	EvaluationState, IStr, Val,
-};
-use std::{
-	convert::TryFrom,
-	ffi::{c_void, CStr},
-	os::raw::{c_char, c_int},
-	path::Path,
-	rc::Rc,
 };
 
 type JsonnetNativeCallback = unsafe extern "C" fn(
modifiedbindings/jsonnet/src/val_extract.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/val_extract.rs
+++ b/bindings/jsonnet/src/val_extract.rs
@@ -1,12 +1,12 @@
 //! Extract values from VM
 
-use jrsonnet_evaluator::{EvaluationState, Val};
-
 use std::{
 	ffi::CString,
 	os::raw::{c_char, c_double, c_int},
 };
 
+use jrsonnet_evaluator::{EvaluationState, Val};
+
 #[no_mangle]
 pub extern "C" fn jsonnet_json_extract_string(_vm: &EvaluationState, v: &Val) -> *mut c_char {
 	match v {
modifiedbindings/jsonnet/src/val_make.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/val_make.rs
+++ b/bindings/jsonnet/src/val_make.rs
@@ -1,12 +1,13 @@
 //! Create values in VM
 
-use gcmodule::Cc;
-use jrsonnet_evaluator::{ArrValue, EvaluationState, ObjValue, Val};
 use std::{
 	ffi::CStr,
 	os::raw::{c_char, c_double, c_int},
 };
 
+use gcmodule::Cc;
+use jrsonnet_evaluator::{val::ArrValue, EvaluationState, ObjValue, Val};
+
 /// # Safety
 ///
 /// This function is safe, if received v is a pointer to normal C string
modifiedbindings/jsonnet/src/val_modify.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/val_modify.rs
+++ b/bindings/jsonnet/src/val_modify.rs
@@ -2,10 +2,11 @@
 //! Only tested with variables, which haven't altered by code before appearing here
 //! In jrsonnet every value is immutable, and this code is probally broken
 
+use std::{ffi::CStr, os::raw::c_char};
+
 use gcmodule::Cc;
-use jrsonnet_evaluator::{ArrValue, EvaluationState, LazyBinding, LazyVal, ObjMember, Val};
+use jrsonnet_evaluator::{val::ArrValue, EvaluationState, LazyBinding, LazyVal, ObjMember, Val};
 use jrsonnet_parser::Visibility;
-use std::{ffi::CStr, os::raw::c_char};
 
 /// # Safety
 ///
modifiedbindings/jsonnet/src/vars_tlas.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/vars_tlas.rs
+++ b/bindings/jsonnet/src/vars_tlas.rs
@@ -1,8 +1,9 @@
 //! Manipulate external variables and top level arguments
 
-use jrsonnet_evaluator::EvaluationState;
 use std::{ffi::CStr, os::raw::c_char};
 
+use jrsonnet_evaluator::EvaluationState;
+
 /// # Safety
 #[no_mangle]
 pub unsafe extern "C" fn jsonnet_ext_var(
modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -1,13 +1,13 @@
+use std::{
+	fs::{create_dir_all, File},
+	io::{Read, Write},
+	path::PathBuf,
+};
+
 use clap::{AppSettings, IntoApp, Parser};
 use clap_complete::Shell;
 use jrsonnet_cli::{ConfigureState, GcOpts, GeneralOpts, InputOpts, ManifestOpts, OutputOpts};
 use jrsonnet_evaluator::{error::LocError, EvaluationState};
-use std::{
-	fs::{create_dir_all, File},
-	io::Read,
-	io::Write,
-	path::PathBuf,
-};
 
 #[cfg(feature = "mimalloc")]
 #[global_allocator]
modifiedcrates/jrsonnet-cli/src/ext.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/ext.rs
+++ b/crates/jrsonnet-cli/src/ext.rs
@@ -1,8 +1,10 @@
-use crate::ConfigureState;
+use std::{fs::read_to_string, str::FromStr};
+
 use clap::Parser;
 use jrsonnet_evaluator::{error::Result, EvaluationState};
-use std::{fs::read_to_string, str::FromStr};
 
+use crate::ConfigureState;
+
 #[derive(Clone)]
 pub struct ExtStr {
 	pub name: String,
modifiedcrates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/lib.rs
+++ b/crates/jrsonnet-cli/src/lib.rs
@@ -3,14 +3,14 @@
 mod tla;
 mod trace;
 
+use std::{env, path::PathBuf};
+
+use clap::Parser;
 pub use ext::*;
+use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};
 pub use manifest::*;
 pub use tla::*;
 pub use trace::*;
-
-use clap::Parser;
-use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};
-use std::{env, path::PathBuf};
 
 pub trait ConfigureState {
 	fn configure(&self, state: &EvaluationState) -> Result<()>;
modifiedcrates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -1,8 +1,10 @@
-use crate::ConfigureState;
+use std::{path::PathBuf, str::FromStr};
+
 use clap::Parser;
 use jrsonnet_evaluator::{error::Result, EvaluationState, ManifestFormat};
-use std::{path::PathBuf, str::FromStr};
 
+use crate::ConfigureState;
+
 pub enum ManifestFormatName {
 	/// Expect string as output, and write them directly
 	String,
modifiedcrates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -1,7 +1,8 @@
-use crate::{ConfigureState, ExtFile, ExtStr};
 use clap::Parser;
 use jrsonnet_evaluator::{error::Result, EvaluationState};
 
+use crate::{ConfigureState, ExtFile, ExtStr};
+
 #[derive(Parser)]
 #[clap(next_help_heading = "TOP LEVEL ARGUMENTS")]
 pub struct TLAOpts {
modifiedcrates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/trace.rs
+++ b/crates/jrsonnet-cli/src/trace.rs
@@ -1,12 +1,14 @@
-use crate::ConfigureState;
+use std::str::FromStr;
+
 use clap::Parser;
 use jrsonnet_evaluator::{
 	error::Result,
 	trace::{CompactFormat, ExplainingFormat, PathResolver},
 	EvaluationState,
 };
-use std::str::FromStr;
 
+use crate::ConfigureState;
+
 #[derive(PartialEq)]
 pub enum TraceFormatName {
 	Compact,
modifiedcrates/jrsonnet-evaluator/build.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/build.rs
+++ b/crates/jrsonnet-evaluator/build.rs
@@ -1,6 +1,3 @@
-use bincode::serialize;
-use jrsonnet_parser::{parse, ParserSettings};
-use jrsonnet_stdlib::STDLIB_STR;
 use std::{
 	env,
 	fs::File,
@@ -8,6 +5,10 @@
 	path::{Path, PathBuf},
 };
 
+use bincode::serialize;
+use jrsonnet_parser::{parse, ParserSettings};
+use jrsonnet_stdlib::STDLIB_STR;
+
 fn main() {
 	let parsed = parse(
 		STDLIB_STR,
modifiedcrates/jrsonnet-evaluator/src/builtin/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/format.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/format.rs
@@ -1,13 +1,15 @@
 //! faster std.format impl
 #![allow(clippy::too_many_arguments)]
 
-use crate::{error::Error::*, throw, LocError, ObjValue, Result, Val};
+use std::convert::TryFrom;
+
 use gcmodule::Trace;
 use jrsonnet_interner::IStr;
 use jrsonnet_types::ValType;
-use std::convert::TryFrom;
 use thiserror::Error;
 
+use crate::{error::Error::*, throw, LocError, ObjValue, Result, Val};
+
 #[derive(Debug, Clone, Error, Trace)]
 pub enum FormatError {
 	#[error("truncated format code")]
modifiedcrates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/manifest.rs
@@ -1,7 +1,7 @@
-use crate::error::Error::*;
-use crate::error::Result;
-use crate::push_description_frame;
-use crate::{throw, Val};
+use crate::{
+	error::{Error::*, Result},
+	push_description_frame, throw, Val,
+};
 
 #[derive(PartialEq, Clone, Copy)]
 pub enum ManifestType {
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -1,23 +1,25 @@
-use crate::function::{CallLocation, StaticBuiltin};
-use crate::typed::{Any, Bytes, PositiveF64, VecVal, M1};
-use crate::{
-	builtin::manifest::{manifest_yaml_ex, ManifestYamlOptions},
-	equals,
-	error::{Error::*, Result},
-	operator::evaluate_mod_op,
-	primitive_equals, push_frame, throw,
-	typed::{Either2, Either4},
-	with_state, ArrValue, FuncVal, IndexableVal, Val,
+use std::{
+	collections::HashMap,
+	convert::{TryFrom, TryInto},
 };
-use crate::{Either, ObjValue};
+
 use format::{format_arr, format_obj};
 use gcmodule::Cc;
 use jrsonnet_interner::IStr;
 use serde::Deserialize;
 use serde_yaml::DeserializingQuirks;
-use std::collections::HashMap;
-use std::convert::{TryFrom, TryInto};
 
+use crate::{
+	builtin::manifest::{manifest_yaml_ex, ManifestYamlOptions},
+	error::{Error::*, Result},
+	function::{CallLocation, StaticBuiltin},
+	operator::evaluate_mod_op,
+	push_frame, throw,
+	typed::{Any, BoundedUsize, Bytes, Either2, Either4, PositiveF64, VecVal, M1},
+	val::{equals, primitive_equals, ArrValue, FuncVal, IndexableVal, Slice},
+	with_state, Either, ObjValue, Val,
+};
+
 pub mod stdlib;
 pub use stdlib::*;
 
@@ -58,12 +60,12 @@
 			}
 
 			Ok(Val::Str(
-			(s.chars()
-				.skip(index)
-				.take(end - index)
-				.step_by(step)
-				.collect::<String>())
-			.into(),
+				(s.chars()
+					.skip(index)
+					.take(end - index)
+					.step_by(step)
+					.collect::<String>())
+				.into(),
 			))
 		}
 		IndexableVal::Arr(arr) => {
modifiedcrates/jrsonnet-evaluator/src/builtin/sort.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/sort.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/sort.rs
@@ -1,10 +1,12 @@
+use gcmodule::{Cc, Trace};
+
 use crate::{
 	error::{Error, LocError, Result},
 	throw,
 	typed::Any,
-	FuncVal, Val,
+	val::FuncVal,
+	Val,
 };
-use gcmodule::{Cc, Trace};
 
 #[derive(Debug, Clone, thiserror::Error, Trace)]
 pub enum SortError {
modifiedcrates/jrsonnet-evaluator/src/builtin/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/stdlib.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/stdlib.rs
@@ -1,6 +1,7 @@
-use jrsonnet_parser::{LocExpr, ParserSettings};
 use std::path::PathBuf;
 
+use jrsonnet_parser::{LocExpr, ParserSettings};
+
 thread_local! {
 	/// To avoid parsing again when issued from the same thread
 	#[allow(unreachable_code)]
modifiedcrates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -1,12 +1,12 @@
-use crate::cc_ptr_eq;
-use crate::gc::GcHashMap;
+use std::fmt::Debug;
+
+use gcmodule::{Cc, Trace};
+use jrsonnet_interner::IStr;
+
 use crate::{
-	error::Error::*, map::LayeredHashMap, FutureWrapper, LazyBinding, LazyVal, ObjValue, Result,
-	Val,
+	cc_ptr_eq, error::Error::*, gc::GcHashMap, map::LayeredHashMap, FutureWrapper, LazyBinding,
+	LazyVal, ObjValue, Result, Val,
 };
-use gcmodule::{Cc, Trace};
-use jrsonnet_interner::IStr;
-use std::fmt::Debug;
 
 #[derive(Clone, Trace)]
 pub struct ContextCreator(pub Context, pub FutureWrapper<GcHashMap<IStr, LazyBinding>>);
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -1,16 +1,18 @@
-use crate::{
-	builtin::{format::FormatError, sort::SortError},
-	typed::TypeLocError,
+use std::{
+	path::{Path, PathBuf},
+	rc::Rc,
 };
+
 use gcmodule::Trace;
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{BinaryOpType, ExprLocation, UnaryOpType};
 use jrsonnet_types::ValType;
-use std::{
-	path::{Path, PathBuf},
-	rc::Rc,
+use thiserror::Error;
+
+use crate::{
+	builtin::{format::FormatError, sort::SortError},
+	typed::TypeLocError,
 };
-use thiserror::Error;
 
 #[derive(Error, Debug, Clone, Trace)]
 pub enum Error {
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -1,15 +1,5 @@
 use std::convert::TryFrom;
 
-use crate::{
-	builtin::{std_slice, BUILTINS},
-	error::Error::*,
-	evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},
-	function::CallLocation,
-	gc::TraceBox,
-	push_frame, throw, with_state, ArrValue, Bindable, Context, ContextCreator, FuncDesc, FuncVal,
-	FutureWrapper, GcHashMap, LazyBinding, LazyVal, LazyValValue, ObjValue, ObjValueBuilder,
-	ObjectAssertion, Result, Val,
-};
 use gcmodule::{Cc, Trace};
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{
@@ -17,6 +7,19 @@
 	LiteralType, LocExpr, Member, ObjBody, ParamsDesc,
 };
 use jrsonnet_types::ValType;
+
+use crate::{
+	builtin::{std_slice, BUILTINS},
+	error::Error::*,
+	evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},
+	function::CallLocation,
+	gc::TraceBox,
+	push_frame, throw,
+	typed::BoundedUsize,
+	val::{ArrValue, FuncDesc, FuncVal, LazyValValue},
+	with_state, Bindable, Context, ContextCreator, FutureWrapper, GcHashMap, LazyBinding, LazyVal,
+	ObjValue, ObjValueBuilder, ObjectAssertion, Result, Val,
+};
 pub mod operator;
 
 pub fn evaluate_binding_in_future(
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/operator.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/operator.rs
@@ -1,10 +1,11 @@
 use std::convert::TryInto;
 
-use crate::builtin::std_format;
-use crate::{equals, evaluate, Context, Val};
-use crate::{error::Error::*, throw, Result};
 use jrsonnet_parser::{BinaryOpType, LocExpr, UnaryOpType};
 
+use crate::{
+	builtin::std_format, error::Error::*, evaluate, throw, val::equals, Context, Result, Val,
+};
+
 pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Result<Val> {
 	use UnaryOpType::*;
 	use Val::*;
modifiedcrates/jrsonnet-evaluator/src/function.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function.rs
+++ b/crates/jrsonnet-evaluator/src/function.rs
@@ -1,16 +1,19 @@
+use std::{borrow::Cow, collections::HashMap, convert::TryFrom};
+
+use gcmodule::Trace;
+use jrsonnet_interner::IStr;
+pub use jrsonnet_macros::builtin;
+use jrsonnet_parser::{ArgsDesc, ExprLocation, LocExpr, ParamsDesc};
+
 use crate::{
 	error::{Error::*, LocError},
 	evaluate, evaluate_named,
 	gc::TraceBox,
 	throw,
 	typed::Typed,
-	Context, FutureWrapper, GcHashMap, LazyVal, LazyValValue, Result, Val,
+	val::LazyValValue,
+	Context, FutureWrapper, GcHashMap, LazyVal, Result, Val,
 };
-use gcmodule::Trace;
-use jrsonnet_interner::IStr;
-pub use jrsonnet_macros::builtin;
-use jrsonnet_parser::{ArgsDesc, ExprLocation, LocExpr, ParamsDesc};
-use std::{borrow::Cow, collections::HashMap, convert::TryFrom};
 
 #[derive(Clone, Copy)]
 pub struct CallLocation<'l>(pub Option<&'l ExprLocation>);
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/import.rs
+++ b/crates/jrsonnet-evaluator/src/import.rs
@@ -1,17 +1,20 @@
-use crate::{
-	error::{Error::*, Result},
-	throw,
-};
-use fs::File;
-use jrsonnet_interner::IStr;
-use std::fs;
 use std::{
 	any::Any,
+	convert::TryFrom,
+	fs,
+	io::Read,
 	path::{Path, PathBuf},
 	rc::Rc,
 };
-use std::{convert::TryFrom, io::Read};
 
+use fs::File;
+use jrsonnet_interner::IStr;
+
+use crate::{
+	error::{Error::*, Result},
+	throw,
+};
+
 /// Implements file resolution logic for `import` and `importStr`
 pub trait ImportResolver {
 	/// Resolves real file path, e.g. `(/home/user/manifests, b.libjsonnet)` can correspond
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -1,9 +1,11 @@
+use std::convert::{TryFrom, TryInto};
+
+use serde_json::{Map, Number, Value};
+
 use crate::{
 	error::{Error::*, LocError, Result},
 	throw, ObjValueBuilder, Val,
 };
-use serde_json::{Map, Number, Value};
-use std::convert::{TryFrom, TryInto};
 
 impl TryFrom<&Val> for Value {
 	type Error = LocError;
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -13,6 +13,7 @@
 pub mod error;
 mod evaluate;
 pub mod function;
+pub mod gc;
 mod import;
 mod integrations;
 mod map;
@@ -20,9 +21,15 @@
 mod obj;
 pub mod trace;
 pub mod typed;
-mod val;
+pub mod val;
 
-pub use jrsonnet_parser as parser;
+use std::{
+	cell::{Ref, RefCell, RefMut},
+	collections::HashMap,
+	fmt::Debug,
+	path::{Path, PathBuf},
+	rc::Rc,
+};
 
 pub use ctx::*;
 pub use dynamic::*;
@@ -33,18 +40,11 @@
 use gcmodule::{Cc, Trace, Weak};
 pub use import::*;
 pub use jrsonnet_interner::IStr;
+pub use jrsonnet_parser as parser;
 use jrsonnet_parser::*;
 pub use obj::*;
-use std::{
-	cell::{Ref, RefCell, RefMut},
-	collections::HashMap,
-	fmt::Debug,
-	path::{Path, PathBuf},
-	rc::Rc,
-};
 use trace::{location_to_offset, offset_to_location, CodeLocation, CompactFormat, TraceFormat};
-pub use val::*;
-pub mod gc;
+pub use val::{LazyVal, ManifestFormat, Val};
 
 pub trait Bindable: Trace + 'static {
 	fn bind(&self, this: Option<ObjValue>, super_obj: Option<ObjValue>) -> Result<LazyVal>;
@@ -693,18 +693,24 @@
 
 #[cfg(test)]
 pub mod tests {
-	use super::Val;
-	use crate::{
-		error::Error::*, function::BuiltinParam, gc::TraceBox, native::NativeCallbackHandler,
-		primitive_equals, EvaluationState,
-	};
-	use gcmodule::{Cc, Trace};
-	use jrsonnet_parser::*;
 	use std::{
 		path::{Path, PathBuf},
 		rc::Rc,
 	};
 
+	use gcmodule::{Cc, Trace};
+	use jrsonnet_parser::*;
+
+	use super::Val;
+	use crate::{
+		error::Error::*,
+		function::{BuiltinParam, CallLocation},
+		gc::TraceBox,
+		native::NativeCallbackHandler,
+		val::primitive_equals,
+		EvaluationState,
+	};
+
 	#[test]
 	#[should_panic]
 	fn eval_state_stacktrace() {
@@ -712,11 +718,15 @@
 		state.run_in_state(|| {
 			state
 				.push(
-					Some(&ExprLocation(PathBuf::from("test1.jsonnet").into(), 10, 20)),
+					CallLocation::new(&ExprLocation(PathBuf::from("test1.jsonnet").into(), 10, 20)),
 					|| "outer".to_owned(),
 					|| {
 						state.push(
-							Some(&ExprLocation(PathBuf::from("test2.jsonnet").into(), 30, 40)),
+							CallLocation::new(&ExprLocation(
+								PathBuf::from("test2.jsonnet").into(),
+								30,
+								40,
+							)),
 							|| "inner".to_owned(),
 							|| Err(RuntimeError("".into()).into()),
 						)?;
@@ -1290,10 +1300,11 @@
 	}
 
 	mod derive_typed {
+		use std::path::PathBuf;
+
 		use crate::{typed::Typed, EvaluationState};
-		use std::path::PathBuf;
 
-		#[derive(Typed, PartialEq, Debug)]
+		#[derive(PartialEq, Debug, Typed)]
 		struct MyTyped {
 			a: u32,
 			#[typed(rename = "b")]
modifiedcrates/jrsonnet-evaluator/src/native.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/native.rs
+++ b/crates/jrsonnet-evaluator/src/native.rs
@@ -1,13 +1,16 @@
 #![allow(clippy::type_complexity)]
 
-use crate::function::{parse_builtin_call, ArgsLike, Builtin, BuiltinParam, CallLocation};
-use crate::gc::TraceBox;
-use crate::Context;
-use crate::{error::Result, Val};
+use std::{path::Path, rc::Rc};
+
 use gcmodule::Trace;
-use std::path::Path;
-use std::rc::Rc;
 
+use crate::{
+	error::Result,
+	function::{parse_builtin_call, ArgsLike, Builtin, BuiltinParam, CallLocation},
+	gc::TraceBox,
+	Context, Val,
+};
+
 #[derive(Trace)]
 pub struct NativeCallback {
 	pub(crate) params: Vec<BuiltinParam>,
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -1,20 +1,23 @@
-use crate::error::LocError;
-use crate::function::CallLocation;
-use crate::gc::{GcHashMap, GcHashSet, TraceBox};
-use crate::operator::evaluate_add_op;
-use crate::push_frame;
-use crate::{
-	cc_ptr_eq, error::Error::*, throw, weak_ptr_eq, weak_raw, Bindable, LazyBinding, LazyVal,
-	Result, Val,
+use std::{
+	cell::RefCell,
+	fmt::Debug,
+	hash::{Hash, Hasher},
 };
+
 use gcmodule::{Cc, Trace, Weak};
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{ExprLocation, Visibility};
 use rustc_hash::FxHashMap;
-use std::cell::RefCell;
-use std::fmt::Debug;
-use std::hash::{Hash, Hasher};
 
+use crate::{
+	cc_ptr_eq,
+	error::{Error::*, LocError},
+	function::CallLocation,
+	gc::{GcHashMap, GcHashSet, TraceBox},
+	operator::evaluate_add_op,
+	push_frame, throw, weak_ptr_eq, weak_raw, Bindable, LazyBinding, LazyVal, Result, Val,
+};
+
 #[derive(Debug, Trace)]
 pub struct ObjMember {
 	pub add: bool,
modifiedcrates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/trace/mod.rs
+++ b/crates/jrsonnet-evaluator/src/trace/mod.rs
@@ -1,8 +1,10 @@
 mod location;
 
+use std::path::{Path, PathBuf};
+
+pub use location::*;
+
 use crate::{error::Error, EvaluationState, LocError};
-pub use location::*;
-use std::path::{Path, PathBuf};
 
 /// The way paths should be displayed
 pub enum PathResolver {
modifiedcrates/jrsonnet-evaluator/src/typed/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/mod.rs
+++ b/crates/jrsonnet-evaluator/src/typed/mod.rs
@@ -2,14 +2,14 @@
 
 mod conversions;
 pub use conversions::*;
+use gcmodule::Trace;
+pub use jrsonnet_types::{ComplexValType, ValType};
+use thiserror::Error;
 
 use crate::{
 	error::{Error, LocError, Result},
 	push_description_frame, Val,
 };
-use gcmodule::Trace;
-pub use jrsonnet_types::{ComplexValType, ValType};
-use thiserror::Error;
 
 #[derive(Debug, Error, Clone, Trace)]
 pub enum TypeError {
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -1,3 +1,10 @@
+use std::{cell::RefCell, fmt::Debug, rc::Rc};
+
+use gcmodule::{Cc, Trace};
+use jrsonnet_interner::IStr;
+use jrsonnet_parser::{LocExpr, ParamsDesc};
+use jrsonnet_types::ValType;
+
 use crate::{
 	builtin::manifest::{
 		manifest_json_ex, manifest_yaml_ex, ManifestJsonOptions, ManifestType, ManifestYamlOptions,
@@ -12,11 +19,6 @@
 	gc::TraceBox,
 	throw, Context, ObjValue, Result,
 };
-use gcmodule::{Cc, Trace};
-use jrsonnet_interner::IStr;
-use jrsonnet_parser::{LocExpr, ParamsDesc};
-use jrsonnet_types::ValType;
-use std::{cell::RefCell, fmt::Debug, rc::Rc};
 
 pub trait LazyValValue: Trace {
 	fn get(self: Box<Self>) -> Result<Val>;
modifiedcrates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-interner/src/lib.rs
+++ b/crates/jrsonnet-interner/src/lib.rs
@@ -1,6 +1,3 @@
-use gcmodule::Trace;
-use rustc_hash::FxHashMap;
-use serde::{Deserialize, Serialize};
 use std::{
 	borrow::Cow,
 	cell::RefCell,
@@ -12,6 +9,10 @@
 	str::Utf8Error,
 };
 
+use gcmodule::Trace;
+use rustc_hash::FxHashMap;
+use serde::{Deserialize, Serialize};
+
 #[derive(Clone, PartialOrd, Ord, Eq)]
 pub struct IStr(Rc<str>);
 impl Trace for IStr {
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -1,7 +1,3 @@
-use gcmodule::Trace;
-use jrsonnet_interner::IStr;
-#[cfg(feature = "serde")]
-use serde::{Deserialize, Serialize};
 use std::{
 	fmt::{Debug, Display},
 	ops::Deref,
@@ -9,6 +5,11 @@
 	rc::Rc,
 };
 
+use gcmodule::Trace;
+use jrsonnet_interner::IStr;
+#[cfg(feature = "serde")]
+use serde::{Deserialize, Serialize};
+
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub enum FieldName {
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/lib.rs
+++ b/crates/jrsonnet-parser/src/lib.rs
@@ -1,10 +1,11 @@
 #![allow(clippy::redundant_closure_call)]
 
-use peg::parser;
 use std::{
 	path::{Path, PathBuf},
 	rc::Rc,
 };
+
+use peg::parser;
 mod expr;
 pub use expr::*;
 pub use jrsonnet_interner::IStr;
@@ -317,11 +318,13 @@
 
 #[cfg(test)]
 pub mod tests {
-	use super::{expr::*, parse};
-	use crate::ParserSettings;
 	use std::path::PathBuf;
+
 	use BinaryOpType::*;
 
+	use super::{expr::*, parse};
+	use crate::ParserSettings;
+
 	macro_rules! parse {
 		($s:expr) => {
 			parse(
modifiedcrates/jrsonnet-types/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-types/src/lib.rs
+++ b/crates/jrsonnet-types/src/lib.rs
@@ -1,8 +1,9 @@
 #![allow(clippy::redundant_closure_call)]
 
-use gcmodule::Trace;
 use std::fmt::Display;
 
+use gcmodule::Trace;
+
 #[macro_export]
 macro_rules! ty {
 	((Array<number>)) => {{