Skip to content

Commit b2767a4

Browse files
committed
clippy: move statements after items
As a matter of style, we should always have items (structs, fns, etc) first in a block before any real code. This is because it's easy for the real code to be missed if it's interspersed with items.
1 parent 8cd383b commit b2767a4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ inefficient_to_string = "allow"
8888
inline_always = "warn"
8989
into_iter_without_iter = "warn"
9090
invalid_upcast_comparisons = "warn"
91-
items_after_statements = "allow"
91+
items_after_statements = "warn"
9292
iter_filter_is_ok = "warn"
9393
iter_filter_is_some = "warn"
9494
iter_not_returning_iterator = "warn"

src/compile.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -438,19 +438,6 @@ impl Call {
438438
/// takes the list of type `E^(<2^n)` and an initial accumulator of type `A`,
439439
/// and it produces the final accumulator of type `A`.
440440
fn list_fold(bound: NonZeroPow2Usize, f: &ProgNode) -> Result<ProgNode, simplicity::types::Error> {
441-
/* f_0 : E × A → A
442-
* f_0 := f
443-
*/
444-
let mut f_array = f.clone();
445-
446-
/* (fold f)_1 : E^<2 × A → A
447-
* (fold f)_1 := case IH f_0
448-
*/
449-
let ctx = f.inference_context();
450-
let ioh = ProgNode::i().h(ctx);
451-
let mut f_fold = ProgNode::case(ioh.as_ref(), &f_array)?;
452-
let mut i = NonZeroPow2Usize::TWO;
453-
454441
fn next_f_array(f_array: &ProgNode) -> Result<ProgNode, simplicity::types::Error> {
455442
/* f_(n + 1) : E^(2^(n + 1)) × A → A
456443
* f_(n + 1) := OIH ▵ (OOH ▵ IH; f_n); f_n
@@ -487,6 +474,19 @@ fn list_fold(bound: NonZeroPow2Usize, f: &ProgNode) -> Result<ProgNode, simplici
487474
.map(PairBuilder::build)
488475
}
489476

477+
/* f_0 : E × A → A
478+
* f_0 := f
479+
*/
480+
let mut f_array = f.clone();
481+
482+
/* (fold f)_1 : E^<2 × A → A
483+
* (fold f)_1 := case IH f_0
484+
*/
485+
let ctx = f.inference_context();
486+
let ioh = ProgNode::i().h(ctx);
487+
let mut f_fold = ProgNode::case(ioh.as_ref(), &f_array)?;
488+
let mut i = NonZeroPow2Usize::TWO;
489+
490490
while i < bound {
491491
f_array = next_f_array(&f_array)?;
492492
f_fold = next_f_fold(&f_array, &f_fold)?;

0 commit comments

Comments
 (0)