Merge pull request #1307 from topos-protocol/fmt

Apply rustfmt with latest nightly
This commit is contained in:
Robin Salen 2023-10-24 08:50:15 -04:00 committed by GitHub
commit ed5ec3ca9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -114,7 +114,8 @@ fn no_op_jumps(code: &mut Vec<Item>) {
fn remove_swapped_pushes(code: &mut Vec<Item>) {
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<Item>) {
/// Remove SWAP1 before a commutative function.
fn remove_swaps_commutative(code: &mut Vec<Item>) {
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<Item>) {
// Could be extended to other non-side-effecting operations, e.g. [DUP1, ADD, POP] -> [POP].
fn remove_ignored_values(code: &mut Vec<Item>) {
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![]),

View File

@ -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<StackOp> {
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) {