Skip to content

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Feb 26, 2024
1 parent b6689e4 commit a9f014b
Show file tree
Hide file tree
Showing 137 changed files with 289 additions and 289 deletions.
4 changes: 2 additions & 2 deletions noir_stdlib/src/field_element.nr
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ pub fn modulus_le_bytes() -> [u8] {}
pub fn bytes32_to_field(bytes32: [u8; 32]) -> field {
// Convert it to a field element
let mut v = 1;
let mut high = 0 as plain::field;
let mut low = 0 as plain::field;
let mut high = 0 as field;
let mut low = 0 as field;

for i in 0..16 {
high = high + (bytes32[15 - i] as field) * v;
Expand Down
6 changes: 3 additions & 3 deletions noir_stdlib/src/uint128.nr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl U128 {

pub fn from_u64s_le(lo: u64, hi: u64) -> U128 {
// in order to handle multiplication, we need to represent the product of two u64 without overflow
assert(crate::field::modulus_num_bits() as u32 > 128);
assert(crate::field_element::modulus_num_bits() as u32 > 128);
U128 { lo: lo as Field, hi: hi as Field }
}

Expand Down Expand Up @@ -129,7 +129,7 @@ impl U128 {
let low = self.lo * b.lo;
let lo = low as u64 as Field;
let carry = (low - lo) / pow64;
let high = if crate::field::modulus_num_bits() as u32 > 196 {
let high = if crate::field_element::modulus_num_bits() as u32 > 196 {
(self.lo + self.hi) * (b.lo + b.hi) - low + carry
} else {
self.lo * b.hi + self.hi * b.lo + carry
Expand Down Expand Up @@ -175,7 +175,7 @@ impl Mul for U128 {
let low = self.lo*b.lo;
let lo = low as u64 as Field;
let carry = (low - lo) / pow64;
let high = if crate::field::modulus_num_bits() as u32 > 196 {
let high = if crate::field_element::modulus_num_bits() as u32 > 196 {
(self.lo+self.hi)*(b.lo+b.hi) - low + carry
} else {
self.lo*b.hi + self.hi*b.lo + carry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ fn main() {
assert((x / y) == div(x, y));
}

unconstrained fn add(x: Field, y: Field) -> Field {
unconstrained fn add(x: field, y: field) -> field {
x + y
}

unconstrained fn sub(x: Field, y: Field) -> Field {
unconstrained fn sub(x: field, y: field) -> field {
x - y
}

unconstrained fn mul(x: Field, y: Field) -> Field {
unconstrained fn mul(x: field, y: field) -> field {
x * y
}

unconstrained fn div(x: Field, y: Field) -> Field {
unconstrained fn div(x: field, y: field) -> field {
x / y
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
fn ret_normal_lambda1() -> fn() -> Field {
fn ret_normal_lambda1() -> fn() -> field {
|| 10
}
// return lamda that captures a thing
fn ret_closure1() -> fn[(Field,)]() -> Field {
fn ret_closure1() -> fn[(field,)]() -> field {
let x = 20;
|| x + 10
}
// return lamda that captures two things
fn ret_closure2() -> fn[(Field, Field)]() -> Field {
fn ret_closure2() -> fn[(field, field)]() -> field {
let x = 20;
let y = 10;
|| x + y + 10
Expand All @@ -19,19 +19,19 @@ fn ret_closure3() -> fn[(u32, u64)]() -> u64 {
|| x as u64 + y + 10
}
// accepts closure that has 1 thing in its env, calls it and returns the result
fn accepts_closure1(f: fn[(Field,)]() -> Field) -> Field {
fn accepts_closure1(f: fn[(field,)]() -> field) -> field {
f()
}
// accepts closure that has 1 thing in its env and returns it
fn accepts_closure2(f: fn[(Field,)]() -> Field) -> fn[(Field,)]() -> Field {
fn accepts_closure2(f: fn[(field,)]() -> field) -> fn[(field,)]() -> field {
f
}
// accepts closure with different types in the capture group
fn accepts_closure3(f: fn[(u32, u64)]() -> u64) -> u64 {
f()
}
// generic over closure environments
fn add_results<Env1, Env2>(f1: fn[Env1]() -> Field, f2: fn[Env2]() -> Field) -> Field {
fn add_results<Env1, Env2>(f1: fn[Env1]() -> field, f2: fn[Env2]() -> field) -> field {
f1() + f2()
}
// a *really* generic function
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main(x: Field, y: Field) {
fn main(x: field, y: field) {
let flag = (x == 1) | (y == 2);
assert(flag | false == flag);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main(x: Field) -> pub Field {
fn main(x: field) -> pub field {
// Regression test for issue #547
// Warning: it must be kept at the start of main
let arr: [u8; 2] = [1, 2];
Expand All @@ -11,6 +11,6 @@ fn main(x: Field) -> pub Field {
x + safe_inverse(0)
}

fn safe_inverse(n: Field) -> Field {
fn safe_inverse(n: field) -> field {
if n == 0 { 0 } else { 1 / n }
}
6 changes: 3 additions & 3 deletions test_programs/compile_success_empty/generators/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// the syntax for these return types is very difficult to get right :/
// for arguments this can be handled with a generic Env (or with Fn traits when we add them)
// but for return types neither fo these will help, you need to type out the exact type
fn make_counter() -> fn[(&mut Field,)]() -> Field {
fn make_counter() -> fn[(&mut field,)]() -> field {
let mut x = &mut 0;

|| {
Expand All @@ -11,7 +11,7 @@ fn make_counter() -> fn[(&mut Field,)]() -> Field {
}
}

fn fibonacci_generator() -> fn[(&mut Field, &mut Field)]() -> Field {
fn fibonacci_generator() -> fn[(&mut field, &mut field)]() -> field {
let mut x = &mut 1;
let mut y = &mut 2;

Expand All @@ -26,7 +26,7 @@ fn fibonacci_generator() -> fn[(&mut Field, &mut Field)]() -> Field {
}
}
// we'll be able to un-hardcode the array length if we have the ::<> syntax proposed in https://github.com/noir-lang/noir/issues/2458
fn get_some<Env>(generator: fn[Env]() -> Field) -> [Field; 5] {
fn get_some<Env>(generator: fn[Env]() -> field) -> [field; 5] {
[0, 0, 0, 0, 0].map(|_| generator())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
fn g(x: &mut Field) -> () {
fn g(x: &mut field) -> () {
*x *= 2;
}

fn h(x: &mut Field) -> () {
fn h(x: &mut field) -> () {
*x *= 3;
}

fn selector(flag: &mut bool) -> fn(&mut Field) -> () {
fn selector(flag: &mut bool) -> fn(&mut field) -> () {
let my_func = if *flag { g } else { h };
// Flip the flag for the next function call
*flag = !(*flag);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main(x: Field) {
fn main(x: field) {
// This is a regression test for #2450.
// The compiler should recognize that the `(x as u32)` instructions are duplicates and so have the same output.
assert(x as u32 == x as u32);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::std;
// This test checks that we perform dead-instruction-elimination on intrinsic functions.
fn main(x: Field) {
fn main(x: field) {
let hash = std::hash::pedersen_commitment([x]);
let _p1 = std::scalar_mul::fixed_base_embedded_curve(x, 0);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main(x: pub Field) -> pub Field {
fn main(x: pub field) -> pub field {
x
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {
assert(foo(itWorks2).data[0] == itWorks2.data[0] + 1);
}

fn id<I>(x: [Field; I]) -> [Field; I] {
fn id<I>(x: [field; I]) -> [field; I] {
x
}

Expand All @@ -23,7 +23,7 @@ struct MyStruct<S> {
}

impl<S> MyStruct<S> {
fn insert(mut self: Self, index: Field, elem: Field) -> Self {
fn insert(mut self: Self, index: field, elem: field) -> Self {
// Regression test for numeric generics on impls
assert(index as u64 < S as u64);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
regression_2445();
}

fn increment(mut r: &mut Field) {
fn increment(mut r: &mut field) {
*r = *r + 1;
}
// If aliasing within arrays and constant folding within the mem2reg pass aren't
Expand Down
8 changes: 4 additions & 4 deletions test_programs/compile_success_empty/ret_fn_ret_cl/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fn f(x: Field) -> Field {
fn f(x: field) -> field {
x + 1
}

fn ret_fn() -> fn(Field) -> Field {
fn ret_fn() -> fn(field) -> field {
f
}
// TODO: in the advanced implicitly generic function with closures branch
Expand All @@ -16,14 +16,14 @@ fn ret_fn() -> fn(Field) -> Field {
// };
// inner_closure
// }
fn ret_lambda() -> fn(Field) -> Field {
fn ret_lambda() -> fn(field) -> field {
let cl = |z: Field| -> Field {
z + 1
};
cl
}

fn main(x: Field) {
fn main(x: field) {
let result_fn = ret_fn();
assert(result_fn(x) == x + 1);
// let result_closure = ret_closure();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This program tests:
// - the allocation of virtual arrays for array params to main
// - load instructions for such arrays
fn main(xs: [Field; 2]) -> pub Field {
fn main(xs: [field; 2]) -> pub field {
xs[1]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
//
// This program will never fail since there are
// no assertions being applied.
fn main(_x: Field, _y: pub Field) {}
fn main(_x: field, _y: pub field) {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Tests a very simple program.
//
// The features being tested is casting to an integer
fn main(x: Field) {
fn main(x: field) {
let _z = x as u32;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
struct Foo<T> {}

impl Foo<u32> {
fn foo(_self: Self) -> Field {
fn foo(_self: Self) -> field {
1
}
}

impl Foo<u64> {
fn foo(_self: Self) -> Field {
fn foo(_self: Self) -> field {
2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct Struct1 {
}

impl Struct1 {
fn tralala() -> Field {
fn tralala() -> field {
123456
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl MyDefault for Foo {
}
}

fn main(x: Field) {
fn main(x: field) {
let first = Foo::method2(x);
assert(first == x);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ impl Serializable<2> for Data {
}
}

fn sum<T, M>(data: T) -> Field where T: Serializable<M> {
fn sum<T, M>(data: T) -> field where T: Serializable<M> {
let serialized = data.serialize();
serialized.fold(0, |acc, elem| acc + elem)
}

// Test static trait method syntax
fn sum_static<T, M>(data: T) -> Field where T: Serializable<M> {
fn sum_static<T, M>(data: T) -> field where T: Serializable<M> {
let serialized = Serializable::serialize(data);
serialized.fold(0, |acc, elem| acc + elem)
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl F for Bar {
// fn f1(self) -> Field { 101 }
// fn f5(self) -> Field { 505 }
// }
fn main(x: Field) {
fn main(x: field) {
let first = Foo::method2(x);
assert(first == 3 * x);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn assert_asd_eq_100<T>(t: T) where T: crate::the_trait::Asd {
assert(t.asd() == 100);
}

fn add_one_to_static_function<T>(t: T) -> Field where T: StaticTrait {
fn add_one_to_static_function<T>(t: T) -> field where T: StaticTrait {
T::static_function(t) + 1
}

Expand Down
2 changes: 1 addition & 1 deletion test_programs/compile_success_empty/traits/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl MyDefault for Foo {
}
}

fn main(x: Field, y: Field) {
fn main(x: field, y: field) {
let first = Foo::my_default(x, y);
assert(first.bar == x);
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fn main(x: Field, y: pub Field) {}
fn main(x: field, y: pub field) {}
2 changes: 1 addition & 1 deletion test_programs/compile_success_empty/vectors/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::std::collections::vec::Vec;

fn main(x: Field, y: pub Field) {
fn main(x: field, y: pub field) {
let mut vector = Vec::new();

assert(vector.len() == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<T_D> C<T_D> {
C { t_d_interface }
}

fn call_method_of_t_d(self, t_d: T_D) -> Field {
fn call_method_of_t_d(self, t_d: T_D) -> field {
let some_method_on_t_d = self.t_d_interface.some_method_on_t_d;
some_method_on_t_d(t_d)
}
Expand All @@ -45,15 +45,15 @@ struct D {
d: Field,
}

fn d_method(input: D) -> Field {
fn d_method(input: D) -> field {
input.d * input.d
}

fn get_d_method_interface() -> MethodInterface<D> {
MethodInterface { some_method_on_t_d: d_method }
}
// ---
fn main(input: Field) -> pub Field {
fn main(input: field) -> pub field {
let b: B<C<D>> = B::new(new_concrete_c_over_d);
let c: C<D> = b.get_t_c(); // Singleton<Note>
let d: D = D { d: input }; // Note
Expand Down
Loading

0 comments on commit a9f014b

Please sign in to comment.