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

difftreelog

style fix all clippy warnings

Лач2020-07-17parent: #190d87f.patch.diff
in: master

3 files changed

modified.gitignorediffbeforeafterboth
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,5 @@
 .vscode
 
 cache
+
+jsonnet-cpp
modifiedbindings/jsonnet/src/lib.rsdiffbeforeafterboth
65}65}
6666
67#[no_mangle]67#[no_mangle]
68pub extern "C" fn jsonnet_make() -> Box<EvaluationState> {68pub extern "C" fn jsonnet_make() -> *mut EvaluationState {
69 let state = EvaluationState::default();69 let state = EvaluationState::default();
70 state.with_stdlib();70 state.with_stdlib();
71 state.settings_mut().import_resolver = Box::new(NativeImportResolver::default());71 state.settings_mut().import_resolver = Box::new(NativeImportResolver::default());
72 Box::new(state)72 Box::into_raw(Box::new(state))
73}73}
74
75/// # Safety
76#[no_mangle]
77#[allow(clippy::boxed_local)]
78pub unsafe extern "C" fn jsonnet_destroy(vm: *mut EvaluationState) {
79 Box::from_raw(vm);
80}
7481
75#[no_mangle]82#[no_mangle]
76pub extern "C" fn jsonnet_max_stack(vm: &EvaluationState, v: c_uint) {83pub extern "C" fn jsonnet_max_stack(vm: &EvaluationState, v: c_uint) {
133pub unsafe extern "C" fn jsonnet_json_make_string(140pub unsafe extern "C" fn jsonnet_json_make_string(
134 _vm: &EvaluationState,141 _vm: &EvaluationState,
135 v: *const c_char,142 v: *const c_char,
136) -> Box<Val> {143) -> *mut Val {
137 let cstr = CStr::from_ptr(v);144 let cstr = CStr::from_ptr(v);
138 let str = cstr.to_str().unwrap();145 let str = cstr.to_str().unwrap();
139 Box::new(Val::Str(str.into()))146 Box::into_raw(Box::new(Val::Str(str.into())))
140}147}
141148
142#[no_mangle]149#[no_mangle]
143pub extern "C" fn jsonnet_json_make_number(_vm: &EvaluationState, v: c_double) -> Box<Val> {150pub extern "C" fn jsonnet_json_make_number(_vm: &EvaluationState, v: c_double) -> *mut Val {
144 Box::new(Val::Num(v))151 Box::into_raw(Box::new(Val::Num(v)))
145}152}
146153
147#[no_mangle]154#[no_mangle]
148pub extern "C" fn jsonnet_json_make_bool(_vm: &EvaluationState, v: c_int) -> Box<Val> {155pub extern "C" fn jsonnet_json_make_bool(_vm: &EvaluationState, v: c_int) -> *mut Val {
149 assert!(v == 0 || v == 1);156 assert!(v == 0 || v == 1);
150 Box::new(Val::Bool(v == 1))157 Box::into_raw(Box::new(Val::Bool(v == 1)))
151}158}
152159
153#[no_mangle]160#[no_mangle]
154pub extern "C" fn jsonnet_json_make_null(_vm: &EvaluationState) -> Box<Val> {161pub extern "C" fn jsonnet_json_make_null(_vm: &EvaluationState) -> *mut Val {
155 Box::new(Val::Null)162 Box::into_raw(Box::new(Val::Null))
156}163}
157164
158#[no_mangle]165#[no_mangle]
159pub extern "C" fn jsonnet_json_make_array(_vm: &EvaluationState) -> Box<Val> {166pub extern "C" fn jsonnet_json_make_array(_vm: &EvaluationState) -> *mut Val {
160 Box::new(Val::Arr(Rc::new(Vec::new())))167 Box::into_raw(Box::new(Val::Arr(Rc::new(Vec::new()))))
161}168}
162169
163#[no_mangle]170#[no_mangle]
175}182}
176183
177#[no_mangle]184#[no_mangle]
178pub extern "C" fn jsonnet_json_make_object(_vm: &EvaluationState) -> Box<Val> {185pub extern "C" fn jsonnet_json_make_object(_vm: &EvaluationState) -> *mut Val {
179 Box::new(Val::Obj(ObjValue::new_empty()))186 Box::into_raw(Box::new(Val::Obj(ObjValue::new_empty())))
180}187}
181188
182/// # Safety189/// # Safety
233 std::alloc::realloc(buf, old_layout, sz)240 std::alloc::realloc(buf, old_layout, sz)
234}241}
235242
243/// # Safety
236#[no_mangle]244#[no_mangle]
237#[allow(clippy::boxed_local)]245#[allow(clippy::boxed_local)]
238pub extern "C" fn jsonnet_json_destroy(_vm: &EvaluationState, _v: Box<Val>) {}246pub unsafe extern "C" fn jsonnet_json_destroy(_vm: &EvaluationState, v: *mut Val) {
247 Box::from_raw(v);
248}
239249
363 todo!()373 todo!()
364}374}
365
366#[no_mangle]
367#[allow(clippy::boxed_local)]
368pub extern "C" fn jsonnet_destroy(_vm: Box<EvaluationState>) {}
369375
modifiedcrates/jrsonnet-trace/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-trace/src/lib.rs
+++ b/crates/jrsonnet-trace/src/lib.rs
@@ -1,7 +1,4 @@
-use jrsonnet_evaluator::{
-	trace::{offset_to_location, CodeLocation},
-	EvaluationState, LocError,
-};
+use jrsonnet_evaluator::{trace::CodeLocation, EvaluationState, LocError};
 use std::path::PathBuf;
 
 /// How paths should be displayed