chore: cargo clippy

This commit is contained in:
2025-05-20 18:39:09 +08:00
parent 736402dc53
commit 9b3c3d6fe9
10 changed files with 25 additions and 30 deletions

View File

@@ -53,17 +53,14 @@ impl<'jit: 'vm, 'vm> AttrSet<'jit, 'vm> {
}
pub fn capture(&mut self, env: &Rc<LetEnv<'jit, 'vm>>) {
self.data.iter().for_each(|(_, v)| match v.clone() {
Value::Thunk(ref thunk) => {
thunk.capture(env.clone());
}
_ => (),
self.data.iter().for_each(|(_, v)| if let Value::Thunk(ref thunk) = v.clone() {
thunk.capture(env.clone());
})
}
pub fn update(&mut self, other: &AttrSet<'jit, 'vm>) {
for (k, v) in other.data.iter() {
self.push_attr_force(k.clone(), v.clone())
self.push_attr_force(*k, v.clone())
}
}
@@ -79,7 +76,7 @@ impl<'jit: 'vm, 'vm> AttrSet<'jit, 'vm> {
let mut map: Vec<_> = self
.data
.iter()
.map(|(k, v)| (k.clone(), v.clone()))
.map(|(k, v)| (*k, v.clone()))
.collect();
for (_, v) in map.iter_mut() {
v.force_deep(vm)?;

View File

@@ -56,7 +56,7 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
use Param::*;
let env = match self.func.param.clone() {
Ident(ident) => self.env.clone().enter_arg(ident.into(), arg),
Ident(ident) => self.env.clone().enter_arg(ident, arg),
Formals {
formals,
ellipsis,
@@ -75,7 +75,6 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
todo!()
}
for (formal, default) in formals {
let formal = formal.clone().into();
let arg = arg
.select(formal)
.or_else(|| {
@@ -85,12 +84,11 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
new.insert(formal, arg);
}
if let Some(alias) = alias {
new.insert(alias.clone().into(), Value::AttrSet(arg));
new.insert(alias, Value::AttrSet(arg));
}
self.env.clone().enter_attrs(AttrSet::new(new).into())
}
}
.into();
};
let count = self.count.get();
self.count.replace(count + 1);

View File

@@ -459,7 +459,7 @@ impl<'jit, 'vm> Value<'jit, 'vm> {
AttrSet(attrs) => attrs.to_public(vm, seen),
List(list) => list.to_public(vm, seen),
Catchable(catchable) => Value::Catchable(catchable.clone()),
Const(cnst) => Value::Const(cnst.clone().into()),
Const(cnst) => Value::Const(cnst.clone()),
Thunk(_) => Value::Thunk,
ThunkRef(_) => Value::Thunk,
PrimOp(primop) => Value::PrimOp(primop.name),
@@ -514,7 +514,7 @@ impl<'jit, 'vm> Thunk<'jit, 'vm> {
let value = vm.eval(opcodes.iter().copied(), env.get().unwrap().clone())?;
let _ = std::mem::replace(
&mut *self.thunk.borrow_mut(),
_Thunk::Value(value.clone().into()),
_Thunk::Value(value.clone()),
);
Ok(value)
}

View File

@@ -69,7 +69,7 @@ impl<'jit: 'vm, 'vm> PartialPrimOp<'jit, 'vm> {
if self_mut.arity > 0 {
Value::PartialPrimOp(self_clone).ok()
} else if self_mut.arity == 0 {
let args = std::mem::replace(&mut self_mut.args, Vec::new());
let args = std::mem::take(&mut self_mut.args);
(self.func)(vm, args)
} else {
unimplemented!()