Make new clippy happy (#384)

This commit is contained in:
Ivan Boldyrev 2022-11-23 17:02:28 +03:00 committed by GitHub
parent 78675f930e
commit fb344084a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 43 additions and 70 deletions

View File

@ -96,7 +96,7 @@ pub(crate) fn populate_context_from_data<'i>(
}
/// Writes an executed state of a particle being sent to remote node.
pub(crate) fn handle_remote_call<'i>(peer_pk: String, exec_ctx: &mut ExecutionCtx<'i>, trace_ctx: &mut TraceHandler) {
pub(crate) fn handle_remote_call(peer_pk: String, exec_ctx: &mut ExecutionCtx<'_>, trace_ctx: &mut TraceHandler) {
exec_ctx.next_peer_pks.push(peer_pk);
exec_ctx.subgraph_complete = false;

View File

@ -134,10 +134,7 @@ fn create_canon_stream_from_name(
/// This function gets a stream from context or return a default empty stream,
/// it's crucial for deterministic behaviour, for more info see
/// github.com/fluencelabs/aquavm/issues/346
fn get_stream_or_default<'ctx, 'value>(
ast_canon: &ast::Canon<'_>,
exec_ctx: &'ctx ExecutionCtx<'value>,
) -> Cow<'ctx, Stream> {
fn get_stream_or_default<'ctx>(ast_canon: &ast::Canon<'_>, exec_ctx: &'ctx ExecutionCtx<'_>) -> Cow<'ctx, Stream> {
let maybe_stream = exec_ctx.streams.get(ast_canon.stream.name, ast_canon.stream.position);
maybe_stream.map(Cow::Borrowed).unwrap_or_default()
}

View File

@ -60,11 +60,11 @@ fn fail_with_scalar<'i>(scalar: &ast::ScalarWithLambda<'i>, exec_ctx: &mut Execu
fail_with_error_object(exec_ctx, Rc::new(value), Some(tetraplet))
}
fn fail_with_literals<'i>(
fn fail_with_literals(
error_code: i64,
error_message: &str,
fail: &Fail<'_>,
exec_ctx: &mut ExecutionCtx<'i>,
exec_ctx: &mut ExecutionCtx<'_>,
) -> ExecutionResult<()> {
let error_object = crate::execution_step::execution_context::error_from_raw_fields(
error_code,

View File

@ -86,10 +86,7 @@ pub(crate) fn construct_stream_iterable_values(
.collect::<Vec<_>>()
}
fn create_scalar_iterable<'ctx>(
exec_ctx: &ExecutionCtx<'ctx>,
variable_name: &str,
) -> ExecutionResult<FoldIterableScalar> {
fn create_scalar_iterable(exec_ctx: &ExecutionCtx<'_>, variable_name: &str) -> ExecutionResult<FoldIterableScalar> {
match exec_ctx.scalars.get_value(variable_name)? {
ScalarRef::Value(call_result) => from_value(call_result.clone(), variable_name),
ScalarRef::IterableValue(fold_state) => {
@ -127,8 +124,8 @@ fn from_value(call_result: ValueAggregate, variable_name: &str) -> ExecutionResu
Ok(iterable)
}
fn create_scalar_lambda_iterable<'ctx>(
exec_ctx: &ExecutionCtx<'ctx>,
fn create_scalar_lambda_iterable(
exec_ctx: &ExecutionCtx<'_>,
scalar_name: &str,
lambda: &LambdaAST<'_>,
) -> ExecutionResult<FoldIterableScalar> {

View File

@ -38,14 +38,13 @@ use std::borrow::Cow;
/// Represent a value that could be transform to a JValue with or without tetraplets.
pub(crate) trait JValuable {
/// Applies lambda to the internal value, produces JValue.
fn apply_lambda<'i>(&self, lambda: &LambdaAST<'_>, exec_ctx: &ExecutionCtx<'i>)
-> ExecutionResult<Cow<'_, JValue>>;
fn apply_lambda(&self, lambda: &LambdaAST<'_>, exec_ctx: &ExecutionCtx<'_>) -> ExecutionResult<Cow<'_, JValue>>;
/// Applies lambda to the internal value, produces JValue with tetraplet.
fn apply_lambda_with_tetraplets<'i>(
fn apply_lambda_with_tetraplets(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<(Cow<'_, JValue>, SecurityTetraplet)>;
/// Return internal value as borrowed if it's possible, owned otherwise.

View File

@ -29,21 +29,17 @@ use std::borrow::Cow;
use std::ops::Deref;
impl JValuable for &CanonStream {
fn apply_lambda<'i>(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
) -> ExecutionResult<Cow<'_, JValue>> {
fn apply_lambda(&self, lambda: &LambdaAST<'_>, exec_ctx: &ExecutionCtx<'_>) -> ExecutionResult<Cow<'_, JValue>> {
let iter = self.iter().map(|v| v.result.deref());
let select_result = select_by_lambda_from_stream(iter, lambda, exec_ctx)?;
Ok(select_result.result)
}
fn apply_lambda_with_tetraplets<'i>(
fn apply_lambda_with_tetraplets(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<(Cow<'_, JValue>, SecurityTetraplet)> {
let iter = self.iter().map(|v| v.result.deref());
let select_result = select_by_lambda_from_stream(iter, lambda, exec_ctx)?;

View File

@ -29,20 +29,16 @@ use std::borrow::Cow;
use std::ops::Deref;
impl JValuable for std::cell::Ref<'_, Vec<ValueAggregate>> {
fn apply_lambda<'i>(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
) -> ExecutionResult<Cow<'_, JValue>> {
fn apply_lambda(&self, lambda: &LambdaAST<'_>, exec_ctx: &ExecutionCtx<'_>) -> ExecutionResult<Cow<'_, JValue>> {
let stream_iter = self.iter().map(|r| r.result.deref());
let select_result = select_by_lambda_from_stream(stream_iter, lambda, exec_ctx)?;
Ok(select_result.result)
}
fn apply_lambda_with_tetraplets<'i>(
fn apply_lambda_with_tetraplets(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<(Cow<'_, JValue>, SecurityTetraplet)> {
let stream_iter = self.iter().map(|r| r.result.deref());
let select_result = select_by_lambda_from_stream(stream_iter, lambda, exec_ctx)?;

View File

@ -27,19 +27,15 @@ use crate::SecurityTetraplet;
use std::borrow::Cow;
impl JValuable for () {
fn apply_lambda<'i>(
&self,
_lambda: &LambdaAST<'_>,
_exec_ctx: &ExecutionCtx<'i>,
) -> ExecutionResult<Cow<'_, JValue>> {
fn apply_lambda(&self, _lambda: &LambdaAST<'_>, _exec_ctx: &ExecutionCtx<'_>) -> ExecutionResult<Cow<'_, JValue>> {
// applying lambda to an empty stream will produce a join behaviour
Err(LambdaApplierError(EmptyStream).into())
}
fn apply_lambda_with_tetraplets<'i>(
fn apply_lambda_with_tetraplets(
&self,
_lambda: &LambdaAST<'_>,
_exec_ctx: &ExecutionCtx<'i>,
_exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<(Cow<'_, JValue>, SecurityTetraplet)> {
// applying lambda to an empty stream will produce a join behaviour
Err(LambdaApplierError(EmptyStream).into())

View File

@ -29,11 +29,7 @@ use std::borrow::Cow;
use std::ops::Deref;
impl<'ctx> JValuable for IterableItem<'ctx> {
fn apply_lambda<'i>(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
) -> ExecutionResult<Cow<'_, JValue>> {
fn apply_lambda(&self, lambda: &LambdaAST<'_>, exec_ctx: &ExecutionCtx<'_>) -> ExecutionResult<Cow<'_, JValue>> {
use super::IterableItem::*;
let jvalue = match self {
@ -46,10 +42,10 @@ impl<'ctx> JValuable for IterableItem<'ctx> {
Ok(selected_value)
}
fn apply_lambda_with_tetraplets<'i>(
fn apply_lambda_with_tetraplets(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<(Cow<'_, JValue>, SecurityTetraplet)> {
use super::IterableItem::*;

View File

@ -29,19 +29,15 @@ use std::borrow::Cow;
use std::ops::Deref;
impl JValuable for ValueAggregate {
fn apply_lambda<'i>(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
) -> ExecutionResult<Cow<'_, JValue>> {
fn apply_lambda(&self, lambda: &LambdaAST<'_>, exec_ctx: &ExecutionCtx<'_>) -> ExecutionResult<Cow<'_, JValue>> {
let selected_value = select_by_lambda_from_scalar(&self.result, lambda, exec_ctx)?;
Ok(selected_value)
}
fn apply_lambda_with_tetraplets<'i>(
fn apply_lambda_with_tetraplets(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<(Cow<'_, JValue>, SecurityTetraplet)> {
let selected_value = select_by_lambda_from_scalar(&self.result, lambda, exec_ctx)?;
let tetraplet = populate_tetraplet_with_lambda(self.tetraplet.as_ref().clone(), lambda);

View File

@ -38,21 +38,17 @@ pub(crate) struct StreamJvaluableIngredients<'stream> {
// TODO: this will be deleted soon, because it would be impossible to use streams without
// canonicalization as an arg of a call
impl JValuable for StreamJvaluableIngredients<'_> {
fn apply_lambda<'i>(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
) -> ExecutionResult<Cow<'_, JValue>> {
fn apply_lambda(&self, lambda: &LambdaAST<'_>, exec_ctx: &ExecutionCtx<'_>) -> ExecutionResult<Cow<'_, JValue>> {
let iter = self.iter()?.map(|v| v.result.deref());
let select_result = select_by_lambda_from_stream(iter, lambda, exec_ctx)?;
Ok(select_result.result)
}
fn apply_lambda_with_tetraplets<'i>(
fn apply_lambda_with_tetraplets(
&self,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<(Cow<'_, JValue>, SecurityTetraplet)> {
let iter = self.iter()?.map(|v| v.result.deref());
let select_result = select_by_lambda_from_stream(iter, lambda, exec_ctx)?;

View File

@ -36,10 +36,10 @@ pub(crate) struct StreamSelectResult<'value> {
pub(crate) tetraplet_idx: Option<usize>,
}
pub(crate) fn select_by_lambda_from_stream<'value, 'i>(
pub(crate) fn select_by_lambda_from_stream<'value>(
stream: impl ExactSizeIterator<Item = &'value JValue> + 'value,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<StreamSelectResult<'value>> {
match lambda {
LambdaAST::ValuePath(value_path) => select_by_path_from_stream(stream, value_path, exec_ctx),
@ -47,10 +47,10 @@ pub(crate) fn select_by_lambda_from_stream<'value, 'i>(
}
}
pub(crate) fn select_by_lambda_from_scalar<'value, 'i>(
pub(crate) fn select_by_lambda_from_scalar<'value>(
value: &'value JValue,
lambda: &LambdaAST<'_>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<Cow<'value, JValue>> {
match lambda {
LambdaAST::ValuePath(value_path) => select_by_path_from_scalar(value, value_path.iter(), exec_ctx),
@ -58,10 +58,10 @@ pub(crate) fn select_by_lambda_from_scalar<'value, 'i>(
}
}
fn select_by_path_from_stream<'value, 'i>(
fn select_by_path_from_stream<'value>(
stream: impl ExactSizeIterator<Item = &'value JValue> + 'value,
lambda: &NonEmpty<ValueAccessor<'_>>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<StreamSelectResult<'value>> {
let (prefix, body) = lambda.split_first();
let idx = match prefix {
@ -89,7 +89,7 @@ fn select_by_path_from_stream<'value, 'i>(
Ok(select_result)
}
fn select_by_functor_from_stream<'value, 'i>(
fn select_by_functor_from_stream<'value>(
stream: impl ExactSizeIterator<Item = &'value JValue> + 'value,
functor: &Functor,
) -> StreamSelectResult<'value> {
@ -101,10 +101,10 @@ fn select_by_functor_from_stream<'value, 'i>(
}
}
fn select_by_path_from_scalar<'value, 'accessor, 'i>(
fn select_by_path_from_scalar<'value, 'accessor>(
mut value: &'value JValue,
lambda: impl Iterator<Item = &'accessor ValueAccessor<'accessor>>,
exec_ctx: &ExecutionCtx<'i>,
exec_ctx: &ExecutionCtx<'_>,
) -> ExecutionResult<Cow<'value, JValue>> {
for accessor in lambda {
match accessor {

View File

@ -53,9 +53,9 @@ pub(super) fn try_jvalue_with_field_name<'value>(
}
}
pub(super) fn select_by_scalar<'value, 'i>(
pub(super) fn select_by_scalar<'value>(
value: &'value JValue,
scalar_ref: ScalarRef<'i>,
scalar_ref: ScalarRef<'_>,
) -> LambdaResult<&'value JValue> {
use ScalarRef::*;

View File

@ -58,6 +58,7 @@ pub struct AVM<E> {
impl<E> AVM<E> {
/// Create AVM with provided config.
#[allow(clippy::result_large_err)]
pub fn new(config: AVMConfig<E>) -> AVMResult<Self, E> {
let AVMConfig {
air_wasm_path,
@ -77,6 +78,7 @@ impl<E> AVM<E> {
Ok(avm)
}
#[allow(clippy::result_large_err)]
pub fn call(
&mut self,
air: impl Into<String>,
@ -126,6 +128,7 @@ impl<E> AVM<E> {
}
/// Cleanup data that become obsolete.
#[allow(clippy::result_large_err)]
pub fn cleanup_data(&mut self, particle_id: &str) -> AVMResult<(), E> {
self.data_store.cleanup_data(particle_id)?;
Ok(())
@ -136,6 +139,7 @@ impl<E> AVM<E> {
self.runner.memory_stats()
}
#[allow(clippy::result_large_err)]
fn save_anomaly_data(
&mut self,
air_script: &str,