Skip to content

Commit

Permalink
lints and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
plotchy committed Jun 28, 2024
1 parent 2523d63 commit 3ad7061
Show file tree
Hide file tree
Showing 37 changed files with 53 additions and 97 deletions.
4 changes: 2 additions & 2 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ fn main() {
if !args.funcs.is_empty() {
if args.funcs.iter().any(|analyze_for| {
FunctionNode::from(func)
.name(&mut analyzer)
.name(&analyzer)
.unwrap()
.starts_with(analyze_for)
}) {
Expand Down Expand Up @@ -509,7 +509,7 @@ fn main() {
let funcs = contract.funcs(&analyzer);
for func in funcs.into_iter() {
if !args.funcs.is_empty() {
if args.funcs.contains(&func.name(&mut analyzer).unwrap()) {
if args.funcs.contains(&func.name(&analyzer).unwrap()) {
let ctx = func.body_ctx(&mut analyzer);
let analysis = analyzer
.bounds_for_all(arena, &file_mapping, ctx, config)
Expand Down
2 changes: 1 addition & 1 deletion crates/graph/src/nodes/context/var/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
AsDotStr, ContextEdge, Edge, GraphBackend, Node,
};

use shared::{NodeIdx, RangeArena, Search, StorageLocation, GraphError};
use shared::{GraphError, NodeIdx, RangeArena, Search, StorageLocation};

use petgraph::{visit::EdgeRef, Direction};
use solang_parser::pt::Loc;
Expand Down
2 changes: 1 addition & 1 deletion crates/graph/src/nodes/context/versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::{
nodes::{CallFork, ContextNode, FunctionNode, KilledKind},
AnalyzerBackend, GraphBackend, Node,
};
use shared::GraphError;
use petgraph::visit::EdgeRef;
use petgraph::Direction;
use shared::GraphError;

use solang_parser::pt::Loc;

Expand Down
4 changes: 1 addition & 3 deletions crates/graph/src/nodes/enum_ty.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
nodes::Concrete, range::elem::Elem, AsDotStr, GraphBackend, Node, SolcRange,
};
use crate::{nodes::Concrete, range::elem::Elem, AsDotStr, GraphBackend, Node, SolcRange};

use shared::{GraphError, NodeIdx, RangeArena};

Expand Down
4 changes: 1 addition & 3 deletions crates/graph/src/nodes/err_ty.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, Node,
};
use crate::{nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, Node};

use shared::{GraphError, NodeIdx, RangeArena};
use solang_parser::pt::{ErrorDefinition, ErrorParameter, Expression, Identifier, Loc};
Expand Down
3 changes: 1 addition & 2 deletions crates/graph/src/nodes/func_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::{
nodes::Concrete,
nodes::{ContextNode, ContractNode, SourceUnitNode, SourceUnitPartNode},
range::elem::Elem,
AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, Node, SolcRange,
VarType,
AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, Node, SolcRange, VarType,
};

use shared::{GraphError, NodeIdx, RangeArena, Search, StorageLocation};
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/struct_ty.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, Edge, GraphBackend,
Node, VarType,
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, Edge, GraphBackend, Node,
VarType,
};

use shared::{GraphError, NodeIdx, RangeArena};
Expand Down
3 changes: 1 addition & 2 deletions crates/graph/src/nodes/ty_ty.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, Node,
VarType,
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, Node, VarType,
};

use shared::{GraphError, NodeIdx, RangeArena};
Expand Down
3 changes: 1 addition & 2 deletions crates/graph/src/range/elem/elem_enum/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ impl RangeArenaLike<Elem<Concrete>> for RangeArena<Elem<Concrete>> {
fn to_graph(
&mut self,
analyzer: &impl GraphBackend,
) -> Result<petgraph::Graph<Elem<Concrete>, usize, petgraph::Directed, usize>, GraphError>
{
) -> Result<petgraph::Graph<Elem<Concrete>, usize, petgraph::Directed, usize>, GraphError> {
let mut graph = petgraph::Graph::default();
let mut added = vec![];
let mut ids = vec![];
Expand Down
16 changes: 7 additions & 9 deletions crates/graph/src/range/exec/exec_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ impl ExecOp<Concrete> for RangeExpr<Concrete> {
) -> Result<Elem<Concrete>, Self::GraphError> {
let idx = self.arena_idx(arena);
if let Some(idx) = idx {
if let Some(t) = arena.ranges.get(idx) {
if let Elem::Expr(expr) = t {
tracing::trace!("hitting cache");
if maximize {
if let Some(MinMaxed::Maximized(max)) = &expr.maximized {
return Ok(*max.clone());
}
} else if let Some(MinMaxed::Minimized(min)) = &expr.minimized {
return Ok(*min.clone());
if let Some(Elem::Expr(expr)) = arena.ranges.get(idx) {
tracing::trace!("hitting cache");
if maximize {
if let Some(MinMaxed::Maximized(max)) = &expr.maximized {
return Ok(*max.clone());
}
} else if let Some(MinMaxed::Minimized(min)) = &expr.minimized {
return Ok(*min.clone());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/graph/src/solvers/dl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl DLSolver {
added_atoms.push((*dyn_elem).clone());
self.graph_map.insert((*dyn_elem).clone(), idx);
if let Some(dep) = dep {
if self.var_to_atom_idx.get(&dep).is_none() {
if !self.var_to_atom_idx.contains_key(&dep) {
added_deps.push(dep);
self.var_to_atom_idx.insert(dep, idx);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pyrometer/src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ impl Analyzer {
});
}

async fn post_source_to_site_async(file_no: usize, path: &PathBuf, source: &str)
async fn post_source_to_site_async(file_no: usize, path: &Path, source: &str)
where
Self: std::marker::Sized,
Self: AnalyzerLike,
Expand Down
2 changes: 1 addition & 1 deletion crates/pyrometer/src/analyzer_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use graph::{
},
AnalyzerBackend, Edge, Node, VarType,
};
use shared::{AnalyzerLike, ExprErr, IntoExprErr, GraphLike, JoinStats, NodeIdx, RangeArena};
use shared::{AnalyzerLike, ExprErr, GraphLike, IntoExprErr, JoinStats, NodeIdx, RangeArena};

use ahash::AHashMap;
use ethers_core::types::U256;
Expand Down
14 changes: 7 additions & 7 deletions crates/pyrometer/src/graph_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,13 +1265,13 @@ pub fn mermaid_node(
match g.node(current_node) {
Node::ContextVar(..) => {
// highlight self
if let Ok(loc) = graph::nodes::ContextVarNode::from(current_node).loc(g) {
if let solang_parser::pt::Loc::File(f, s, e) = loc {
node_str.push_str(&format!(
"\n{indent}class {} loc_{f}_{s}_{e}",
petgraph::graph::GraphIndex::index(&current_node)
));
}
if let Ok(solang_parser::pt::Loc::File(f, s, e)) =
graph::nodes::ContextVarNode::from(current_node).loc(g)
{
node_str.push_str(&format!(
"\n{indent}class {} loc_{f}_{s}_{e}",
petgraph::graph::GraphIndex::index(&current_node)
));
}

// color the forks
Expand Down
4 changes: 2 additions & 2 deletions crates/shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod analyzer_like;
mod error;
pub mod gas;
mod graph_like;
mod search;
mod error;

pub use analyzer_like::*;
pub use error::*;
pub use graph_like::*;
pub use search::*;
pub use error::*;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum StorageLocation {
Expand Down
6 changes: 1 addition & 5 deletions crates/solc-expressions/src/array.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
require::Require, variable::Variable, ContextBuilder, ExpressionParser,
ListAccess,
};
use crate::{require::Require, variable::Variable, ContextBuilder, ExpressionParser, ListAccess};

use graph::{
elem::{Elem, RangeDyn, RangeOp},
Expand Down Expand Up @@ -483,4 +480,3 @@ pub trait Array: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Sized {
Ok(())
}
}

7 changes: 2 additions & 5 deletions crates/solc-expressions/src/assign.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use crate::{
array::Array, variable::Variable, ContextBuilder, ExpressionParser,
ListAccess,
};
use crate::{array::Array, variable::Variable, ContextBuilder, ExpressionParser, ListAccess};

use graph::{
elem::{Elem, RangeElem},
nodes::{Concrete, ContextNode, ContextVarNode, ExprRet},
AnalyzerBackend, ContextEdge, Edge, Node,
};

use shared::{ExprErr, IntoExprErr, GraphError, RangeArena};
use shared::{ExprErr, GraphError, IntoExprErr, RangeArena};
use solang_parser::pt::{Expression, Loc};

impl<T> Assign for T where T: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Sized {}
Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/bin_op.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
require::Require, variable::Variable, ContextBuilder, ExpressionParser,
};
use crate::{require::Require, variable::Variable, ContextBuilder, ExpressionParser};

use graph::{
elem::*,
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use graph::{
},
AnalyzerBackend, Node, Range, SolcRange, VarType,
};
use shared::{ExprErr, IntoExprErr, GraphError, RangeArena};
use shared::{ExprErr, GraphError, IntoExprErr, RangeArena};

use solang_parser::pt::{Expression, Loc};
use std::cmp::Ordering;
Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/cond_op.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
require::Require, ContextBuilder, ExpressionParser, StatementParser,
};
use crate::{require::Require, ContextBuilder, ExpressionParser, StatementParser};

use graph::{
elem::Elem,
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/context_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use graph::{
nodes::{Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet, KilledKind},
AnalyzerBackend, ContextEdge, Edge, Node,
};
use shared::{ExprErr, IntoExprErr, GraphError, RangeArena};
use shared::{ExprErr, GraphError, IntoExprErr, RangeArena};

use solang_parser::pt::{Expression, Loc};

Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
func_call::helper::CallerHelper, func_call::modifier::ModifierCaller,
};
use crate::{func_call::helper::CallerHelper, func_call::modifier::ModifierCaller};

use graph::{
elem::Elem,
Expand Down
3 changes: 1 addition & 2 deletions crates/solc-expressions/src/func_call/func_caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
use crate::{
func_call::join::FuncJoiner, func_call::modifier::ModifierCaller, helper::CallerHelper,
internal_call::InternalFuncCaller, intrinsic_call::IntrinsicFuncCaller,
namespaced_call::NameSpaceFuncCaller, ContextBuilder, ExpressionParser,
StatementParser,
namespaced_call::NameSpaceFuncCaller, ContextBuilder, ExpressionParser, StatementParser,
};
use std::cell::RefCell;
use std::rc::Rc;
Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/func_call/helper.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Helper traits & blanket implementations that help facilitate performing function calls.
use crate::{
member_access::ListAccess, variable::Variable, ContextBuilder, ExpressionParser,
};
use crate::{member_access::ListAccess, variable::Variable, ContextBuilder, ExpressionParser};

use graph::{
elem::Elem,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::func_caller::NamedOrUnnamedArgs;
use crate::{
array::Array, bin_op::BinOp, ContextBuilder, ExpressionParser, ListAccess,
};
use crate::{array::Array, bin_op::BinOp, ContextBuilder, ExpressionParser, ListAccess};

use graph::{
elem::*,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::func_caller::NamedOrUnnamedArgs;
use crate::{
assign::Assign, func_call::helper::CallerHelper, ContextBuilder, ExpressionParser,
};
use crate::{assign::Assign, func_call::helper::CallerHelper, ContextBuilder, ExpressionParser};

use graph::{
elem::*,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::func_caller::NamedOrUnnamedArgs;
use crate::{
variable::Variable, ContextBuilder, ExpressionParser, ListAccess,
};
use crate::{variable::Variable, ContextBuilder, ExpressionParser, ListAccess};

use graph::{
elem::{Elem, RangeElem},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::func_caller::NamedOrUnnamedArgs;
use crate::{
func_call::helper::CallerHelper, ContextBuilder, ExpressionParser,
};
use crate::{func_call::helper::CallerHelper, ContextBuilder, ExpressionParser};
use graph::nodes::FunctionNode;

use graph::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::func_caller::NamedOrUnnamedArgs;
use crate::{
func_call::helper::CallerHelper, require::Require, ContextBuilder, ExpressionParser,
};
use crate::{func_call::helper::CallerHelper, require::Require, ContextBuilder, ExpressionParser};

use graph::{
elem::Elem,
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/func_call/join.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::context_builder::StatementParser;
use crate::helper::CallerHelper;
use crate::member_access::ListAccess;
use crate::variable::Variable;
use crate::helper::CallerHelper;

use graph::{
elem::{Elem, RangeElem, RangeExpr, RangeOp},
Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/func_call/modifier.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Traits & blanket implementations that facilitate performing modifier function calls.
use crate::{
func_caller::FuncCaller, helper::CallerHelper, ContextBuilder, ExpressionParser,
};
use crate::{func_caller::FuncCaller, helper::CallerHelper, ContextBuilder, ExpressionParser};

use graph::{
elem::Elem,
Expand Down
2 changes: 0 additions & 2 deletions crates/solc-expressions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use solang_parser::pt::Loc;

mod array;
mod assign;
mod bin_op;
Expand Down
3 changes: 2 additions & 1 deletion crates/solc-expressions/src/member_access/member_trait.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{
BuiltinAccess, ContextBuilder, ContractAccess, EnumAccess, Env, ExpressionParser, ListAccess, StructAccess,
BuiltinAccess, ContextBuilder, ContractAccess, EnumAccess, Env, ExpressionParser, ListAccess,
StructAccess,
};

use graph::{
Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/pre_post_in_decrement.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
context_builder::ContextBuilder, variable::Variable, ExpressionParser,
};
use crate::{context_builder::ContextBuilder, variable::Variable, ExpressionParser};

use graph::{
elem::*,
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use graph::{
nodes::{Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet, VarNode},
AnalyzerBackend, ContextEdge, Edge, Node, VarType,
};
use shared::{ExprErr, IntoExprErr, GraphError, RangeArena};
use shared::{ExprErr, GraphError, IntoExprErr, RangeArena};

use solang_parser::pt::{Expression, Identifier, Loc, VariableDeclaration};

Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/yul/yul_builder.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Trait and blanket implementation for parsing yul-based statements and expressions
use crate::{
yul::YulCondOp, yul::YulFuncCaller, ContextBuilder, ExpressionParser,
};
use crate::{yul::YulCondOp, yul::YulFuncCaller, ContextBuilder, ExpressionParser};

use graph::{
elem::Elem,
Expand Down
4 changes: 1 addition & 3 deletions crates/solc-expressions/src/yul/yul_funcs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
assign::Assign, variable::Variable, yul::YulBuilder, BinOp, Cmp, ContextBuilder, Env,
};
use crate::{assign::Assign, variable::Variable, yul::YulBuilder, BinOp, Cmp, ContextBuilder, Env};

use graph::{
elem::*,
Expand Down

0 comments on commit 3ad7061

Please sign in to comment.