Skip to content

Commit

Permalink
more clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
plotchy committed Jun 26, 2024
1 parent 655bf96 commit 66dcd5c
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 52 deletions.
12 changes: 6 additions & 6 deletions crates/graph/src/range/elem/elem_enum/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ impl RangeArenaLike<Elem<Concrete>> for RangeArena<Elem<Concrete>> {
self.map.insert(Elem::Null, 0);
}

let nulls = self.ranges.iter().fold(0, |mut acc, e| {
if matches!(e, Elem::Null) {
acc += 1;
}
acc
});
// let nulls = self.ranges.iter().fold(0, |mut acc, e| {
// if matches!(e, Elem::Null) {
// acc += 1;
// }
// acc
// });

// println!(
// "{}\nhad cycle:\n{:?}",
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/range/elem/map_or_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ impl RangeElem<Concrete> for RangeDyn<Concrete> {
.map(|(k, (v, op))| {
let mut new_k = k.clone();
let mut new_v = v.clone();
new_k.arenaize(analyzer, arena);
new_v.arenaize(analyzer, arena);
let _ =new_k.arenaize(analyzer, arena);
let _ =new_v.arenaize(analyzer, arena);
(new_k, (new_v, *op))
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion crates/graph/src/range/exec/math_ops/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn exec_sub(
rhs_max: &Elem<Concrete>,
maximize: bool,
wrapping: bool,
analyzer: &impl GraphBackend,
_analyzer: &impl GraphBackend,
arena: &mut RangeArena<Elem<Concrete>>,
) -> Option<Elem<Concrete>> {
// quick check if rhs is const and zero, if so return min or max
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait Array: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Sized {
ctx: ContextNode,
) -> Result<(), ExprErr> {
self.parse_ctx_expr(arena, ty_expr, ctx)?;
self.apply_to_edges(ctx, ty_expr.loc(), arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, ty_expr.loc(), arena, &|analyzer, _arena, ctx, loc| {
if let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? {
if matches!(ret, ExprRet::CtxKilled(_)) {
ctx.push_expr(ret, analyzer).into_expr_err(loc)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/bin_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ pub trait BinOp: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Sized {
fn checked_require_mod_div(
&mut self,
arena: &mut RangeArena<Elem<Concrete>>,
lhs: ContextVarNode,
_lhs: ContextVarNode,
rhs: ContextVarNode,
loc: Loc,
ctx: ContextNode,
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 @@ -64,7 +64,7 @@ pub trait Cmp: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Sized {
RangeOp::Not,
Elem::Null,
));
elem.arenaize(self, arena);
let _ = elem.arenaize(self, arena);
let mut range = SolcRange::new(elem.clone(), elem, vec![]);

range.cache_eval(self, arena).into_expr_err(loc)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/context_builder/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ pub trait ExpressionParser:
}

self.parse_ctx_expr(arena, expr, ctx)?;
self.apply_to_edges(ctx, *loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, *loc, arena, &|analyzer, _arena, ctx, loc| {
tracing::trace!("Delete variable pop");
let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoRhs(
Expand Down
6 changes: 3 additions & 3 deletions crates/solc-expressions/src/context_builder/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub trait StatementParser:
ctx_node.into(),
*loc,
arena,
&|analyzer, arena, ctx, loc| {
&|analyzer, _arena, ctx, loc| {
if ctx.killed_or_ret(analyzer).into_expr_err(loc)? {
tracing::trace!("killing due to bad funciton call");
let res = ContextNode::from(ctx_node)
Expand Down Expand Up @@ -415,7 +415,7 @@ pub trait StatementParser:
ctx,
*loc,
arena,
&|analyzer, arena, ctx, loc| {
&|analyzer, _arena, ctx, loc| {
if ctx.killed_or_ret(analyzer).into_expr_err(loc)? {
tracing::trace!("killing due to bad expr");
ContextNode::from(parent.into())
Expand Down Expand Up @@ -550,7 +550,7 @@ pub trait StatementParser:
if let Some(parent) = parent_ctx {
let parent = ContextNode::from(parent.into());
let res =
self.apply_to_edges(parent, *loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(parent, *loc, arena, &|analyzer, _arena, ctx, loc| {
let res = ctx
.kill(analyzer, loc, KilledKind::Revert)
.into_expr_err(loc);
Expand Down
6 changes: 3 additions & 3 deletions crates/solc-expressions/src/func_call/func_caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<'a> NamedOrUnnamedArgs<'a> {
Ok(())
})?;
if !inner.is_empty() {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_tmp_expr(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<'a> NamedOrUnnamedArgs<'a> {
Ok(())
})?;
if !inner.is_empty() {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_tmp_expr(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand All @@ -132,7 +132,7 @@ impl<'a> NamedOrUnnamedArgs<'a> {
Ok(())
})?;
if !inner.is_empty() {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_tmp_expr(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand Down
4 changes: 2 additions & 2 deletions crates/solc-expressions/src/func_call/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub trait CallerHelper: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> +
.try_for_each(|input| self.parse_input(arena, ctx, loc, input, &append))?;

if !inputs.is_empty() {
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_tmp_expr(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand All @@ -165,7 +165,7 @@ pub trait CallerHelper: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> +
append: &Rc<RefCell<bool>>,
) -> Result<(), ExprErr> {
self.parse_ctx_expr(arena, input, ctx)?;
self.apply_to_edges(ctx, input.loc(), arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, input.loc(), arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/func_call/internal_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub trait InternalFuncCaller:
Ok(())
})
})?;
self.apply_to_edges(ctx, *loc, arena, &|analyzer, arena, ctx, _loc| {
self.apply_to_edges(ctx, *loc, arena, &|analyzer, _arena, ctx, _loc| {
ctx.push_expr(ExprRet::Single(cvar), analyzer)
.into_expr_err(*loc)?;
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub trait AbiCaller: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Siz
}
let input_exprs = input_exprs.unnamed_args().unwrap();
self.parse_ctx_expr(arena, &input_exprs[1], ctx)?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoRhs(
loc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait BlockCaller: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + S
match &*func_name {
"blockhash" => {
input_exprs.parse_n(arena, 1, self, ctx, loc)?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(input) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoRhs(
loc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub trait ConstructorCaller:
if !input_exprs.is_empty() {
self.parse_ctx_expr(arena, &input_exprs.unnamed_args().unwrap()[0], ctx)?;
}
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
if !input_exprs.is_empty() {
let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoRhs(loc, "Contract creation failed".to_string()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait DynBuiltinCaller: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr
.iter()
.try_for_each(|expr| {
self.parse_ctx_expr(arena, expr, ctx)?;
self.apply_to_edges(ctx, *loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, *loc, arena, &|analyzer, _arena, ctx, loc| {
let input = ctx
.pop_expr_latest(loc, analyzer)
.into_expr_err(loc)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub trait IntrinsicFuncCaller:
None,
None,
)?;
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let var = match ContextVar::maybe_from_user_ty(analyzer, loc, ty_idx) {
Some(v) => v,
None => {
Expand Down Expand Up @@ -141,7 +141,7 @@ pub trait IntrinsicFuncCaller:
None,
None,
)?;
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let var = match ContextVar::maybe_from_user_ty(analyzer, loc, ty_idx) {
Some(v) => v,
None => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub trait PrecompileCaller:
match &*func_name {
"sha256" => {
self.parse_ctx_expr(arena, &input_exprs.unnamed_args().unwrap()[0], ctx)?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(input) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoRhs(
loc,
Expand All @@ -60,7 +60,7 @@ pub trait PrecompileCaller:
}
"ripemd160" => {
self.parse_ctx_expr(arena, &input_exprs.unnamed_args().unwrap()[0], ctx)?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(input) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoRhs(
loc,
Expand All @@ -85,7 +85,7 @@ pub trait PrecompileCaller:
}
"ecrecover" => {
input_exprs.parse(arena, self, ctx, loc)?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let cctx = Context::new_subctx(
ctx,
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub trait SolidityCaller:
// TODO: actually calcuate this if possible
input_exprs.parse(arena, self, ctx, loc)?;

self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)?;
let var = ContextVar::new_from_builtin(
loc,
Expand All @@ -99,7 +99,7 @@ pub trait SolidityCaller:
"mulmod" => {
// TODO: actually calcuate this if possible
input_exprs.parse(arena, self, ctx, loc)?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)?;
let var = ContextVar::new_from_builtin(
loc,
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/func_call/namespaced_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ pub trait NameSpaceFuncCaller:
let _ = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)?;
Ok(())
})?;
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, _loc| {
analyzer.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, _loc| {
ctx.push_expr(ExprRet::Single(cvar), analyzer)
.into_expr_err(loc)?;
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions crates/solc-expressions/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub trait List: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Sized {
params.iter().try_for_each(|(loc, input)| {
if let Some(input) = input {
self.parse_ctx_expr(arena, &input.ty, ctx)?;
self.apply_to_edges(ctx, *loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, *loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand All @@ -39,13 +39,13 @@ pub trait List: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Sized {
})
} else {
// create a dummy var
self.apply_to_edges(ctx, *loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, *loc, arena, &|analyzer, _arena, ctx, loc| {
ctx.append_tmp_expr(ExprRet::Null, analyzer)
.into_expr_err(loc)
})
}
})?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_tmp_expr(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand Down
2 changes: 1 addition & 1 deletion crates/solc-expressions/src/member_access/member_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait MemberAccess:
}

self.parse_ctx_expr(arena, member_expr, ctx)?;
self.apply_to_edges(ctx, loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) = ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? else {
return Err(ExprErr::NoLhs(
loc,
Expand Down
4 changes: 2 additions & 2 deletions crates/solc-expressions/src/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub trait Variable: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Size
target_ctx,
ident.loc,
arena,
&|analyzer, arena, edge_ctx, _loc| {
&|analyzer, _arena, edge_ctx, _loc| {
let var = analyzer.advance_var_in_ctx(cvar, ident.loc, edge_ctx)?;
edge_ctx
.push_expr(ExprRet::Single(var.into()), analyzer)
Expand All @@ -60,7 +60,7 @@ pub trait Variable: AnalyzerBackend<Expr = Expression, ExprErr = ExprErr> + Size
target_ctx,
ident.loc,
arena,
&|analyzer, arena, edge_ctx, _loc| {
&|analyzer, _arena, edge_ctx, _loc| {
let var = analyzer.advance_var_in_ctx(cvar, ident.loc, edge_ctx)?;
edge_ctx
.push_expr(ExprRet::Single(var.into()), analyzer)
Expand Down
6 changes: 3 additions & 3 deletions crates/solc-expressions/src/yul/yul_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub trait YulBuilder:

if let Some(yul_expr) = maybe_yul_expr {
analyzer.parse_ctx_yul_expr(arena, yul_expr, ctx)?;
analyzer.apply_to_edges(ctx, *loc, arena, &|analyzer, arena, ctx, loc| {
analyzer.apply_to_edges(ctx, *loc, arena, &|analyzer, _arena, ctx, loc| {
let Some(ret) =
ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)?
else {
Expand Down Expand Up @@ -312,7 +312,7 @@ pub trait YulBuilder:
StringLiteral(lit, _) => self.string_literal(ctx, lit.loc, &lit.string),
Variable(ident) => {
self.variable(arena, ident, ctx, None)?;
self.apply_to_edges(ctx, ident.loc, arena, &|analyzer, arena, edge_ctx, loc| {
self.apply_to_edges(ctx, ident.loc, arena, &|analyzer, _arena, edge_ctx, loc| {
if let Some(ret) = edge_ctx.pop_expr_latest(loc, analyzer).into_expr_err(loc)? {
if ContextVarNode::from(ret.expect_single().into_expr_err(loc)?)
.is_memory(analyzer)
Expand Down Expand Up @@ -345,7 +345,7 @@ pub trait YulBuilder:
SuffixAccess(loc, yul_member_expr, ident) => {
self.parse_inputs(arena, ctx, *loc, &[*yul_member_expr.clone()])?;

self.apply_to_edges(ctx, *loc, arena, &|analyzer, arena, ctx, loc| {
self.apply_to_edges(ctx, *loc, arena, &|analyzer, _arena, ctx, loc| {
let Ok(Some(lhs)) = ctx.pop_expr_latest(loc, analyzer) else {
return Err(ExprErr::NoLhs(
loc,
Expand Down
Loading

0 comments on commit 66dcd5c

Please sign in to comment.