difftreelog
fix clippy warnings
in: master
5 files changed
crates/jrsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth147 Ok(match (a, op, b) {147 Ok(match (a, op, b) {148 (a, BinaryOpType::Add, b) => evaluate_add_op(a, b)?,148 (a, BinaryOpType::Add, b) => evaluate_add_op(a, b)?,149149150 (a, BinaryOpType::Eq, b) => Val::Bool(equals(&a, &b)?),150 (a, BinaryOpType::Eq, b) => Val::Bool(equals(a, b)?),151 (a, BinaryOpType::Neq, b) => Val::Bool(!equals(&a, &b)?),151 (a, BinaryOpType::Neq, b) => Val::Bool(!equals(a, b)?),152152153 (Val::Str(v1), BinaryOpType::Mul, Val::Num(v2)) => Val::Str(v1.repeat(*v2 as usize).into()),153 (Val::Str(v1), BinaryOpType::Mul, Val::Num(v2)) => Val::Str(v1.repeat(*v2 as usize).into()),154154578 }578 }579 Intrinsic(name) => Val::Func(Rc::new(FuncVal::Intrinsic(name.clone()))),579 Intrinsic(name) => Val::Func(Rc::new(FuncVal::Intrinsic(name.clone()))),580 AssertExpr(assert, returned) => {580 AssertExpr(assert, returned) => {581 evaluate_assert(context.clone(), &assert)?;581 evaluate_assert(context.clone(), assert)?;582 evaluate(context, returned)?582 evaluate(context, returned)?583 }583 }584 ErrorStmt(e) => push(584 ErrorStmt(e) => push(crates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -1,7 +1,6 @@
use crate::{
- Context,
error::{Error::*, LocError, Result},
- throw, LazyBinding, LazyVal, ObjMember, ObjValue, Val,
+ throw, Context, LazyBinding, LazyVal, ObjMember, ObjValue, Val,
};
use jrsonnet_parser::Visibility;
use rustc_hash::FxHasher;
@@ -77,7 +76,12 @@
},
);
}
- Self::Obj(ObjValue::new(Context::new(), None, Rc::new(entries), Rc::new(Vec::new())))
+ Self::Obj(ObjValue::new(
+ Context::new(),
+ None,
+ Rc::new(entries),
+ Rc::new(Vec::new()),
+ ))
}
}
}
crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -1,6 +1,9 @@
#![cfg_attr(feature = "unstable", feature(stmt_expr_attributes))]
#![warn(clippy::all, clippy::nursery)]
-#![allow(macro_expanded_macro_exports_accessed_by_absolute_paths, clippy::ptr_arg)]
+#![allow(
+ macro_expanded_macro_exports_accessed_by_absolute_paths,
+ clippy::ptr_arg
+)]
mod builtin;
mod ctx;
@@ -390,7 +393,7 @@
loc_data: true,
},
)
- .map_err(|e| ImportSyntaxError {
+ .map_err(|e| ImportSyntaxError {
path: source.clone(),
source_code: code.clone(),
error: Box::new(e),
@@ -998,9 +1001,10 @@
let state = EvaluationState::default();
state.with_stdlib();
- let error = state.evaluate_snippet_raw(
- Rc::new(PathBuf::from("issue40.jsonnet")),
- r#"
+ let error = state
+ .evaluate_snippet_raw(
+ Rc::new(PathBuf::from("issue40.jsonnet")),
+ r#"
local conf = {
n: ""
};
@@ -1010,8 +1014,10 @@
};
std.manifestJsonEx(result, "")
- "#.into(),
- ).unwrap_err();
+ "#
+ .into(),
+ )
+ .unwrap_err();
assert_eq!(error.error().to_string(), "assert failed: is number");
}
}
crates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -1,6 +1,6 @@
-use crate::{Context, evaluate_add_op, evaluate_assert, LazyBinding, Result, Val};
+use crate::{evaluate_add_op, evaluate_assert, Context, LazyBinding, Result, Val};
use jrsonnet_interner::IStr;
-use jrsonnet_parser::{ExprLocation, LocExpr, Visibility, AssertStmt};
+use jrsonnet_parser::{AssertStmt, ExprLocation, Visibility};
use rustc_hash::{FxHashMap, FxHashSet};
use std::hash::{Hash, Hasher};
use std::{cell::RefCell, fmt::Debug, hash::BuildHasherDefault, rc::Rc};
@@ -54,7 +54,12 @@
}
impl ObjValue {
- pub fn new(context: Context, super_obj: Option<Self>, this_entries: Rc<FxHashMap<IStr, ObjMember>>, assertions: Rc<Vec<AssertStmt>>) -> Self {
+ pub fn new(
+ context: Context,
+ super_obj: Option<Self>,
+ this_entries: Rc<FxHashMap<IStr, ObjMember>>,
+ assertions: Rc<Vec<AssertStmt>>,
+ ) -> Self {
Self(Rc::new(ObjValueInternals {
context,
super_obj,
@@ -66,12 +71,27 @@
}))
}
pub fn new_empty() -> Self {
- Self::new(Context::new(), None, Rc::new(FxHashMap::default()), Rc::new(Vec::new()))
+ Self::new(
+ Context::new(),
+ None,
+ Rc::new(FxHashMap::default()),
+ Rc::new(Vec::new()),
+ )
}
pub fn extend_from(&self, super_obj: Self) -> Self {
match &self.0.super_obj {
- None => Self::new(self.0.context.clone(), Some(super_obj), self.0.this_entries.clone(), self.0.assertions.clone()),
- Some(v) => Self::new(self.0.context.clone(), Some(v.extend_from(super_obj)), self.0.this_entries.clone(), self.0.assertions.clone()),
+ None => Self::new(
+ self.0.context.clone(),
+ Some(super_obj),
+ self.0.this_entries.clone(),
+ self.0.assertions.clone(),
+ ),
+ Some(v) => Self::new(
+ self.0.context.clone(),
+ Some(v.extend_from(super_obj)),
+ self.0.this_entries.clone(),
+ self.0.assertions.clone(),
+ ),
}
}
pub fn with_this(&self, this_obj: Self) -> Self {
@@ -176,17 +196,22 @@
}
pub fn get(&self, key: IStr) -> Result<Option<Val>> {
- self.run_assertions(self.0.this_obj.as_ref().unwrap_or(self))?;
+ self.run_assertions()?;
self.get_raw(key, self.0.this_obj.as_ref())
}
pub fn extend_with_field(self, key: IStr, value: ObjMember) -> Self {
let mut new = FxHashMap::with_capacity_and_hasher(1, BuildHasherDefault::default());
new.insert(key, value);
- Self::new(Context::new(), Some(self), Rc::new(new), Rc::new(Vec::new()))
+ Self::new(
+ Context::new(),
+ Some(self),
+ Rc::new(new),
+ Rc::new(Vec::new()),
+ )
}
- pub fn get_raw(&self, key: IStr, real_this: Option<&Self>) -> Result<Option<Val>> {
+ fn get_raw(&self, key: IStr, real_this: Option<&Self>) -> Result<Option<Val>> {
let real_this = real_this.unwrap_or(self);
let cache_key = (key.clone(), real_this.clone());
crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -124,7 +124,7 @@
for p in handler.params.0.iter() {
out_args.push(args.binding(p.0.clone())?.evaluate()?);
}
- Ok(handler.call(loc.clone().map(|l| l.0.clone()), &out_args)?)
+ Ok(handler.call(loc.map(|l| l.0.clone()), &out_args)?)
}
}
}