chore: cargo clippy

This commit is contained in:
2025-05-22 19:22:38 +08:00
parent c898b577b0
commit 6bb86ca2cf
3 changed files with 8 additions and 8 deletions

View File

@@ -24,7 +24,7 @@ fn main() -> Result<()> {
let expr = root.tree().expr().unwrap();
let downgraded = downgrade(expr)?;
let prog = compile(downgraded);
println!("{:?}", prog);
println!("{prog:?}");
Ok(())
}

View File

@@ -13,7 +13,7 @@ pub struct Env<K: Hash + Eq + Clone, V: Clone> {
#[derive(Clone)]
pub struct LetEnv<K: Hash + Eq + Clone, V: Clone> {
map: Let<K, V>,
map: LetNode<K, V>,
last: Option<Rc<LetEnv<K, V>>>,
}
@@ -44,7 +44,7 @@ pub struct With<K: Hash + Eq, V> {
}
#[derive(Debug, Clone)]
enum Let<K: Hash + Eq, V> {
enum LetNode<K: Hash + Eq, V> {
Let(Rc<HashMap<K, V>>),
SingleArg(K, V),
MultiArg(Rc<HashMap<K, V>>),
@@ -100,13 +100,13 @@ impl<K: Hash + Eq + Clone, V: Clone> Env<K, V> {
impl<K: Hash + Eq + Clone, V: Clone> LetEnv<K, V> {
pub fn new(map: Rc<HashMap<K, V>>) -> Self {
Self {
map: Let::Let(map),
map: LetNode::Let(map),
last: None,
}
}
pub fn lookup(&self, symbol: &K) -> Option<&V> {
use self::Let::*;
use self::LetNode::*;
match &self.map {
Let(map) | MultiArg(map) => {
if let Some(val) = map.get(symbol) {
@@ -126,14 +126,14 @@ impl<K: Hash + Eq + Clone, V: Clone> LetEnv<K, V> {
let cloned = self.clone();
let mutref = Rc::make_mut(self);
mutref.last = Some(cloned);
mutref.map = Let::SingleArg(ident, val);
mutref.map = LetNode::SingleArg(ident, val);
}
pub fn enter_let(self: &mut Rc<Self>, map: Rc<HashMap<K, V>>) {
let cloned = self.clone();
let mutref = Rc::make_mut(self);
mutref.last = Some(cloned);
mutref.map = Let::Let(map);
mutref.map = LetNode::Let(map);
}
pub fn leave(self: &mut Rc<Self>) {

View File

@@ -190,7 +190,7 @@ impl<'vm, 'jit: 'vm> VM<'jit> {
}
OpCode::FinalizeRec => {
env.enter_let(stack.tos()?.clone().unwrap_attr_set().into_inner());
stack.tos_mut()?.as_mut().unwrap_attr_set().capture(&env);
stack.tos_mut()?.as_mut().unwrap_attr_set().capture(env);
}
OpCode::PushStaticAttr { name } => {
let val = stack.pop();