make clippy happy (#291)

This commit is contained in:
Mike Voronov
2022-08-10 12:27:06 +03:00
committed by GitHub
parent e884210d35
commit 0d9390d333
13 changed files with 31 additions and 26 deletions

View File

@ -68,6 +68,7 @@ impl AVMRunner {
Ok(avm) Ok(avm)
} }
#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
pub fn call( pub fn call(
&mut self, &mut self,
@ -106,6 +107,7 @@ impl AVMRunner {
Ok(outcome) Ok(outcome)
} }
#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
pub fn call_tracing( pub fn call_tracing(
&mut self, &mut self,
@ -170,6 +172,7 @@ impl AVMRunner {
} }
} }
#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip(air, prev_data, data, call_results))] #[tracing::instrument(skip(air, prev_data, data, call_results))]
fn prepare_args( fn prepare_args(
air: impl Into<String>, air: impl Into<String>,

View File

@ -25,7 +25,7 @@ use air_lambda_ast::LambdaAST;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum CallInstrValue<'i> { pub enum CallInstrValue<'i> {
InitPeerId, InitPeerId,
Literal(&'i str), Literal(&'i str),
@ -34,7 +34,7 @@ pub enum CallInstrValue<'i> {
/// Triplet represents a location of the executable code in the network. /// Triplet represents a location of the executable code in the network.
/// It is build from `PeerPart` and `FunctionPart` of a `Call` instruction. /// It is build from `PeerPart` and `FunctionPart` of a `Call` instruction.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Triplet<'i> { pub struct Triplet<'i> {
#[serde(borrow)] #[serde(borrow)]
pub peer_pk: CallInstrValue<'i>, pub peer_pk: CallInstrValue<'i>,
@ -58,7 +58,7 @@ pub enum Value<'i> {
Variable(VariableWithLambda<'i>), Variable(VariableWithLambda<'i>),
} }
#[derive(Serialize, Debug, PartialEq, Clone)] #[derive(Serialize, Debug, PartialEq, Eq, Clone)]
pub enum CallOutputValue<'i> { pub enum CallOutputValue<'i> {
Variable(Variable<'i>), Variable(Variable<'i>),
None, None,
@ -83,7 +83,7 @@ pub enum Number {
Float(f64), Float(f64),
} }
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum FoldScalarIterable<'i> { pub enum FoldScalarIterable<'i> {
#[serde(borrow)] #[serde(borrow)]
Scalar(ScalarWithLambda<'i>), Scalar(ScalarWithLambda<'i>),

View File

@ -86,7 +86,7 @@ pub struct MisMatch<'i> {
/// (fail 1337 "error message") /// (fail 1337 "error message")
/// (fail %last_error%) /// (fail %last_error%)
#[derive(Serialize, Debug, PartialEq)] #[derive(Serialize, Debug, PartialEq, Eq)]
pub enum Fail<'i> { pub enum Fail<'i> {
Scalar(ScalarWithLambda<'i>), Scalar(ScalarWithLambda<'i>),
Literal { Literal {
@ -118,7 +118,7 @@ pub struct FoldStream<'i> {
} }
/// (fold stream_iterable iterator instruction) /// (fold stream_iterable iterator instruction)
#[derive(Serialize, Debug, PartialEq)] #[derive(Serialize, Debug, PartialEq, Eq)]
pub struct Next<'i> { pub struct Next<'i> {
pub iterator: Scalar<'i>, pub iterator: Scalar<'i>,
} }
@ -132,5 +132,5 @@ pub struct New<'i> {
} }
/// (null) /// (null)
#[derive(Serialize, Debug, PartialEq)] #[derive(Serialize, Debug, PartialEq, Eq)]
pub struct Null; pub struct Null;

View File

@ -23,14 +23,14 @@ use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
/// A scalar value without lambda. /// A scalar value without lambda.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Scalar<'i> { pub struct Scalar<'i> {
pub name: &'i str, pub name: &'i str,
pub position: usize, pub position: usize,
} }
/// A scalar value with possible lambda expression. /// A scalar value with possible lambda expression.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct ScalarWithLambda<'i> { pub struct ScalarWithLambda<'i> {
pub name: &'i str, pub name: &'i str,
#[serde(borrow)] #[serde(borrow)]
@ -39,14 +39,14 @@ pub struct ScalarWithLambda<'i> {
} }
/// A stream without lambda. /// A stream without lambda.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Stream<'i> { pub struct Stream<'i> {
pub name: &'i str, pub name: &'i str,
pub position: usize, pub position: usize,
} }
/// A stream with possible lambda expression. /// A stream with possible lambda expression.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct StreamWithLambda<'i> { pub struct StreamWithLambda<'i> {
pub name: &'i str, pub name: &'i str,
#[serde(borrow)] #[serde(borrow)]
@ -55,7 +55,7 @@ pub struct StreamWithLambda<'i> {
} }
/// A variable that could be either scalar or stream without lambda. /// A variable that could be either scalar or stream without lambda.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum Variable<'i> { pub enum Variable<'i> {
#[serde(borrow)] #[serde(borrow)]
Scalar(Scalar<'i>), Scalar(Scalar<'i>),
@ -64,7 +64,7 @@ pub enum Variable<'i> {
} }
/// A variable that could be either scalar or stream with possible lambda expression. /// A variable that could be either scalar or stream with possible lambda expression.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum VariableWithLambda<'i> { pub enum VariableWithLambda<'i> {
#[serde(borrow)] #[serde(borrow)]
Scalar(ScalarWithLambda<'i>), Scalar(ScalarWithLambda<'i>),

