Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jul 16, 2024
1 parent 426b648 commit 8f0000c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 4 additions & 7 deletions crates/turbo-tasks/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ mod ser {
},
Borrowed {
fn_type: FunctionId,
arg: &'a Box<dyn MagicAny>,
arg: &'a dyn MagicAny,
},
}

Expand All @@ -129,7 +129,7 @@ mod ser {
};
let mut state = serializer.serialize_seq(Some(2))?;
state.serialize_element(&fn_type)?;
let arg = &***arg;
let arg = *arg;
let arg = registry::get_function(*fn_type).arg_meta.as_serialize(arg);
state.serialize_element(arg)?;
state.end()
Expand Down Expand Up @@ -159,10 +159,7 @@ mod ser {
let arg = seq
.next_element_seed(seed)?
.ok_or_else(|| serde::de::Error::invalid_length(1, &self))?;
Ok(FunctionAndArg::Owned {
fn_type,
arg: arg.into(),
})
Ok(FunctionAndArg::Owned { fn_type, arg })
}
}
deserializer.deserialize_seq(Visitor)
Expand Down Expand Up @@ -190,7 +187,7 @@ mod ser {
s.serialize_element::<u8>(&1)?;
s.serialize_element(&FunctionAndArg::Borrowed {
fn_type: *fn_type,
arg: arg,
arg,
})?;
s.serialize_element(this)?;
s.end()
Expand Down
16 changes: 10 additions & 6 deletions crates/turbo-tasks/src/native_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ use crate::{
RawVc, TaskInput,
};

type ResolveFunctor =
for<'a> fn(
&'a dyn MagicAny,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn MagicAny>>> + Send + 'a>>;

type IsResolvedFunctor = fn(&dyn MagicAny) -> bool;

pub struct ArgMeta {
serializer: MagicAnySerializeSeed,
deserializer: MagicAnyDeserializeSeed,
is_resolved: fn(&dyn MagicAny) -> bool,
resolve: for<'a> fn(
&'a dyn MagicAny,
)
-> Pin<Box<dyn Future<Output = Result<Box<dyn MagicAny>>> + Send + 'a>>,
is_resolved: IsResolvedFunctor,
resolve: ResolveFunctor,
}

impl ArgMeta {
Expand Down Expand Up @@ -142,7 +146,7 @@ impl NativeFunction {
pub fn execute(&'static self, this: Option<RawVc>, arg: &dyn MagicAny) -> NativeTaskFuture {
match (self.implementation).functor(this, arg) {
Ok(functor) => functor,
Err(err) => Box::pin(async { Err(err.into()) }),
Err(err) => Box::pin(async { Err(err) }),
}
}

Expand Down

0 comments on commit 8f0000c

Please sign in to comment.