difftreelog
fix clippy warnings
in: master
5 files changed
crates/jrsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate.rs
@@ -147,8 +147,8 @@
Ok(match (a, op, b) {
(a, BinaryOpType::Add, b) => evaluate_add_op(a, b)?,
- (a, BinaryOpType::Eq, b) => Val::Bool(equals(&a, &b)?),
- (a, BinaryOpType::Neq, b) => Val::Bool(!equals(&a, &b)?),
+ (a, BinaryOpType::Eq, b) => Val::Bool(equals(a, b)?),
+ (a, BinaryOpType::Neq, b) => Val::Bool(!equals(a, b)?),
(Val::Str(v1), BinaryOpType::Mul, Val::Num(v2)) => Val::Str(v1.repeat(*v2 as usize).into()),
@@ -578,7 +578,7 @@
}
Intrinsic(name) => Val::Func(Rc::new(FuncVal::Intrinsic(name.clone()))),
AssertExpr(assert, returned) => {
- evaluate_assert(context.clone(), &assert)?;
+ evaluate_assert(context.clone(), assert)?;
evaluate(context, returned)?
}
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.rsdiffbeforeafterbothno syntactic changes
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)?)
}
}
}