Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #291

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions avm/server/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl AVMRunner {
Ok(avm)
}

#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip_all)]
pub fn call(
&mut self,
Expand Down Expand Up @@ -106,6 +107,7 @@ impl AVMRunner {
Ok(outcome)
}

#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip_all)]
pub fn call_tracing(
&mut self,
Expand Down Expand Up @@ -170,6 +172,7 @@ impl AVMRunner {
}
}

#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip(air, prev_data, data, call_results))]
fn prepare_args(
air: impl Into<String>,
Expand Down
8 changes: 4 additions & 4 deletions crates/air-lib/air-parser/src/ast/instruction_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use air_lambda_ast::LambdaAST;
use serde::Deserialize;
use serde::Serialize;

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
mikevoronov marked this conversation as resolved.
Show resolved Hide resolved
pub enum CallInstrValue<'i> {
InitPeerId,
Literal(&'i str),
Expand All @@ -34,7 +34,7 @@ pub enum CallInstrValue<'i> {

/// Triplet represents a location of the executable code in the network.
/// 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> {
#[serde(borrow)]
pub peer_pk: CallInstrValue<'i>,
Expand All @@ -58,7 +58,7 @@ pub enum Value<'i> {
Variable(VariableWithLambda<'i>),
}

#[derive(Serialize, Debug, PartialEq, Clone)]
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
pub enum CallOutputValue<'i> {
Variable(Variable<'i>),
None,
Expand All @@ -83,7 +83,7 @@ pub enum Number {
Float(f64),
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum FoldScalarIterable<'i> {
#[serde(borrow)]
Scalar(ScalarWithLambda<'i>),
Expand Down
6 changes: 3 additions & 3 deletions crates/air-lib/air-parser/src/ast/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub struct MisMatch<'i> {

/// (fail 1337 "error message")
/// (fail %last_error%)
#[derive(Serialize, Debug, PartialEq)]
#[derive(Serialize, Debug, PartialEq, Eq)]
pub enum Fail<'i> {
Scalar(ScalarWithLambda<'i>),
Literal {
Expand Down Expand Up @@ -118,7 +118,7 @@ pub struct FoldStream<'i> {
}

/// (fold stream_iterable iterator instruction)
#[derive(Serialize, Debug, PartialEq)]
#[derive(Serialize, Debug, PartialEq, Eq)]
pub struct Next<'i> {
pub iterator: Scalar<'i>,
}
Expand All @@ -132,5 +132,5 @@ pub struct New<'i> {
}

/// (null)
#[derive(Serialize, Debug, PartialEq)]
#[derive(Serialize, Debug, PartialEq, Eq)]
pub struct Null;
12 changes: 6 additions & 6 deletions crates/air-lib/air-parser/src/ast/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ use serde::Deserialize;
use serde::Serialize;

/// A scalar value without lambda.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Scalar<'i> {
pub name: &'i str,
pub position: usize,
}

/// 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 name: &'i str,
#[serde(borrow)]
Expand All @@ -39,14 +39,14 @@ pub struct ScalarWithLambda<'i> {
}

/// A stream without lambda.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct Stream<'i> {
pub name: &'i str,
pub position: usize,
}

/// A stream with possible lambda expression.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct StreamWithLambda<'i> {
pub name: &'i str,
#[serde(borrow)]
Expand All @@ -55,7 +55,7 @@ pub struct StreamWithLambda<'i> {
}

/// 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> {
#[serde(borrow)]
Scalar(Scalar<'i>),
Expand All @@ -64,7 +64,7 @@ pub enum Variable<'i> {
}

/// 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> {
#[serde(borrow)]
Scalar(ScalarWithLambda<'i>),
Expand Down
2 changes: 1 addition & 1 deletion crates/air-lib/air-parser/src/parser/air_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[macro_export]
macro_rules! make_user_error(
($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 dropped_tokens = vec![($start_pos, $token, $end_pos)];
Expand Down
14 changes: 6 additions & 8 deletions crates/air-lib/interpreter-interface/src/interpreter_outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,24 @@ use fluence_it_types::ne_vec::NEVec;
fn try_as_record(ivalue: IValue) -> Result<NEVec<IValue>, String> {
match ivalue {
IValue::Record(record_values) => Ok(record_values),
v => {
return Err(format!(
"expected record for InterpreterOutcome, got {:?}",
v
))
}
v => Err(format!(
"expected record for InterpreterOutcome, got {:?}",
v
)),
}
}

fn try_as_i64(ivalue: IValue, field_name: &str) -> Result<i64, String> {
match ivalue {
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> {
match ivalue {
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)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/air-lib/lambda/ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use serde::Serialize;

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> {
// (.)?[$idx]
ArrayAccess { idx: u32 },
Expand Down
1 change: 1 addition & 0 deletions crates/air-lib/test-utils/src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::collections::HashSet;
pub trait AirRunner {
fn new(current_call_id: impl Into<String>) -> Self;

#[allow(clippy::too_many_arguments)]
fn call(
&mut self,
air: impl Into<String>,
Expand Down
2 changes: 1 addition & 1 deletion crates/air-lib/trace-handler/src/data_keeper/merge_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use air_interpreter_data::InterpreterData;
use std::collections::HashMap;

/// Contains all necessary information about data.
#[derive(Debug, Default, PartialEq)]
#[derive(Debug, Default, PartialEq, Eq)]
pub struct MergeCtx {
pub slider: TraceSlider,
pub streams: GlobalStreamGens,
Expand Down
2 changes: 1 addition & 1 deletion crates/data-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait DataStore {
) -> Result<(), Self::Error>;
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct AnomalyData<'data> {
#[serde(borrow)]
pub air_script: Cow<'data, str>,
Expand Down
1 change: 1 addition & 0 deletions tools/cli/air-trace/src/run/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use avm_server::avm_runner::*;
use avm_server::CallResults;

pub(crate) trait AirRunner {
#[allow(clippy::too_many_arguments)]
fn call_tracing(
&mut self,
air: String,
Expand Down
1 change: 1 addition & 0 deletions tools/cli/air-trace/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub(crate) fn stats(mut args: Args) -> anyhow::Result<()> {

let mut stats = self::report::StatsReport::new();

#[allow(clippy::significant_drop_in_scrutinee)]
mikevoronov marked this conversation as resolved.
Show resolved Hide resolved
for rec in read_logs(stdin) {
let rec = rec?;

Expand Down
3 changes: 2 additions & 1 deletion tools/cli/air-trace/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down