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
--- a/bindings/jsonnet/src/import.rs
+++ b/bindings/jsonnet/src/import.rs
@@ -1,9 +1,5 @@
 //! Import resolution manipulation utilities
 
-use jrsonnet_evaluator::{
-	error::{Error::*, Result},
-	throw, EvaluationState, ImportResolver,
-};
 use std::{
 	any::Any,
 	cell::RefCell,
@@ -17,6 +13,11 @@
 	rc::Rc,
 };
 
+use jrsonnet_evaluator::{
+	error::{Error::*, Result},
+	throw, EvaluationState, ImportResolver,
+};
+
 pub type JsonnetImportCallback = unsafe extern "C" fn(
 	ctx: *mut c_void,
 	base: *const c_char,
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
before · crates/jrsonnet-parser/src/expr.rs
1use gcmodule::Trace;2use jrsonnet_interner::IStr;3#[cfg(feature = "serde")]4use serde::{Deserialize, Serialize};5use std::{6	fmt::{Debug, Display},7	ops::Deref,8	path::{Path, PathBuf},9	rc::Rc,10};1112#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]13#[derive(Debug, PartialEq, Trace)]14pub enum FieldName {15	/// {fixed: 2}16	Fixed(IStr),17	/// {["dyn"+"amic"]: 3}18	Dyn(LocExpr),19}2021#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]22#[derive(Debug, Clone, Copy, PartialEq, Trace)]23pub enum Visibility {24	/// :25	Normal,26	/// ::27	Hidden,28	/// :::29	Unhide,30}3132impl Visibility {33	pub fn is_visible(&self) -> bool {34		matches!(self, Self::Normal | Self::Unhide)35	}36}3738#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]39#[derive(Clone, Debug, PartialEq, Trace)]40pub struct AssertStmt(pub LocExpr, pub Option<LocExpr>);4142#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]43#[derive(Debug, PartialEq, Trace)]44pub struct FieldMember {45	pub name: FieldName,46	pub plus: bool,47	pub params: Option<ParamsDesc>,48	pub visibility: Visibility,49	pub value: LocExpr,50}5152#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]53#[derive(Debug, PartialEq, Trace)]54pub enum Member {55	Field(FieldMember),56	BindStmt(BindSpec),57	AssertStmt(AssertStmt),58}5960#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]61#[derive(Debug, Clone, Copy, PartialEq, Trace)]62pub enum UnaryOpType {63	Plus,64	Minus,65	BitNot,66	Not,67}6869impl Display for UnaryOpType {70	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {71		use UnaryOpType::*;72		write!(73			f,74			"{}",75			match self {76				Plus => "+",77				Minus => "-",78				BitNot => "~",79				Not => "!",80			}81		)82	}83}8485#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]86#[derive(Debug, Clone, Copy, PartialEq, Trace)]87pub enum BinaryOpType {88	Mul,89	Div,9091	/// Implemented as intrinsic, put here for completeness92	Mod,9394	Add,95	Sub,9697	Lhs,98	Rhs,99100	Lt,101	Gt,102	Lte,103	Gte,104105	BitAnd,106	BitOr,107	BitXor,108109	Eq,110	Neq,111112	And,113	Or,114115	// Equialent to std.objectHasEx(a, b, true)116	In,117}118119impl Display for BinaryOpType {120	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {121		use BinaryOpType::*;122		write!(123			f,124			"{}",125			match self {126				Mul => "*",127				Div => "/",128				Mod => "%",129				Add => "+",130				Sub => "-",131				Lhs => "<<",132				Rhs => ">>",133				Lt => "<",134				Gt => ">",135				Lte => "<=",136				Gte => ">=",137				BitAnd => "&",138				BitOr => "|",139				BitXor => "^",140				Eq => "==",141				Neq => "!=",142				And => "&&",143				Or => "||",144				In => "in",145			}146		)147	}148}149150/// name, default value151#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]152#[derive(Debug, PartialEq, Trace)]153pub struct Param(pub IStr, pub Option<LocExpr>);154155/// Defined function parameters156#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]157#[derive(Debug, Clone, PartialEq, Trace)]158pub struct ParamsDesc(pub Rc<Vec<Param>>);159160impl Deref for ParamsDesc {161	type Target = Vec<Param>;162	fn deref(&self) -> &Self::Target {163		&self.0164	}165}166167#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]168#[derive(Debug, PartialEq, Trace)]169pub struct ArgsDesc {170	pub unnamed: Vec<LocExpr>,171	pub named: Vec<(IStr, LocExpr)>,172}173impl ArgsDesc {174	pub fn new(unnamed: Vec<LocExpr>, named: Vec<(IStr, LocExpr)>) -> Self {175		Self { unnamed, named }176	}177}178179#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]180#[derive(Debug, Clone, PartialEq, Trace)]181pub struct BindSpec {182	pub name: IStr,183	pub params: Option<ParamsDesc>,184	pub value: LocExpr,185}186187#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]188#[derive(Debug, PartialEq, Trace)]189pub struct IfSpecData(pub LocExpr);190191#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]192#[derive(Debug, PartialEq, Trace)]193pub struct ForSpecData(pub IStr, pub LocExpr);194195#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]196#[derive(Debug, PartialEq, Trace)]197pub enum CompSpec {198	IfSpec(IfSpecData),199	ForSpec(ForSpecData),200}201202#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]203#[derive(Debug, PartialEq, Trace)]204pub struct ObjComp {205	pub pre_locals: Vec<BindSpec>,206	pub key: LocExpr,207	pub plus: bool,208	pub value: LocExpr,209	pub post_locals: Vec<BindSpec>,210	pub compspecs: Vec<CompSpec>,211}212213#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]214#[derive(Debug, PartialEq, Trace)]215pub enum ObjBody {216	MemberList(Vec<Member>),217	ObjComp(ObjComp),218}219220#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]221#[derive(Debug, PartialEq, Clone, Copy, Trace)]222pub enum LiteralType {223	This,224	Super,225	Dollar,226	Null,227	True,228	False,229}230231#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]232#[derive(Debug, PartialEq, Trace)]233pub struct SliceDesc {234	pub start: Option<LocExpr>,235	pub end: Option<LocExpr>,236	pub step: Option<LocExpr>,237}238239/// Syntax base240#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]241#[derive(Debug, PartialEq, Trace)]242pub enum Expr {243	Literal(LiteralType),244245	/// String value: "hello"246	Str(IStr),247	/// Number: 1, 2.0, 2e+20248	Num(f64),249	/// Variable name: test250	Var(IStr),251252	/// Array of expressions: [1, 2, "Hello"]253	Arr(Vec<LocExpr>),254	/// Array comprehension:255	/// ```jsonnet256	///  ingredients: [257	///    { kind: kind, qty: 4 / 3 }258	///    for kind in [259	///      'Honey Syrup',260	///      'Lemon Juice',261	///      'Farmers Gin',262	///    ]263	///  ],264	/// ```265	ArrComp(LocExpr, Vec<CompSpec>),266267	/// Object: {a: 2}268	Obj(ObjBody),269	/// Object extension: var1 {b: 2}270	ObjExtend(LocExpr, ObjBody),271272	/// (obj)273	Parened(LocExpr),274275	/// -2276	UnaryOp(UnaryOpType, LocExpr),277	/// 2 - 2278	BinaryOp(LocExpr, BinaryOpType, LocExpr),279	/// assert 2 == 2 : "Math is broken"280	AssertExpr(AssertStmt, LocExpr),281	/// local a = 2; { b: a }282	LocalExpr(Vec<BindSpec>, LocExpr),283284	/// import "hello"285	Import(PathBuf),286	/// importStr "file.txt"287	ImportStr(PathBuf),288	/// importBin "file.txt"289	ImportBin(PathBuf),290	/// error "I'm broken"291	ErrorStmt(LocExpr),292	/// a(b, c)293	Apply(LocExpr, ArgsDesc, bool),294	/// a[b]295	Index(LocExpr, LocExpr),296	/// function(x) x297	Function(ParamsDesc, LocExpr),298	/// std.primitiveEquals299	Intrinsic(IStr),300	/// if true == false then 1 else 2301	IfElse {302		cond: IfSpecData,303		cond_then: LocExpr,304		cond_else: Option<LocExpr>,305	},306	Slice(LocExpr, SliceDesc),307}308309/// file, begin offset, end offset310#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]311#[derive(Clone, PartialEq, Trace)]312#[skip_trace]313pub struct ExprLocation(pub Rc<Path>, pub usize, pub usize);314impl ExprLocation {315	pub fn belongs_to(&self, other: &ExprLocation) -> bool {316		other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2317	}318}319320impl Debug for ExprLocation {321	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {322		write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)323	}324}325326/// Holds AST expression and its location in source file327#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]328#[derive(Clone, PartialEq, Trace)]329pub struct LocExpr(pub Rc<Expr>, pub ExprLocation);330331impl Debug for LocExpr {332	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {333		if f.alternate() {334			write!(f, "{:#?}", self.0)?;335		} else {336			write!(f, "{:?}", self.0)?;337		}338		write!(f, " from {:?}", self.1)?;339		Ok(())340	}341}
after · crates/jrsonnet-parser/src/expr.rs
1use std::{2	fmt::{Debug, Display},3	ops::Deref,4	path::{Path, PathBuf},5	rc::Rc,6};78use gcmodule::Trace;9use jrsonnet_interner::IStr;10#[cfg(feature = "serde")]11use serde::{Deserialize, Serialize};1213#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]14#[derive(Debug, PartialEq, Trace)]15pub enum FieldName {16	/// {fixed: 2}17	Fixed(IStr),18	/// {["dyn"+"amic"]: 3}19	Dyn(LocExpr),20}2122#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]23#[derive(Debug, Clone, Copy, PartialEq, Trace)]24pub enum Visibility {25	/// :26	Normal,27	/// ::28	Hidden,29	/// :::30	Unhide,31}3233impl Visibility {34	pub fn is_visible(&self) -> bool {35		matches!(self, Self::Normal | Self::Unhide)36	}37}3839#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]40#[derive(Clone, Debug, PartialEq, Trace)]41pub struct AssertStmt(pub LocExpr, pub Option<LocExpr>);4243#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]44#[derive(Debug, PartialEq, Trace)]45pub struct FieldMember {46	pub name: FieldName,47	pub plus: bool,48	pub params: Option<ParamsDesc>,49	pub visibility: Visibility,50	pub value: LocExpr,51}5253#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]54#[derive(Debug, PartialEq, Trace)]55pub enum Member {56	Field(FieldMember),57	BindStmt(BindSpec),58	AssertStmt(AssertStmt),59}6061#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]62#[derive(Debug, Clone, Copy, PartialEq, Trace)]63pub enum UnaryOpType {64	Plus,65	Minus,66	BitNot,67	Not,68}6970impl Display for UnaryOpType {71	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {72		use UnaryOpType::*;73		write!(74			f,75			"{}",76			match self {77				Plus => "+",78				Minus => "-",79				BitNot => "~",80				Not => "!",81			}82		)83	}84}8586#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]87#[derive(Debug, Clone, Copy, PartialEq, Trace)]88pub enum BinaryOpType {89	Mul,90	Div,9192	/// Implemented as intrinsic, put here for completeness93	Mod,9495	Add,96	Sub,9798	Lhs,99	Rhs,100101	Lt,102	Gt,103	Lte,104	Gte,105106	BitAnd,107	BitOr,108	BitXor,109110	Eq,111	Neq,112113	And,114	Or,115116	// Equialent to std.objectHasEx(a, b, true)117	In,118}119120impl Display for BinaryOpType {121	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {122		use BinaryOpType::*;123		write!(124			f,125			"{}",126			match self {127				Mul => "*",128				Div => "/",129				Mod => "%",130				Add => "+",131				Sub => "-",132				Lhs => "<<",133				Rhs => ">>",134				Lt => "<",135				Gt => ">",136				Lte => "<=",137				Gte => ">=",138				BitAnd => "&",139				BitOr => "|",140				BitXor => "^",141				Eq => "==",142				Neq => "!=",143				And => "&&",144				Or => "||",145				In => "in",146			}147		)148	}149}150151/// name, default value152#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]153#[derive(Debug, PartialEq, Trace)]154pub struct Param(pub IStr, pub Option<LocExpr>);155156/// Defined function parameters157#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]158#[derive(Debug, Clone, PartialEq, Trace)]159pub struct ParamsDesc(pub Rc<Vec<Param>>);160161impl Deref for ParamsDesc {162	type Target = Vec<Param>;163	fn deref(&self) -> &Self::Target {164		&self.0165	}166}167168#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]169#[derive(Debug, PartialEq, Trace)]170pub struct ArgsDesc {171	pub unnamed: Vec<LocExpr>,172	pub named: Vec<(IStr, LocExpr)>,173}174impl ArgsDesc {175	pub fn new(unnamed: Vec<LocExpr>, named: Vec<(IStr, LocExpr)>) -> Self {176		Self { unnamed, named }177	}178}179180#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]181#[derive(Debug, Clone, PartialEq, Trace)]182pub struct BindSpec {183	pub name: IStr,184	pub params: Option<ParamsDesc>,185	pub value: LocExpr,186}187188#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]189#[derive(Debug, PartialEq, Trace)]190pub struct IfSpecData(pub LocExpr);191192#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]193#[derive(Debug, PartialEq, Trace)]194pub struct ForSpecData(pub IStr, pub LocExpr);195196#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]197#[derive(Debug, PartialEq, Trace)]198pub enum CompSpec {199	IfSpec(IfSpecData),200	ForSpec(ForSpecData),201}202203#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]204#[derive(Debug, PartialEq, Trace)]205pub struct ObjComp {206	pub pre_locals: Vec<BindSpec>,207	pub key: LocExpr,208	pub plus: bool,209	pub value: LocExpr,210	pub post_locals: Vec<BindSpec>,211	pub compspecs: Vec<CompSpec>,212}213214#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]215#[derive(Debug, PartialEq, Trace)]216pub enum ObjBody {217	MemberList(Vec<Member>),218	ObjComp(ObjComp),219}220221#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]222#[derive(Debug, PartialEq, Clone, Copy, Trace)]223pub enum LiteralType {224	This,225	Super,226	Dollar,227	Null,228	True,229	False,230}231232#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]233#[derive(Debug, PartialEq, Trace)]234pub struct SliceDesc {235	pub start: Option<LocExpr>,236	pub end: Option<LocExpr>,237	pub step: Option<LocExpr>,238}239240/// Syntax base241#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]242#[derive(Debug, PartialEq, Trace)]243pub enum Expr {244	Literal(LiteralType),245246	/// String value: "hello"247	Str(IStr),248	/// Number: 1, 2.0, 2e+20249	Num(f64),250	/// Variable name: test251	Var(IStr),252253	/// Array of expressions: [1, 2, "Hello"]254	Arr(Vec<LocExpr>),255	/// Array comprehension:256	/// ```jsonnet257	///  ingredients: [258	///    { kind: kind, qty: 4 / 3 }259	///    for kind in [260	///      'Honey Syrup',261	///      'Lemon Juice',262	///      'Farmers Gin',263	///    ]264	///  ],265	/// ```266	ArrComp(LocExpr, Vec<CompSpec>),267268	/// Object: {a: 2}269	Obj(ObjBody),270	/// Object extension: var1 {b: 2}271	ObjExtend(LocExpr, ObjBody),272273	/// (obj)274	Parened(LocExpr),275276	/// -2277	UnaryOp(UnaryOpType, LocExpr),278	/// 2 - 2279	BinaryOp(LocExpr, BinaryOpType, LocExpr),280	/// assert 2 == 2 : "Math is broken"281	AssertExpr(AssertStmt, LocExpr),282	/// local a = 2; { b: a }283	LocalExpr(Vec<BindSpec>, LocExpr),284285	/// import "hello"286	Import(PathBuf),287	/// importStr "file.txt"288	ImportStr(PathBuf),289	/// importBin "file.txt"290	ImportBin(PathBuf),291	/// error "I'm broken"292	ErrorStmt(LocExpr),293	/// a(b, c)294	Apply(LocExpr, ArgsDesc, bool),295	/// a[b]296	Index(LocExpr, LocExpr),297	/// function(x) x298	Function(ParamsDesc, LocExpr),299	/// std.primitiveEquals300	Intrinsic(IStr),301	/// if true == false then 1 else 2302	IfElse {303		cond: IfSpecData,304		cond_then: LocExpr,305		cond_else: Option<LocExpr>,306	},307	Slice(LocExpr, SliceDesc),308}309310/// file, begin offset, end offset311#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]312#[derive(Clone, PartialEq, Trace)]313#[skip_trace]314pub struct ExprLocation(pub Rc<Path>, pub usize, pub usize);315impl ExprLocation {316	pub fn belongs_to(&self, other: &ExprLocation) -> bool {317		other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2318	}319}320321impl Debug for ExprLocation {322	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {323		write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)324	}325}326327/// Holds AST expression and its location in source file328#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]329#[derive(Clone, PartialEq, Trace)]330pub struct LocExpr(pub Rc<Expr>, pub ExprLocation);331332impl Debug for LocExpr {333	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {334		if f.alternate() {335			write!(f, "{:#?}", self.0)?;336		} else {337			write!(f, "{:?}", self.0)?;338		}339		write!(f, " from {:?}", self.1)?;340		Ok(())341	}342}
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>)) => {{