From b31f70612e85fe805f6f62f7a1fb6ad2dafa3c8f Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Tue, 24 Oct 2023 07:26:45 -0400 Subject: [PATCH] Apply rustfmt with latest nightly --- evm/src/cpu/kernel/optimizer.rs | 11 ++++++++--- evm/src/cpu/kernel/stack/stack_manipulation.rs | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/evm/src/cpu/kernel/optimizer.rs b/evm/src/cpu/kernel/optimizer.rs index 61f25ac6..f29c9613 100644 --- a/evm/src/cpu/kernel/optimizer.rs +++ b/evm/src/cpu/kernel/optimizer.rs @@ -114,7 +114,8 @@ fn no_op_jumps(code: &mut Vec) { fn remove_swapped_pushes(code: &mut Vec) { replace_windows(code, |window| { if let [Push(x), Push(y), StandardOp(swap1)] = window - && &swap1 == "SWAP1" { + && &swap1 == "SWAP1" + { Some(vec![Push(y), Push(x)]) } else { None @@ -125,7 +126,9 @@ fn remove_swapped_pushes(code: &mut Vec) { /// Remove SWAP1 before a commutative function. fn remove_swaps_commutative(code: &mut Vec) { replace_windows(code, |window| { - if let [StandardOp(swap1), StandardOp(f)] = window && &swap1 == "SWAP1" { + if let [StandardOp(swap1), StandardOp(f)] = window + && &swap1 == "SWAP1" + { let commutative = matches!(f.as_str(), "ADD" | "MUL" | "AND" | "OR" | "XOR" | "EQ"); commutative.then_some(vec![StandardOp(f)]) } else { @@ -138,7 +141,9 @@ fn remove_swaps_commutative(code: &mut Vec) { // Could be extended to other non-side-effecting operations, e.g. [DUP1, ADD, POP] -> [POP]. fn remove_ignored_values(code: &mut Vec) { replace_windows(code, |[a, b]| { - if let StandardOp(pop) = b && &pop == "POP" { + if let StandardOp(pop) = b + && &pop == "POP" + { match a { Push(_) => Some(vec![]), StandardOp(dup) if dup.starts_with("DUP") => Some(vec![]), diff --git a/evm/src/cpu/kernel/stack/stack_manipulation.rs b/evm/src/cpu/kernel/stack/stack_manipulation.rs index 73a24029..47b02cf6 100644 --- a/evm/src/cpu/kernel/stack/stack_manipulation.rs +++ b/evm/src/cpu/kernel/stack/stack_manipulation.rs @@ -135,7 +135,9 @@ fn shortest_path( let cost = node.cost + op.cost(); let entry = node_info.entry(neighbor.clone()); - if let Occupied(e) = &entry && e.get().0 <= cost { + if let Occupied(e) = &entry + && e.get().0 <= cost + { // We already found a better or equal path. continue; } @@ -202,9 +204,11 @@ fn next_ops( dst: &[StackItem], unique_push_targets: &[PushTarget], ) -> Vec { - if let Some(top) = src.last() && !dst.contains(top) { + if let Some(top) = src.last() + && !dst.contains(top) + { // If the top of src doesn't appear in dst, don't bother with anything other than a POP. - return vec![StackOp::Pop] + return vec![StackOp::Pop]; } if is_permutation(src, dst) {