difftreelog
style enforce import style
in: master
38 files changed
.rustfmt.tomldiffbeforeafterboth--- a/.rustfmt.toml
+++ b/.rustfmt.toml
@@ -1 +1,3 @@
hard_tabs = true
+imports_granularity = "crate"
+group_imports = "stdexternalcrate"
bindings/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,
bindings/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,
bindings/jsonnet/src/lib.rsdiffbeforeafterboth1#[cfg(feature = "interop")]2pub mod interop;34pub mod import;5pub mod native;6pub mod val_extract;7pub mod val_make;8pub mod val_modify;9pub mod vars_tlas;1011use import::NativeImportResolver;12use jrsonnet_evaluator::{EvaluationState, IStr, ManifestFormat, Val};13use std::{14 alloc::Layout,15 ffi::{CStr, CString},16 os::raw::{c_char, c_double, c_int, c_uint},17 path::PathBuf,18};1920/// WASM stub21#[cfg(target_arch = "wasm32")]22#[no_mangle]23pub extern "C" fn _start() {}2425#[no_mangle]26pub extern "C" fn jsonnet_version() -> &'static [u8; 8] {27 b"v0.16.0\0"28}2930#[no_mangle]31pub extern "C" fn jsonnet_make() -> *mut EvaluationState {32 let state = EvaluationState::default();33 state.with_stdlib();34 state.settings_mut().import_resolver = Box::new(NativeImportResolver::default());35 Box::into_raw(Box::new(state))36}3738/// # Safety39#[no_mangle]40#[allow(clippy::boxed_local)]41pub unsafe extern "C" fn jsonnet_destroy(vm: *mut EvaluationState) {42 Box::from_raw(vm);43}4445#[no_mangle]46pub extern "C" fn jsonnet_max_stack(vm: &EvaluationState, v: c_uint) {47 vm.settings_mut().max_stack = v as usize;48}4950// jrsonnet currently have no GC, so these functions is no-op51#[no_mangle]52pub extern "C" fn jsonnet_gc_min_objects(_vm: &EvaluationState, _v: c_uint) {}53#[no_mangle]54pub extern "C" fn jsonnet_gc_growth_trigger(_vm: &EvaluationState, _v: c_double) {}5556#[no_mangle]57pub extern "C" fn jsonnet_string_output(vm: &EvaluationState, v: c_int) {58 match v {59 1 => vm.set_manifest_format(ManifestFormat::String),60 0 => vm.set_manifest_format(ManifestFormat::Json(4)),61 _ => panic!("incorrect output format"),62 }63}6465/// # Safety66///67/// This function is most definitely broken, but it works somehow, see TODO inside68#[no_mangle]69pub unsafe extern "C" fn jsonnet_realloc(70 _vm: &EvaluationState,71 buf: *mut u8,72 sz: usize,73) -> *mut u8 {74 if buf.is_null() {75 assert!(sz != 0);76 return std::alloc::alloc(Layout::from_size_align(sz, std::mem::align_of::<u8>()).unwrap());77 }78 // TODO: Somehow store size of allocation, because its real size is probally not 16 :D79 // OR (Alternative way of fixing this TODO)80 // TODO: Standard allocator uses malloc, and it doesn't uses allocation size,81 // TODO: so it should work in normal cases. Maybe force allocator for this library?82 let old_layout = Layout::from_size_align(16, std::mem::align_of::<u8>()).unwrap();83 if sz == 0 {84 std::alloc::dealloc(buf, old_layout);85 return std::ptr::null_mut();86 }87 std::alloc::realloc(buf, old_layout, sz)88}8990/// # Safety91#[no_mangle]92#[allow(clippy::boxed_local)]93pub unsafe extern "C" fn jsonnet_json_destroy(_vm: &EvaluationState, v: *mut Val) {94 Box::from_raw(v);95}9697#[no_mangle]98pub extern "C" fn jsonnet_max_trace(vm: &EvaluationState, v: c_uint) {99 vm.set_max_trace(v as usize)100}101102/// # Safety103///104/// This function is safe, if received v is a pointer to normal C string105#[no_mangle]106pub unsafe extern "C" fn jsonnet_evaluate_file(107 vm: &EvaluationState,108 filename: *const c_char,109 error: &mut c_int,110) -> *const c_char {111 vm.run_in_state(|| {112 let filename = CStr::from_ptr(filename);113 match vm114 .evaluate_file_raw_nocwd(&PathBuf::from(filename.to_str().unwrap()))115 .and_then(|v| vm.with_tla(v))116 .and_then(|v| vm.manifest(v))117 {118 Ok(v) => {119 *error = 0;120 CString::new(&*v as &str).unwrap().into_raw()121 }122 Err(e) => {123 *error = 1;124 let out = vm.stringify_err(&e);125 CString::new(&out as &str).unwrap().into_raw()126 }127 }128 })129}130131/// # Safety132///133/// This function is safe, if received v is a pointer to normal C string134#[no_mangle]135pub unsafe extern "C" fn jsonnet_evaluate_snippet(136 vm: &EvaluationState,137 filename: *const c_char,138 snippet: *const c_char,139 error: &mut c_int,140) -> *const c_char {141 vm.run_in_state(|| {142 let filename = CStr::from_ptr(filename);143 let snippet = CStr::from_ptr(snippet);144 match vm145 .evaluate_snippet_raw(146 PathBuf::from(filename.to_str().unwrap()).into(),147 snippet.to_str().unwrap().into(),148 )149 .and_then(|v| vm.with_tla(v))150 .and_then(|v| vm.manifest(v))151 {152 Ok(v) => {153 *error = 0;154 CString::new(&*v as &str).unwrap().into_raw()155 }156 Err(e) => {157 *error = 1;158 let out = vm.stringify_err(&e);159 CString::new(&out as &str).unwrap().into_raw()160 }161 }162 })163}164165fn multi_to_raw(multi: Vec<(IStr, IStr)>) -> *const c_char {166 let mut out = Vec::new();167 for (i, (k, v)) in multi.iter().enumerate() {168 if i != 0 {169 out.push(0);170 }171 out.extend_from_slice(k.as_bytes());172 out.push(0);173 out.extend_from_slice(v.as_bytes());174 }175 out.push(0);176 out.push(0);177 let v = out.as_ptr();178 std::mem::forget(out);179 v as *const c_char180}181182/// # Safety183#[no_mangle]184pub unsafe extern "C" fn jsonnet_evaluate_file_multi(185 vm: &EvaluationState,186 filename: *const c_char,187 error: &mut c_int,188) -> *const c_char {189 vm.run_in_state(|| {190 let filename = CStr::from_ptr(filename);191 match vm192 .evaluate_file_raw_nocwd(&PathBuf::from(filename.to_str().unwrap()))193 .and_then(|v| vm.with_tla(v))194 .and_then(|v| vm.manifest_multi(v))195 {196 Ok(v) => {197 *error = 0;198 multi_to_raw(v)199 }200 Err(e) => {201 *error = 1;202 let out = vm.stringify_err(&e);203 CString::new(&out as &str).unwrap().into_raw()204 }205 }206 })207}208209/// # Safety210#[no_mangle]211pub unsafe extern "C" fn jsonnet_evaluate_snippet_multi(212 vm: &EvaluationState,213 filename: *const c_char,214 snippet: *const c_char,215 error: &mut c_int,216) -> *const c_char {217 vm.run_in_state(|| {218 let filename = CStr::from_ptr(filename);219 let snippet = CStr::from_ptr(snippet);220 match vm221 .evaluate_snippet_raw(222 PathBuf::from(filename.to_str().unwrap()).into(),223 snippet.to_str().unwrap().into(),224 )225 .and_then(|v| vm.with_tla(v))226 .and_then(|v| vm.manifest_multi(v))227 {228 Ok(v) => {229 *error = 0;230 multi_to_raw(v)231 }232 Err(e) => {233 *error = 1;234 let out = vm.stringify_err(&e);235 CString::new(&out as &str).unwrap().into_raw()236 }237 }238 })239}240241fn stream_to_raw(multi: Vec<IStr>) -> *const c_char {242 let mut out = Vec::new();243 for (i, v) in multi.iter().enumerate() {244 if i != 0 {245 out.push(0);246 }247 out.extend_from_slice(v.as_bytes());248 }249 out.push(0);250 out.push(0);251 let v = out.as_ptr();252 std::mem::forget(out);253 v as *const c_char254}255256/// # Safety257#[no_mangle]258pub unsafe extern "C" fn jsonnet_evaluate_file_stream(259 vm: &EvaluationState,260 filename: *const c_char,261 error: &mut c_int,262) -> *const c_char {263 vm.run_in_state(|| {264 let filename = CStr::from_ptr(filename);265 match vm266 .evaluate_file_raw_nocwd(&PathBuf::from(filename.to_str().unwrap()))267 .and_then(|v| vm.with_tla(v))268 .and_then(|v| vm.manifest_stream(v))269 {270 Ok(v) => {271 *error = 0;272 stream_to_raw(v)273 }274 Err(e) => {275 *error = 1;276 let out = vm.stringify_err(&e);277 CString::new(&out as &str).unwrap().into_raw()278 }279 }280 })281}282283/// # Safety284#[no_mangle]285pub unsafe extern "C" fn jsonnet_evaluate_snippet_stream(286 vm: &EvaluationState,287 filename: *const c_char,288 snippet: *const c_char,289 error: &mut c_int,290) -> *const c_char {291 vm.run_in_state(|| {292 let filename = CStr::from_ptr(filename);293 let snippet = CStr::from_ptr(snippet);294 match vm295 .evaluate_snippet_raw(296 PathBuf::from(filename.to_str().unwrap()).into(),297 snippet.to_str().unwrap().into(),298 )299 .and_then(|v| vm.with_tla(v))300 .and_then(|v| vm.manifest_stream(v))301 {302 Ok(v) => {303 *error = 0;304 stream_to_raw(v)305 }306 Err(e) => {307 *error = 1;308 let out = vm.stringify_err(&e);309 CString::new(&out as &str).unwrap().into_raw()310 }311 }312 })313}1#[cfg(feature = "interop")]2pub mod interop;34pub mod import;5pub mod native;6pub mod val_extract;7pub mod val_make;8pub mod val_modify;9pub mod vars_tlas;1011use std::{12 alloc::Layout,13 ffi::{CStr, CString},14 os::raw::{c_char, c_double, c_int, c_uint},15 path::PathBuf,16};1718use import::NativeImportResolver;19use jrsonnet_evaluator::{EvaluationState, IStr, ManifestFormat, Val};2021/// WASM stub22#[cfg(target_arch = "wasm32")]23#[no_mangle]24pub extern "C" fn _start() {}2526#[no_mangle]27pub extern "C" fn jsonnet_version() -> &'static [u8; 8] {28 b"v0.16.0\0"29}3031#[no_mangle]32pub extern "C" fn jsonnet_make() -> *mut EvaluationState {33 let state = EvaluationState::default();34 state.with_stdlib();35 state.settings_mut().import_resolver = Box::new(NativeImportResolver::default());36 Box::into_raw(Box::new(state))37}3839/// # Safety40#[no_mangle]41#[allow(clippy::boxed_local)]42pub unsafe extern "C" fn jsonnet_destroy(vm: *mut EvaluationState) {43 Box::from_raw(vm);44}4546#[no_mangle]47pub extern "C" fn jsonnet_max_stack(vm: &EvaluationState, v: c_uint) {48 vm.settings_mut().max_stack = v as usize;49}5051// jrsonnet currently have no GC, so these functions is no-op52#[no_mangle]53pub extern "C" fn jsonnet_gc_min_objects(_vm: &EvaluationState, _v: c_uint) {}54#[no_mangle]55pub extern "C" fn jsonnet_gc_growth_trigger(_vm: &EvaluationState, _v: c_double) {}5657#[no_mangle]58pub extern "C" fn jsonnet_string_output(vm: &EvaluationState, v: c_int) {59 match v {60 1 => vm.set_manifest_format(ManifestFormat::String),61 0 => vm.set_manifest_format(ManifestFormat::Json(4)),62 _ => panic!("incorrect output format"),63 }64}6566/// # Safety67///68/// This function is most definitely broken, but it works somehow, see TODO inside69#[no_mangle]70pub unsafe extern "C" fn jsonnet_realloc(71 _vm: &EvaluationState,72 buf: *mut u8,73 sz: usize,74) -> *mut u8 {75 if buf.is_null() {76 assert!(sz != 0);77 return std::alloc::alloc(Layout::from_size_align(sz, std::mem::align_of::<u8>()).unwrap());78 }79 // TODO: Somehow store size of allocation, because its real size is probally not 16 :D80 // OR (Alternative way of fixing this TODO)81 // TODO: Standard allocator uses malloc, and it doesn't uses allocation size,82 // TODO: so it should work in normal cases. Maybe force allocator for this library?83 let old_layout = Layout::from_size_align(16, std::mem::align_of::<u8>()).unwrap();84 if sz == 0 {85 std::alloc::dealloc(buf, old_layout);86 return std::ptr::null_mut();87 }88 std::alloc::realloc(buf, old_layout, sz)89}9091/// # Safety92#[no_mangle]93#[allow(clippy::boxed_local)]94pub unsafe extern "C" fn jsonnet_json_destroy(_vm: &EvaluationState, v: *mut Val) {95 Box::from_raw(v);96}9798#[no_mangle]99pub extern "C" fn jsonnet_max_trace(vm: &EvaluationState, v: c_uint) {100 vm.set_max_trace(v as usize)101}102103/// # Safety104///105/// This function is safe, if received v is a pointer to normal C string106#[no_mangle]107pub unsafe extern "C" fn jsonnet_evaluate_file(108 vm: &EvaluationState,109 filename: *const c_char,110 error: &mut c_int,111) -> *const c_char {112 vm.run_in_state(|| {113 let filename = CStr::from_ptr(filename);114 match vm115 .evaluate_file_raw_nocwd(&PathBuf::from(filename.to_str().unwrap()))116 .and_then(|v| vm.with_tla(v))117 .and_then(|v| vm.manifest(v))118 {119 Ok(v) => {120 *error = 0;121 CString::new(&*v as &str).unwrap().into_raw()122 }123 Err(e) => {124 *error = 1;125 let out = vm.stringify_err(&e);126 CString::new(&out as &str).unwrap().into_raw()127 }128 }129 })130}131132/// # Safety133///134/// This function is safe, if received v is a pointer to normal C string135#[no_mangle]136pub unsafe extern "C" fn jsonnet_evaluate_snippet(137 vm: &EvaluationState,138 filename: *const c_char,139 snippet: *const c_char,140 error: &mut c_int,141) -> *const c_char {142 vm.run_in_state(|| {143 let filename = CStr::from_ptr(filename);144 let snippet = CStr::from_ptr(snippet);145 match vm146 .evaluate_snippet_raw(147 PathBuf::from(filename.to_str().unwrap()).into(),148 snippet.to_str().unwrap().into(),149 )150 .and_then(|v| vm.with_tla(v))151 .and_then(|v| vm.manifest(v))152 {153 Ok(v) => {154 *error = 0;155 CString::new(&*v as &str).unwrap().into_raw()156 }157 Err(e) => {158 *error = 1;159 let out = vm.stringify_err(&e);160 CString::new(&out as &str).unwrap().into_raw()161 }162 }163 })164}165166fn multi_to_raw(multi: Vec<(IStr, IStr)>) -> *const c_char {167 let mut out = Vec::new();168 for (i, (k, v)) in multi.iter().enumerate() {169 if i != 0 {170 out.push(0);171 }172 out.extend_from_slice(k.as_bytes());173 out.push(0);174 out.extend_from_slice(v.as_bytes());175 }176 out.push(0);177 out.push(0);178 let v = out.as_ptr();179 std::mem::forget(out);180 v as *const c_char181}182183/// # Safety184#[no_mangle]185pub unsafe extern "C" fn jsonnet_evaluate_file_multi(186 vm: &EvaluationState,187 filename: *const c_char,188 error: &mut c_int,189) -> *const c_char {190 vm.run_in_state(|| {191 let filename = CStr::from_ptr(filename);192 match vm193 .evaluate_file_raw_nocwd(&PathBuf::from(filename.to_str().unwrap()))194 .and_then(|v| vm.with_tla(v))195 .and_then(|v| vm.manifest_multi(v))196 {197 Ok(v) => {198 *error = 0;199 multi_to_raw(v)200 }201 Err(e) => {202 *error = 1;203 let out = vm.stringify_err(&e);204 CString::new(&out as &str).unwrap().into_raw()205 }206 }207 })208}209210/// # Safety211#[no_mangle]212pub unsafe extern "C" fn jsonnet_evaluate_snippet_multi(213 vm: &EvaluationState,214 filename: *const c_char,215 snippet: *const c_char,216 error: &mut c_int,217) -> *const c_char {218 vm.run_in_state(|| {219 let filename = CStr::from_ptr(filename);220 let snippet = CStr::from_ptr(snippet);221 match vm222 .evaluate_snippet_raw(223 PathBuf::from(filename.to_str().unwrap()).into(),224 snippet.to_str().unwrap().into(),225 )226 .and_then(|v| vm.with_tla(v))227 .and_then(|v| vm.manifest_multi(v))228 {229 Ok(v) => {230 *error = 0;231 multi_to_raw(v)232 }233 Err(e) => {234 *error = 1;235 let out = vm.stringify_err(&e);236 CString::new(&out as &str).unwrap().into_raw()237 }238 }239 })240}241242fn stream_to_raw(multi: Vec<IStr>) -> *const c_char {243 let mut out = Vec::new();244 for (i, v) in multi.iter().enumerate() {245 if i != 0 {246 out.push(0);247 }248 out.extend_from_slice(v.as_bytes());249 }250 out.push(0);251 out.push(0);252 let v = out.as_ptr();253 std::mem::forget(out);254 v as *const c_char255}256257/// # Safety258#[no_mangle]259pub unsafe extern "C" fn jsonnet_evaluate_file_stream(260 vm: &EvaluationState,261 filename: *const c_char,262 error: &mut c_int,263) -> *const c_char {264 vm.run_in_state(|| {265 let filename = CStr::from_ptr(filename);266 match vm267 .evaluate_file_raw_nocwd(&PathBuf::from(filename.to_str().unwrap()))268 .and_then(|v| vm.with_tla(v))269 .and_then(|v| vm.manifest_stream(v))270 {271 Ok(v) => {272 *error = 0;273 stream_to_raw(v)274 }275 Err(e) => {276 *error = 1;277 let out = vm.stringify_err(&e);278 CString::new(&out as &str).unwrap().into_raw()279 }280 }281 })282}283284/// # Safety285#[no_mangle]286pub unsafe extern "C" fn jsonnet_evaluate_snippet_stream(287 vm: &EvaluationState,288 filename: *const c_char,289 snippet: *const c_char,290 error: &mut c_int,291) -> *const c_char {292 vm.run_in_state(|| {293 let filename = CStr::from_ptr(filename);294 let snippet = CStr::from_ptr(snippet);295 match vm296 .evaluate_snippet_raw(297 PathBuf::from(filename.to_str().unwrap()).into(),298 snippet.to_str().unwrap().into(),299 )300 .and_then(|v| vm.with_tla(v))301 .and_then(|v| vm.manifest_stream(v))302 {303 Ok(v) => {304 *error = 0;305 stream_to_raw(v)306 }307 Err(e) => {308 *error = 1;309 let out = vm.stringify_err(&e);310 CString::new(&out as &str).unwrap().into_raw()311 }312 }313 })314}bindings/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(
bindings/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 {
bindings/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
bindings/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
///
bindings/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(
cmds/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]
crates/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,
crates/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<()>;
crates/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,
crates/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 {
crates/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,
crates/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,
crates/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")]
crates/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 {
crates/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) => {
crates/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 {
crates/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)]
crates/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>>);
crates/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 {
crates/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(
crates/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::*;
crates/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>);
crates/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
crates/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;
crates/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")]
crates/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>,
crates/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,
crates/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 {
crates/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 {
crates/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>;
crates/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 {
crates/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 {
crates/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(
crates/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>)) => {{