View File

@ -17,7 +17,7 @@
#[macro_export] #[macro_export]
macro_rules! make_user_error( macro_rules! make_user_error(
($error_type:ident, $start_pos: ident, $token:expr, $end_pos: ident) => { { ($error_type:ident, $start_pos: ident, $token:expr, $end_pos: ident) => { {
let error = crate::parser::ParserError::$error_type(crate::parser::Span::new($start_pos, $end_pos)); let error = $crate::parser::ParserError::$error_type($crate::parser::Span::new($start_pos, $end_pos));
let error = lalrpop_util::ParseError::User { error }; let error = lalrpop_util::ParseError::User { error };
let dropped_tokens = vec![($start_pos, $token, $end_pos)]; let dropped_tokens = vec![($start_pos, $token, $end_pos)];

View File

@ -78,26 +78,24 @@ use fluence_it_types::ne_vec::NEVec;
fn try_as_record(ivalue: IValue) -> Result<NEVec<IValue>, String> { fn try_as_record(ivalue: IValue) -> Result<NEVec<IValue>, String> {
match ivalue { match ivalue {
IValue::Record(record_values) => Ok(record_values), IValue::Record(record_values) => Ok(record_values),
v => { v => Err(format!(
return Err(format!(
"expected record for InterpreterOutcome, got {:?}", "expected record for InterpreterOutcome, got {:?}",
v v
)) )),
}
} }
} }
fn try_as_i64(ivalue: IValue, field_name: &str) -> Result<i64, String> { fn try_as_i64(ivalue: IValue, field_name: &str) -> Result<i64, String> {
match ivalue { match ivalue {
IValue::S64(value) => Ok(value), IValue::S64(value) => Ok(value),
v => return Err(format!("expected an i64 for {}, got {:?}", field_name, v)), v => Err(format!("expected an i64 for {}, got {:?}", field_name, v)),
} }
} }
fn try_as_string(ivalue: IValue, field_name: &str) -> Result<String, String> { fn try_as_string(ivalue: IValue, field_name: &str) -> Result<String, String> {
match ivalue { match ivalue {
IValue::String(value) => Ok(value), IValue::String(value) => Ok(value),
v => return Err(format!("expected a string for {}, got {:?}", field_name, v)), v => Err(format!("expected a string for {}, got {:?}", field_name, v)),
} }
} }

View File

@ -22,7 +22,7 @@ use serde::Serialize;
pub type LambdaAST<'input> = NonEmpty<ValueAccessor<'input>>; pub type LambdaAST<'input> = NonEmpty<ValueAccessor<'input>>;
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
pub enum ValueAccessor<'input> { pub enum ValueAccessor<'input> {
// (.)?[$idx] // (.)?[$idx]
ArrayAccess { idx: u32 }, ArrayAccess { idx: u32 },

View File

@ -28,6 +28,7 @@ use std::collections::HashSet;
pub trait AirRunner { pub trait AirRunner {
fn new(current_call_id: impl Into<String>) -> Self; fn new(current_call_id: impl Into<String>) -> Self;
#[allow(clippy::too_many_arguments)]
fn call( fn call(
&mut self, &mut self,
air: impl Into<String>, air: impl Into<String>,

View File

@ -26,7 +26,7 @@ use air_interpreter_data::InterpreterData;
use std::collections::HashMap; use std::collections::HashMap;
/// Contains all necessary information about data. /// Contains all necessary information about data.
#[derive(Debug, Default, PartialEq)] #[derive(Debug, Default, PartialEq, Eq)]
pub struct MergeCtx { pub struct MergeCtx {
pub slider: TraceSlider, pub slider: TraceSlider,
pub streams: GlobalStreamGens, pub streams: GlobalStreamGens,

View File

@ -48,7 +48,7 @@ pub trait DataStore {
) -> Result<(), Self::Error>; ) -> Result<(), Self::Error>;
} }
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct AnomalyData<'data> { pub struct AnomalyData<'data> {
#[serde(borrow)] #[serde(borrow)]
pub air_script: Cow<'data, str>, pub air_script: Cow<'data, str>,

View File

@ -18,6 +18,7 @@ use avm_server::avm_runner::*;
use avm_server::CallResults; use avm_server::CallResults;
pub(crate) trait AirRunner { pub(crate) trait AirRunner {
#[allow(clippy::too_many_arguments)]
fn call_tracing( fn call_tracing(
&mut self, &mut self,
air: String, air: String,

View File

@ -48,6 +48,7 @@ pub(crate) fn stats(mut args: Args) -> anyhow::Result<()> {
let mut stats = self::report::StatsReport::new(); let mut stats = self::report::StatsReport::new();
#[allow(clippy::significant_drop_in_scrutinee)]
for rec in read_logs(stdin) { for rec in read_logs(stdin) {
let rec = rec?; let rec = rec?;

View File

@ -27,7 +27,8 @@ pub(crate) fn parse_tracing_duration(input: &str) -> Result<Duration, anyhow::Er
} }
} }
} }
return Err(anyhow::anyhow!("malformed duration {:?}", input));
Err(anyhow::anyhow!("malformed duration {:?}", input))
} }
pub(crate) fn unix_timestamp_now() -> u64 { pub(crate) fn unix_timestamp_now() -> u64 {