From 450dc5b8e689f5784d61550cc2c18ba3cf5a646b Mon Sep 17 00:00:00 2001 From: brock elmore Date: Sat, 9 Dec 2023 11:27:28 -0800 Subject: [PATCH] lint --- crates/graph/src/nodes/context/solving.rs | 6 ++++- crates/graph/src/nodes/context/var/typing.rs | 22 +++++++++---------- crates/graph/src/range/exec/exec_op.rs | 22 +++++++++---------- .../src/context_builder/mod.rs | 3 ++- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/crates/graph/src/nodes/context/solving.rs b/crates/graph/src/nodes/context/solving.rs index 390a2efb..130d3609 100644 --- a/crates/graph/src/nodes/context/solving.rs +++ b/crates/graph/src/nodes/context/solving.rs @@ -79,7 +79,11 @@ impl ContextNode { dep: ContextVarNode, analyzer: &mut (impl GraphBackend + AnalyzerBackend), ) -> Result<(), GraphError> { - tracing::trace!("Adding ctx dependency: {}, is_controllable: {}", dep.display_name(analyzer)?, dep.is_controllable(analyzer)?); + tracing::trace!( + "Adding ctx dependency: {}, is_controllable: {}", + dep.display_name(analyzer)?, + dep.is_controllable(analyzer)? + ); if dep.is_controllable(analyzer)? { let range = dep.ref_range(analyzer)?.unwrap(); let r = range.into_flattened_range(analyzer)?; diff --git a/crates/graph/src/nodes/context/var/typing.rs b/crates/graph/src/nodes/context/var/typing.rs index ce9d4340..c6938f4f 100644 --- a/crates/graph/src/nodes/context/var/typing.rs +++ b/crates/graph/src/nodes/context/var/typing.rs @@ -57,10 +57,7 @@ impl ContextVarNode { Ok(global_first.is_storage(analyzer)? || global_first.is_calldata_input(analyzer)) } - pub fn is_fundamental( - &self, - analyzer: &impl GraphBackend, - ) -> Result { + pub fn is_fundamental(&self, analyzer: &impl GraphBackend) -> Result { let global_first = self.global_first_version(analyzer); let is_independent = self.is_independent(analyzer)?; @@ -86,13 +83,16 @@ impl ContextVarNode { } pub fn is_controllable(&self, analyzer: &impl GraphBackend) -> Result { - Ok(self.dependent_on(analyzer, true)?.iter().any(|dependent_on| { - if let Ok(t) = dependent_on.is_fundamental(analyzer) { - t - } else { - false - } - })) + Ok(self + .dependent_on(analyzer, true)? + .iter() + .any(|dependent_on| { + if let Ok(t) = dependent_on.is_fundamental(analyzer) { + t + } else { + false + } + })) } pub fn is_calldata_input(&self, analyzer: &impl GraphBackend) -> bool { diff --git a/crates/graph/src/range/exec/exec_op.rs b/crates/graph/src/range/exec/exec_op.rs index e68d9b47..ef720173 100644 --- a/crates/graph/src/range/exec/exec_op.rs +++ b/crates/graph/src/range/exec/exec_op.rs @@ -227,9 +227,9 @@ impl ExecOp for RangeExpr { // contains the rhs, we can add zero. Futher more, if // the lhs contains rhs - 1, we can add max as it // would overflow to uint256.max - // zero min max uint256.max + // zero min max uint256.max // lhs: | - - |----------------------------| - - | - // rhs: | - - |--| - - - - - - - - - - - - - - - | + // rhs: | - - |--| - - - - - - - - - - - - - - - | match lhs_max.range_ord(&rhs_min) { Some(std::cmp::Ordering::Less) => { // We are going to overflow, zero not possible @@ -237,7 +237,7 @@ impl ExecOp for RangeExpr { Some(std::cmp::Ordering::Equal) => { // We are going to at least be zero, // we may overflow. check if rhs is const, otherwise - // add uint256.max as a candidate + // add uint256.max as a candidate candidates.push(Some(zero.clone())); if !consts.1 { candidates.push(zero.range_wrapping_sub(&one)); @@ -254,7 +254,7 @@ impl ExecOp for RangeExpr { Some(std::cmp::Ordering::Equal) => { // We are going to at least be zero, // we may overflow. check if rhs is const, otherwise - // add uint256.max as a candidate + // add uint256.max as a candidate candidates.push(Some(zero.clone())); if !consts.1 { candidates.push(zero.range_wrapping_sub(&one)); @@ -262,13 +262,13 @@ impl ExecOp for RangeExpr { } Some(std::cmp::Ordering::Greater) => { // current info: - // zero min max uint256.max + // zero min max uint256.max // lhs: | - - |----------------------------| - - | // rhs: | - |----? - - - - - - - - - - - - - - - | // figure out where rhs max is match lhs_min.range_ord(&rhs_max) { Some(std::cmp::Ordering::Less) => { - // zero min + // zero min // lhs: | - - |---? // rhs: | - |----| // min max @@ -277,21 +277,21 @@ impl ExecOp for RangeExpr { candidates.push(zero.range_wrapping_sub(&one)); } Some(std::cmp::Ordering::Equal) => { - // zero min + // zero min // lhs: | - - |---? // rhs: | |---| // min max // Add zero - candidates.push(Some(zero.clone())); + candidates.push(Some(zero.clone())); } Some(std::cmp::Ordering::Greater) => { - // zero min + // zero min // lhs: | - - |---? // rhs: |-----| // min max // Add nothing - } - _ => {} + } + _ => {} } } _ => {} diff --git a/crates/solc-expressions/src/context_builder/mod.rs b/crates/solc-expressions/src/context_builder/mod.rs index 5a0579b4..a2aadafd 100644 --- a/crates/solc-expressions/src/context_builder/mod.rs +++ b/crates/solc-expressions/src/context_builder/mod.rs @@ -1332,7 +1332,8 @@ pub trait ContextBuilder: ); let new_lhs = self.advance_var_in_ctx(lhs_cvar.latest_version(self), loc, ctx)?; - new_lhs.underlying_mut(self).into_expr_err(loc)?.tmp_of = rhs_cvar.tmp_of(self).into_expr_err(loc)?; + new_lhs.underlying_mut(self).into_expr_err(loc)?.tmp_of = + rhs_cvar.tmp_of(self).into_expr_err(loc)?; if lhs_cvar.is_storage(self).into_expr_err(loc)? { self.add_edge(new_lhs, rhs_cvar, Edge::Context(ContextEdge::StorageWrite)); }