From 2e7b542b8b24dd3baa28e64e5c6e6e43a9829053 Mon Sep 17 00:00:00 2001 From: howardwu Date: Thu, 4 Mar 2021 11:09:24 -0800 Subject: [PATCH] Format and clean up, enable default on snarkvm_algorithms --- .rustfmt.toml | 2 +- .rusty-hook.toml | 2 +- Cargo.toml | 2 +- asg/src/checks/return_path.rs | 18 +++-- asg/src/const_value.rs | 8 +- asg/src/context.rs | 3 +- asg/src/error/mod.rs | 3 +- asg/src/expression/array_access.rs | 11 +-- asg/src/expression/array_init.rs | 11 +-- asg/src/expression/array_inline.rs | 11 +-- asg/src/expression/array_range_access.rs | 11 +-- asg/src/expression/binary.rs | 14 +--- asg/src/expression/call.rs | 31 ++++---- asg/src/expression/circuit_access.rs | 28 +++---- asg/src/expression/circuit_init.rs | 31 ++++---- asg/src/expression/constant.rs | 26 ++++--- asg/src/expression/mod.rs | 9 +-- asg/src/expression/ternary.rs | 11 +-- asg/src/expression/tuple_access.rs | 11 +-- asg/src/expression/tuple_init.rs | 11 +-- asg/src/expression/unary.rs | 11 +-- asg/src/expression/variable_ref.rs | 30 ++++---- asg/src/import.rs | 5 +- asg/src/input.rs | 7 +- asg/src/lib.rs | 4 +- asg/src/node.rs | 22 +++--- asg/src/prelude.rs | 4 +- asg/src/program/circuit.rs | 8 +- asg/src/program/function.rs | 29 ++++---- asg/src/program/mod.rs | 15 +--- asg/src/reducer/monoidal_director.rs | 4 +- asg/src/reducer/monoidal_reducer.rs | 5 +- asg/src/reducer/visitor.rs | 4 +- asg/src/reducer/visitor_director.rs | 7 +- asg/src/scope.rs | 14 +--- asg/src/statement/assign.rs | 34 +++++---- asg/src/statement/block.rs | 8 +- asg/src/statement/conditional.rs | 11 +-- asg/src/statement/console.rs | 10 +-- asg/src/statement/definition.rs | 32 ++++---- asg/src/statement/expression.rs | 9 +-- asg/src/statement/iteration.rs | 27 +++---- asg/src/statement/mod.rs | 7 +- asg/src/statement/return_.rs | 10 +-- asg/src/variable.rs | 4 +- asg/tests/pass/form_ast.rs | 3 +- asg/tests/pass/import/mod.rs | 5 +- ast/benches/leo_ast.rs | 7 +- ast/src/annotation.rs | 17 ++--- ast/src/circuits/circuit.rs | 6 +- .../circuit_implied_variable_definition.rs | 6 +- ast/src/circuits/circuit_member.rs | 14 ++-- .../circuits/circuit_variable_definition.rs | 6 +- ast/src/common/array_dimensions.rs | 3 +- ast/src/common/identifier.rs | 54 ++++++++------ ast/src/common/input_keyword.rs | 6 +- ast/src/common/mut_self_keyword.rs | 6 +- ast/src/common/positive_number.rs | 3 +- ast/src/common/self_keyword.rs | 6 +- ast/src/common/span.rs | 6 +- ast/src/common/spread_or_expression.rs | 13 ++-- ast/src/errors/deprecated.rs | 9 +-- ast/src/errors/error.rs | 3 +- ast/src/expression/mod.rs | 73 +++++++++--------- ast/src/functions/function.rs | 10 +-- ast/src/functions/input/function_input.rs | 8 +- ast/src/functions/input/input_variable.rs | 10 +-- ast/src/functions/test_function.rs | 6 +- ast/src/groups/group_coordinate.rs | 27 ++++--- ast/src/groups/group_value.rs | 22 +++--- ast/src/imports/import.rs | 6 +- ast/src/imports/import_symbol.rs | 6 +- ast/src/imports/package.rs | 7 +- ast/src/imports/package_access.rs | 8 +- ast/src/imports/package_or_packages.rs | 6 +- ast/src/imports/packages.rs | 7 +- ast/src/input/input.rs | 16 ++-- ast/src/input/input_value.rs | 26 ++----- ast/src/input/parameters/parameter.rs | 4 +- ast/src/input/program_input/main_input.rs | 3 +- ast/src/input/program_input/program_input.rs | 11 ++- ast/src/input/program_input/registers.rs | 6 +- .../private_state/private_state.rs | 10 +-- .../program_state/private_state/record.rs | 6 +- .../program_state/private_state/state_leaf.rs | 6 +- ast/src/input/program_state/program_state.rs | 13 ++-- .../public_state/public_state.rs | 7 +- .../input/program_state/public_state/state.rs | 6 +- ast/src/main.rs | 7 +- ast/src/program.rs | 24 +++--- ast/src/statements/assign/assignee.rs | 17 ++--- ast/src/statements/assign/mod.rs | 7 +- ast/src/statements/block.rs | 7 +- ast/src/statements/conditional.rs | 12 +-- .../statements/console/console_function.rs | 18 ++--- .../statements/console/console_statement.rs | 7 +- .../statements/console/formatted_container.rs | 6 +- .../statements/console/formatted_string.rs | 8 +- ast/src/statements/definition/declare.rs | 3 +- ast/src/statements/definition/mod.rs | 8 +- .../statements/definition/variable_name.rs | 7 +- ast/src/statements/expression.rs | 7 +- ast/src/statements/iteration.rs | 9 +-- ast/src/statements/return_statement.rs | 7 +- ast/src/statements/statement.rs | 7 +- ast/src/types/integer_type.rs | 19 +++-- ast/src/types/type_.rs | 23 +++--- ast/tests/serialization/json.rs | 9 +-- compiler/src/compiler.rs | 41 +++++----- compiler/src/console/assert.rs | 15 ++-- compiler/src/console/console.rs | 8 +- compiler/src/console/format.rs | 4 +- compiler/src/constraints/constraints.rs | 9 +-- compiler/src/definition/definition.rs | 4 +- compiler/src/errors/compiler.rs | 8 +- compiler/src/errors/console.rs | 3 +- compiler/src/errors/expression.rs | 14 +--- compiler/src/errors/function.rs | 23 +++--- compiler/src/errors/import.rs | 5 +- compiler/src/errors/output_bytes.rs | 6 +- compiler/src/errors/output_file.rs | 3 +- compiler/src/errors/statement.rs | 10 +-- compiler/src/errors/value/address.rs | 3 +- compiler/src/errors/value/boolean.rs | 3 +- compiler/src/errors/value/field.rs | 3 +- compiler/src/errors/value/group.rs | 3 +- compiler/src/errors/value/integer.rs | 5 +- compiler/src/errors/value/value.rs | 9 +-- compiler/src/expression/arithmetic/add.rs | 4 +- compiler/src/expression/arithmetic/div.rs | 4 +- compiler/src/expression/arithmetic/mul.rs | 4 +- compiler/src/expression/arithmetic/negate.rs | 4 +- compiler/src/expression/arithmetic/pow.rs | 4 +- compiler/src/expression/arithmetic/sub.rs | 4 +- compiler/src/expression/array/access.rs | 8 +- compiler/src/expression/array/array.rs | 8 +- compiler/src/expression/array/index.rs | 8 +- compiler/src/expression/binary/binary.rs | 5 +- compiler/src/expression/circuit/access.rs | 8 +- compiler/src/expression/circuit/circuit.rs | 15 ++-- .../src/expression/conditional/conditional.rs | 8 +- compiler/src/expression/expression.rs | 27 +++---- .../src/expression/function/core_circuit.rs | 9 +-- compiler/src/expression/function/function.rs | 9 +-- compiler/src/expression/logical/and.rs | 4 +- compiler/src/expression/logical/not.rs | 4 +- compiler/src/expression/logical/or.rs | 4 +- compiler/src/expression/relational/eq.rs | 8 +- compiler/src/expression/relational/ge.rs | 4 +- compiler/src/expression/relational/gt.rs | 4 +- compiler/src/expression/relational/le.rs | 4 +- compiler/src/expression/relational/lt.rs | 4 +- compiler/src/expression/tuple/access.rs | 8 +- compiler/src/expression/tuple/tuple.rs | 5 +- .../expression/variable_ref/variable_ref.rs | 5 +- compiler/src/function/function.rs | 9 +-- compiler/src/function/input/array.rs | 8 +- compiler/src/function/input/input_keyword.rs | 14 +--- compiler/src/function/input/input_section.rs | 14 +--- .../src/function/input/main_function_input.rs | 25 ++++--- compiler/src/function/input/tuple.rs | 8 +- compiler/src/function/main_function.rs | 9 +-- compiler/src/function/mut_target.rs | 30 ++++---- compiler/src/function/result/result.rs | 18 ++--- compiler/src/output/output_bytes.rs | 12 +-- compiler/src/output/output_file.rs | 14 ++-- compiler/src/prelude/blake2s.rs | 19 +++-- compiler/src/prelude/mod.rs | 7 +- compiler/src/program/program.rs | 3 +- compiler/src/statement/assign/assign.rs | 13 +--- compiler/src/statement/assign/assignee.rs | 10 +-- compiler/src/statement/block/block.rs | 5 +- .../src/statement/conditional/conditional.rs | 14 ++-- .../src/statement/definition/definition.rs | 9 +-- compiler/src/statement/iteration/iteration.rs | 17 +++-- compiler/src/statement/return_/return_.rs | 5 +- compiler/src/statement/statement.rs | 5 +- compiler/src/value/address/address.rs | 38 ++++------ compiler/src/value/boolean/input.rs | 13 +--- compiler/src/value/field/field_type.rs | 42 +++++------ compiler/src/value/field/input.rs | 12 +-- compiler/src/value/group/group_type.rs | 23 +++--- compiler/src/value/group/input.rs | 10 +-- .../src/value/group/targets/edwards_bls12.rs | 74 +++++++++---------- compiler/src/value/integer/integer.rs | 36 ++++----- compiler/src/value/integer/macros.rs | 10 +-- compiler/src/value/value.rs | 18 +---- compiler/tests/address/mod.rs | 6 +- compiler/tests/array/mod.rs | 16 ++-- compiler/tests/boolean/mod.rs | 16 ++-- compiler/tests/circuits/mod.rs | 4 +- compiler/tests/compiler/mod.rs | 6 +- compiler/tests/console/mod.rs | 14 ++-- compiler/tests/core/mod.rs | 4 +- .../core/packages/unstable/blake2s/mod.rs | 21 +++--- compiler/tests/definition/mod.rs | 4 +- compiler/tests/function/mod.rs | 6 +- compiler/tests/import/mod.rs | 6 +- .../tests/input_files/program_input/mod.rs | 5 +- .../program_input_and_program_state/mod.rs | 4 +- .../input_files/program_registers/mod.rs | 4 +- .../tests/input_files/program_state/mod.rs | 4 +- compiler/tests/integers/i128/mod.rs | 19 +++-- compiler/tests/integers/i16/mod.rs | 19 +++-- compiler/tests/integers/i32/mod.rs | 19 +++-- compiler/tests/integers/i64/mod.rs | 19 +++-- compiler/tests/integers/i8/mod.rs | 19 +++-- compiler/tests/integers/integer_tester.rs | 9 +-- compiler/tests/integers/u128/mod.rs | 18 ++--- compiler/tests/integers/u16/mod.rs | 18 ++--- compiler/tests/integers/u32/mod.rs | 18 ++--- compiler/tests/integers/u64/mod.rs | 18 ++--- compiler/tests/integers/u8/mod.rs | 18 ++--- compiler/tests/mod.rs | 23 +++--- compiler/tests/mutability/mod.rs | 5 +- compiler/tests/statements/conditional/mod.rs | 18 +++-- compiler/tests/statements/mod.rs | 5 +- compiler/tests/syntax/mod.rs | 4 +- compiler/tests/tuples/mod.rs | 3 +- gadgets/benches/integer_arithmetic.rs | 18 +---- gadgets/src/arithmetic/add.rs | 13 +--- gadgets/src/arithmetic/neg.rs | 3 +- gadgets/src/bits/adder.rs | 3 +- gadgets/src/bits/comparator.rs | 18 ++--- gadgets/src/bits/rca.rs | 9 +-- gadgets/src/signed_integer/arithmetic/add.rs | 34 ++++----- gadgets/src/signed_integer/arithmetic/div.rs | 34 ++++----- gadgets/src/signed_integer/arithmetic/mul.rs | 37 +++++----- gadgets/src/signed_integer/arithmetic/neg.rs | 4 +- gadgets/src/signed_integer/arithmetic/pow.rs | 23 +++--- gadgets/src/signed_integer/arithmetic/sub.rs | 18 ++--- gadgets/src/signed_integer/relational/cmp.rs | 21 +++--- gadgets/src/signed_integer/relational/eq.rs | 13 +--- gadgets/src/signed_integer/utilities/alloc.rs | 20 ++--- gadgets/src/signed_integer/utilities/eq.rs | 6 +- .../src/signed_integer/utilities/select.rs | 14 ++-- gadgets/tests/signed_integer/i128.rs | 13 +--- gadgets/tests/signed_integer/i16.rs | 13 +--- gadgets/tests/signed_integer/i32.rs | 13 +--- gadgets/tests/signed_integer/i64.rs | 13 +--- gadgets/tests/signed_integer/i8.rs | 13 +--- grammar/benches/grammar.rs | 5 +- grammar/src/access/access.rs | 3 +- grammar/src/access/array_access.rs | 4 +- grammar/src/access/assignee_access.rs | 8 +- grammar/src/access/call_access.rs | 4 +- grammar/src/access/member_access.rs | 4 +- grammar/src/access/self_access.rs | 3 +- grammar/src/access/static_member_access.rs | 4 +- grammar/src/access/tuple_access.rs | 4 +- .../src/annotations/annotation_arguments.rs | 7 +- grammar/src/annotations/annotation_name.rs | 3 +- grammar/src/annotations/annotation_symbol.rs | 3 +- grammar/src/annotations/annotations.rs | 10 +-- grammar/src/ast.rs | 46 ++++++------ grammar/src/circuits/circuit.rs | 5 +- .../src/circuits/circuit_implied_variable.rs | 4 +- grammar/src/circuits/circuit_member.rs | 4 +- grammar/src/circuits/circuit_variable.rs | 5 +- .../circuits/circuit_variable_definition.rs | 5 +- grammar/src/common/assignee.rs | 5 +- grammar/src/common/eoi.rs | 3 +- grammar/src/common/identifier.rs | 7 +- grammar/src/common/keyword_or_identifier.rs | 5 +- grammar/src/common/mut_self_keyword.rs | 9 ++- grammar/src/common/range.rs | 4 +- grammar/src/common/range_or_expression.rs | 4 +- grammar/src/common/self_keyword.rs | 7 +- .../src/common/self_keyword_or_identifier.rs | 7 +- grammar/src/common/spread.rs | 4 +- grammar/src/common/spread_or_expression.rs | 4 +- grammar/src/common/variable_name.rs | 9 ++- grammar/src/common/variables.rs | 5 +- grammar/src/console/console_assert.rs | 4 +- grammar/src/console/console_debug.rs | 4 +- grammar/src/console/console_error.rs | 4 +- grammar/src/console/console_function.rs | 9 +-- grammar/src/console/console_function_call.rs | 11 +-- grammar/src/console/console_keyword.rs | 3 +- grammar/src/console/console_log.rs | 4 +- grammar/src/console/formatted_container.rs | 3 +- grammar/src/console/formatted_string.rs | 11 +-- .../src/definitions/annotated_definition.rs | 5 +- grammar/src/definitions/definition.rs | 13 ++-- grammar/src/definitions/deprecated.rs | 3 +- grammar/src/errors/parser.rs | 6 +- .../array_initializer_expression.rs | 5 +- .../expressions/array_inline_expression.rs | 4 +- grammar/src/expressions/binary_expression.rs | 4 +- .../expressions/circuit_inline_expression.rs | 6 +- grammar/src/expressions/expression.rs | 5 +- grammar/src/expressions/postfix_expression.rs | 5 +- .../expressions/self_postfix_expression.rs | 11 +-- grammar/src/expressions/ternary_expression.rs | 4 +- grammar/src/expressions/tuple_expression.rs | 4 +- grammar/src/expressions/unary_expression.rs | 5 +- grammar/src/files/file.rs | 5 +- grammar/src/functions/function.rs | 7 +- grammar/src/functions/input/function_input.rs | 12 +-- grammar/src/functions/input/input.rs | 10 +-- grammar/src/functions/input/input_keyword.rs | 7 +- grammar/src/functions/test_function.rs | 4 +- grammar/src/imports/import.rs | 5 +- grammar/src/imports/import_symbol.rs | 4 +- grammar/src/imports/package.rs | 9 ++- grammar/src/imports/package_access.rs | 9 +-- grammar/src/imports/package_name.rs | 7 +- grammar/src/imports/package_or_packages.rs | 7 +- grammar/src/imports/packages.rs | 9 ++- grammar/src/imports/star.rs | 3 +- grammar/src/lib.rs | 3 +- grammar/src/main.rs | 7 +- grammar/src/span.rs | 3 +- grammar/src/statements/assign_statement.rs | 13 ++-- grammar/src/statements/block.rs | 4 +- .../conditional_nested_or_end_statement.rs | 7 +- .../src/statements/conditional_statement.rs | 11 +-- .../src/statements/definition_statement.rs | 12 +-- .../src/statements/expression_statement.rs | 5 +- grammar/src/statements/for_statement.rs | 6 +- grammar/src/statements/return_statement.rs | 4 +- grammar/src/statements/statement.rs | 4 +- grammar/src/types/array_dimensions.rs | 4 +- grammar/src/types/array_type.rs | 9 ++- grammar/src/types/circuit_type.rs | 4 +- grammar/src/types/data_type.rs | 10 +-- grammar/src/types/integer_type.rs | 7 +- grammar/src/types/self_type.rs | 7 +- grammar/src/types/tuple_type.rs | 4 +- grammar/src/types/type_.rs | 3 +- grammar/src/values/address.rs | 7 +- grammar/src/values/address_value.rs | 5 +- grammar/src/values/boolean_value.rs | 7 +- grammar/src/values/field_value.rs | 5 +- grammar/src/values/group_coordinate.rs | 4 +- grammar/src/values/group_value.rs | 11 +-- grammar/src/values/integer_value.rs | 7 +- grammar/src/values/negative_number.rs | 7 +- grammar/src/values/number_value.rs | 7 +- grammar/src/values/positive_number.rs | 7 +- grammar/src/values/signed_integer_value.rs | 5 +- grammar/src/values/unsigned_integer_value.rs | 5 +- grammar/src/values/value.rs | 11 +-- grammar/tests/annotated.rs | 3 +- grammar/tests/circuits.rs | 3 +- grammar/tests/deprecated.rs | 3 +- grammar/tests/display.rs | 7 +- grammar/tests/expression.rs | 3 +- grammar/tests/function.rs | 3 +- grammar/tests/imports.rs | 3 +- grammar/tests/multiline.rs | 3 +- grammar/tests/self.rs | 3 +- grammar/tests/tuple.rs | 3 +- imports/src/errors/import_parser.rs | 9 +-- imports/src/parser/import_parser.rs | 9 +-- imports/src/parser/parse_package.rs | 12 +-- imports/src/parser/parse_symbol.rs | 6 +- input/src/ast.rs | 5 +- input/src/common/identifier.rs | 3 +- input/src/definitions/definition.rs | 5 +- input/src/errors/parser.rs | 35 ++++----- .../array_initializer_expression.rs | 4 +- .../expressions/array_inline_expression.rs | 3 +- input/src/expressions/expression.rs | 4 +- input/src/expressions/tuple_expression.rs | 3 +- input/src/files/file.rs | 4 +- input/src/files/table_or_section.rs | 4 +- input/src/lib.rs | 3 +- input/src/parameters/parameter.rs | 4 +- input/src/sections/header.rs | 12 ++- input/src/sections/section.rs | 4 +- input/src/tables/table.rs | 4 +- input/src/tables/visibility.rs | 7 +- input/src/types/array_dimensions.rs | 3 +- input/src/types/array_type.rs | 7 +- input/src/types/data_type.rs | 9 +-- input/src/types/integer_type.rs | 7 +- input/src/types/tuple_type.rs | 3 +- input/src/types/type_.rs | 3 +- input/src/values/address.rs | 3 +- input/src/values/address_typed.rs | 4 +- input/src/values/address_value.rs | 7 +- input/src/values/boolean_value.rs | 3 +- input/src/values/field_value.rs | 4 +- input/src/values/group_coordinate.rs | 3 +- input/src/values/group_value.rs | 9 ++- input/src/values/integer_value.rs | 7 +- input/src/values/negative_number.rs | 3 +- input/src/values/number_value.rs | 7 +- input/src/values/positive_number.rs | 3 +- input/src/values/signed_integer_value.rs | 4 +- input/src/values/unsigned_integer_value.rs | 4 +- input/src/values/value.rs | 10 +-- leo/api.rs | 13 ++-- leo/commands/build.rs | 31 +++----- leo/commands/clean.rs | 9 +-- leo/commands/deploy.rs | 3 +- leo/commands/init.rs | 6 +- leo/commands/lint.rs | 3 +- leo/commands/mod.rs | 6 +- leo/commands/new.rs | 9 +-- leo/commands/package/add.rs | 18 ++--- leo/commands/package/clone.rs | 22 +++--- leo/commands/package/login.rs | 14 ++-- leo/commands/package/logout.rs | 4 +- leo/commands/package/publish.rs | 21 +++--- leo/commands/package/remove.rs | 3 +- leo/commands/prove.rs | 14 ++-- leo/commands/run.rs | 12 +-- leo/commands/setup.rs | 29 +++----- leo/commands/test.rs | 28 +++---- leo/commands/update.rs | 8 +- leo/commands/watch.rs | 14 +--- leo/config.rs | 20 ++--- leo/context.rs | 7 +- leo/logger.rs | 14 ++-- leo/main.rs | 38 +++++----- leo/tests/mod.rs | 26 ++++--- leo/updater.rs | 7 +- package/src/errors/imports/directory.rs | 4 +- package/src/errors/inputs/directory.rs | 7 +- package/src/errors/inputs/input.rs | 3 +- package/src/errors/inputs/state.rs | 3 +- package/src/errors/outputs/checksum.rs | 3 +- package/src/errors/outputs/circuit.rs | 3 +- package/src/errors/outputs/directory.rs | 4 +- package/src/errors/outputs/proof.rs | 3 +- package/src/errors/outputs/proving_key.rs | 3 +- .../src/errors/outputs/verification_key.rs | 3 +- package/src/errors/package.rs | 3 +- package/src/errors/root/zip.rs | 3 +- package/src/errors/source/directory.rs | 4 +- package/src/imports/directory.rs | 4 +- package/src/inputs/directory.rs | 11 +-- package/src/inputs/input.rs | 17 +++-- package/src/inputs/pairs.rs | 14 ++-- package/src/inputs/state.rs | 17 +++-- package/src/outputs/checksum.rs | 17 +++-- package/src/outputs/circuit.rs | 17 +++-- package/src/outputs/directory.rs | 4 +- package/src/outputs/proof.rs | 17 +++-- package/src/outputs/proving_key.rs | 17 +++-- package/src/outputs/verification_key.rs | 17 +++-- package/src/package.rs | 18 ++--- package/src/root/gitignore.rs | 5 +- package/src/root/manifest.rs | 16 ++-- package/src/root/readme.rs | 5 +- package/src/root/zip.rs | 48 ++++++------ package/src/source/directory.rs | 9 ++- package/src/source/library.rs | 8 +- package/src/source/main.rs | 8 +- package/tests/initialize/initialize.rs | 14 ++-- package/tests/manifest/manifest.rs | 15 ++-- package/tests/mod.rs | 13 ++-- state/Cargo.toml | 2 +- state/src/errors/dpc_record_values.rs | 3 +- state/src/errors/local_data_commitment.rs | 7 +- state/src/errors/state_leaf_values.rs | 3 +- state/src/errors/state_values.rs | 3 +- .../local_data_commitment.rs | 28 ++++--- .../state_leaf_values.rs | 5 +- .../src/local_data_commitment/state_values.rs | 5 +- .../record_commitment/dpc_record_values.rs | 9 +-- .../record_commitment/record_commitment.rs | 14 ++-- state/src/utilities/input_value.rs | 3 +- .../test_verify_local_data_commitment.rs | 30 ++++---- synthesizer/src/circuit_synthesizer.rs | 7 +- synthesizer/src/serialized_circuit.rs | 14 +--- synthesizer/src/serialized_field.rs | 11 +-- synthesizer/src/serialized_index.rs | 3 +- 470 files changed, 1862 insertions(+), 2849 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index 396becc016..39028b1340 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -10,7 +10,7 @@ use_try_shorthand = true # Nightly configurations imports_layout = "HorizontalVertical" license_template_path = ".resources/license_header" -imports_granularity = "Item" +imports_granularity = "Crate" overflow_delimited_expr = true reorder_impl_items = true version = "Two" diff --git a/.rusty-hook.toml b/.rusty-hook.toml index 21760cec6d..bcdbfd8fa4 100644 --- a/.rusty-hook.toml +++ b/.rusty-hook.toml @@ -1,5 +1,5 @@ [hooks] -#pre-commit = "cargo clippy && cargo +nightly fmt --all -- --check" +pre-commit = "cargo clippy && cargo +nightly fmt --all -- --check" [logging] verbose = true diff --git a/Cargo.toml b/Cargo.toml index 1287459f14..6628e10f2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,7 +73,7 @@ version = "1.2.3" [dependencies.snarkvm-algorithms] version = "0.2.0" -default-features = false +#default-features = false [dependencies.snarkvm-curves] version = "0.2.0" diff --git a/asg/src/checks/return_path.rs b/asg/src/checks/return_path.rs index b2366a17f8..8a21f0514e 100644 --- a/asg/src/checks/return_path.rs +++ b/asg/src/checks/return_path.rs @@ -14,14 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::statement::*; -use crate::BoolAnd; -use crate::Expression; -use crate::Monoid; -use crate::MonoidalReducerExpression; -use crate::MonoidalReducerStatement; -use crate::Node; -use crate::Span; +use crate::{ + statement::*, + BoolAnd, + Expression, + Monoid, + MonoidalReducerExpression, + MonoidalReducerStatement, + Node, + Span, +}; pub struct ReturnPathReducer { pub errors: Vec<(Span, String)>, diff --git a/asg/src/const_value.rs b/asg/src/const_value.rs index fce4e43ad7..bab4aa5b3b 100644 --- a/asg/src/const_value.rs +++ b/asg/src/const_value.rs @@ -14,14 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::IntegerType; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, IntegerType, Span, Type}; use num_bigint::BigInt; -use std::convert::TryInto; -use std::fmt; +use std::{convert::TryInto, fmt}; /// Constant integer values in a program. #[derive(Clone, Debug, PartialEq)] diff --git a/asg/src/context.rs b/asg/src/context.rs index 2a20124f4e..7d27ee10c0 100644 --- a/asg/src/context.rs +++ b/asg/src/context.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::cell::Cell; -use std::unimplemented; +use std::{cell::Cell, unimplemented}; use typed_arena::Arena; diff --git a/asg/src/error/mod.rs b/asg/src/error/mod.rs index 47e7cf761e..39e60735dc 100644 --- a/asg/src/error/mod.rs +++ b/asg/src/error/mod.rs @@ -17,8 +17,7 @@ //! Errors encountered when attempting to convert to an asg from an ast. use crate::Span; -use leo_ast::AstError; -use leo_ast::Error as FormattedError; +use leo_ast::{AstError, Error as FormattedError}; use leo_grammar::ParserError; #[derive(Debug, Error)] diff --git a/asg/src/expression/array_access.rs b/asg/src/expression/array_access.rs index 93a373a354..3bbbd7909d 100644 --- a/asg/src/expression/array_access.rs +++ b/asg/src/expression/array_access.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; use leo_ast::IntegerType; use std::cell::Cell; diff --git a/asg/src/expression/array_init.rs b/asg/src/expression/array_init.rs index 8bc8ee1fcd..063485b4c4 100644 --- a/asg/src/expression/array_init.rs +++ b/asg/src/expression/array_init.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; use std::cell::Cell; diff --git a/asg/src/expression/array_inline.rs b/asg/src/expression/array_inline.rs index 2d6a97fd4b..79f78386fa 100644 --- a/asg/src/expression/array_inline.rs +++ b/asg/src/expression/array_inline.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; use leo_ast::SpreadOrExpression; use std::cell::Cell; diff --git a/asg/src/expression/array_range_access.rs b/asg/src/expression/array_range_access.rs index 1890245176..f070116aa0 100644 --- a/asg/src/expression/array_range_access.rs +++ b/asg/src/expression/array_range_access.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; use leo_ast::IntegerType; use std::cell::Cell; diff --git a/asg/src/expression/binary.rs b/asg/src/expression/binary.rs index 2b3b24f2ae..9322b1d587 100644 --- a/asg/src/expression/binary.rs +++ b/asg/src/expression/binary.rs @@ -14,18 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; -pub use leo_ast::BinaryOperation; -pub use leo_ast::BinaryOperationClass; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; +pub use leo_ast::{BinaryOperation, BinaryOperationClass}; use std::cell::Cell; diff --git a/asg/src/expression/call.rs b/asg/src/expression/call.rs index 0de4cbee3c..52572a4907 100644 --- a/asg/src/expression/call.rs +++ b/asg/src/expression/call.rs @@ -14,21 +14,22 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::CircuitMember; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Function; -use crate::FunctionQualifier; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; -pub use leo_ast::BinaryOperation; -pub use leo_ast::Node as AstNode; +use crate::{ + AsgConvertError, + CircuitMember, + ConstValue, + Expression, + ExpressionNode, + FromAst, + Function, + FunctionQualifier, + Node, + PartialType, + Scope, + Span, + Type, +}; +pub use leo_ast::{BinaryOperation, Node as AstNode}; use std::cell::Cell; diff --git a/asg/src/expression/circuit_access.rs b/asg/src/expression/circuit_access.rs index 63b79671d4..739579cabd 100644 --- a/asg/src/expression/circuit_access.rs +++ b/asg/src/expression/circuit_access.rs @@ -14,19 +14,21 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::Circuit; -use crate::CircuitMember; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Identifier; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{ + AsgConvertError, + Circuit, + CircuitMember, + ConstValue, + Expression, + ExpressionNode, + FromAst, + Identifier, + Node, + PartialType, + Scope, + Span, + Type, +}; use std::cell::Cell; diff --git a/asg/src/expression/circuit_init.rs b/asg/src/expression/circuit_init.rs index 10058661bf..b7ec7a764b 100644 --- a/asg/src/expression/circuit_init.rs +++ b/asg/src/expression/circuit_init.rs @@ -14,22 +14,23 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::Circuit; -use crate::CircuitMember; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Identifier; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{ + AsgConvertError, + Circuit, + CircuitMember, + ConstValue, + Expression, + ExpressionNode, + FromAst, + Identifier, + Node, + PartialType, + Scope, + Span, + Type, +}; -use indexmap::IndexMap; -use indexmap::IndexSet; +use indexmap::{IndexMap, IndexSet}; use std::cell::Cell; #[derive(Clone)] diff --git a/asg/src/expression/constant.rs b/asg/src/expression/constant.rs index 1ab97a0588..ae2a1fdd13 100644 --- a/asg/src/expression/constant.rs +++ b/asg/src/expression/constant.rs @@ -14,18 +14,20 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstInt; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::GroupValue; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{ + AsgConvertError, + ConstInt, + ConstValue, + Expression, + ExpressionNode, + FromAst, + GroupValue, + Node, + PartialType, + Scope, + Span, + Type, +}; use std::cell::Cell; diff --git a/asg/src/expression/mod.rs b/asg/src/expression/mod.rs index 76cb49011f..720bac0781 100644 --- a/asg/src/expression/mod.rs +++ b/asg/src/expression/mod.rs @@ -62,14 +62,7 @@ pub use unary::*; mod variable_ref; pub use variable_ref::*; -use crate::AsgConvertError; -use crate::ConstValue; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, FromAst, Node, PartialType, Scope, Span, Type}; #[derive(Clone)] pub enum Expression<'a> { diff --git a/asg/src/expression/ternary.rs b/asg/src/expression/ternary.rs index 76d7b962e7..93d1a7df0f 100644 --- a/asg/src/expression/ternary.rs +++ b/asg/src/expression/ternary.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; use std::cell::Cell; diff --git a/asg/src/expression/tuple_access.rs b/asg/src/expression/tuple_access.rs index a73f7093f6..4886ff4aa6 100644 --- a/asg/src/expression/tuple_access.rs +++ b/asg/src/expression/tuple_access.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; use std::cell::Cell; diff --git a/asg/src/expression/tuple_init.rs b/asg/src/expression/tuple_init.rs index d2bd923807..195b4fe4af 100644 --- a/asg/src/expression/tuple_init.rs +++ b/asg/src/expression/tuple_init.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; use std::cell::Cell; diff --git a/asg/src/expression/unary.rs b/asg/src/expression/unary.rs index e71f2d3d45..0e5078e71c 100644 --- a/asg/src/expression/unary.rs +++ b/asg/src/expression/unary.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, ConstValue, Expression, ExpressionNode, FromAst, Node, PartialType, Scope, Span, Type}; pub use leo_ast::UnaryOperation; use std::cell::Cell; diff --git a/asg/src/expression/variable_ref.rs b/asg/src/expression/variable_ref.rs index 15f69ee690..d702caa295 100644 --- a/asg/src/expression/variable_ref.rs +++ b/asg/src/expression/variable_ref.rs @@ -14,20 +14,22 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::ConstValue; -use crate::Constant; -use crate::DefinitionStatement; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Type; -use crate::Variable; +use crate::{ + AsgConvertError, + ConstValue, + Constant, + DefinitionStatement, + Expression, + ExpressionNode, + FromAst, + Node, + PartialType, + Scope, + Span, + Statement, + Type, + Variable, +}; use std::cell::Cell; diff --git a/asg/src/import.rs b/asg/src/import.rs index 1b95fc2fdd..4dc3c5ae43 100644 --- a/asg/src/import.rs +++ b/asg/src/import.rs @@ -18,10 +18,7 @@ use std::marker::PhantomData; -use crate::AsgContext; -use crate::AsgConvertError; -use crate::Program; -use crate::Span; +use crate::{AsgContext, AsgConvertError, Program, Span}; use indexmap::IndexMap; diff --git a/asg/src/input.rs b/asg/src/input.rs index ee4b5ea72d..f9af9c2851 100644 --- a/asg/src/input.rs +++ b/asg/src/input.rs @@ -14,12 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Circuit; -use crate::CircuitMember; -use crate::Identifier; -use crate::Scope; -use crate::Type; -use crate::Variable; +use crate::{Circuit, CircuitMember, Identifier, Scope, Type, Variable}; use indexmap::IndexMap; use std::cell::RefCell; diff --git a/asg/src/lib.rs b/asg/src/lib.rs index a611f6929f..ada569edeb 100644 --- a/asg/src/lib.rs +++ b/asg/src/lib.rs @@ -74,9 +74,7 @@ pub use pass::*; pub mod context; pub use context::*; -pub use leo_ast::Ast; -pub use leo_ast::Identifier; -pub use leo_ast::Span; +pub use leo_ast::{Ast, Identifier, Span}; use std::path::Path; diff --git a/asg/src/node.rs b/asg/src/node.rs index ae9ca44a68..58b4b7709e 100644 --- a/asg/src/node.rs +++ b/asg/src/node.rs @@ -14,16 +14,18 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgContextInner; -use crate::AsgConvertError; -use crate::Circuit; -use crate::Expression; -use crate::Function; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Variable; +use crate::{ + AsgContextInner, + AsgConvertError, + Circuit, + Expression, + Function, + PartialType, + Scope, + Span, + Statement, + Variable, +}; /// A node in the abstract semantic graph. pub trait Node { diff --git a/asg/src/prelude.rs b/asg/src/prelude.rs index f8408f5cb9..e977fd137f 100644 --- a/asg/src/prelude.rs +++ b/asg/src/prelude.rs @@ -16,9 +16,7 @@ // TODO (protryon): We should merge this with core -use crate::AsgContext; -use crate::AsgConvertError; -use crate::Program; +use crate::{AsgContext, AsgConvertError, Program}; // TODO (protryon): Make asg deep copy so we can cache resolved core modules // TODO (protryon): Figure out how to do headers without bogus returns diff --git a/asg/src/program/circuit.rs b/asg/src/program/circuit.rs index 05b262bd8b..e44c8b8277 100644 --- a/asg/src/program/circuit.rs +++ b/asg/src/program/circuit.rs @@ -14,13 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::Function; -use crate::Identifier; -use crate::Node; -use crate::Scope; -use crate::Span; -use crate::Type; +use crate::{AsgConvertError, Function, Identifier, Node, Scope, Span, Type}; use indexmap::IndexMap; use std::cell::RefCell; diff --git a/asg/src/program/function.rs b/asg/src/program/function.rs index 1a46063502..159d3ead3b 100644 --- a/asg/src/program/function.rs +++ b/asg/src/program/function.rs @@ -14,23 +14,24 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::BlockStatement; -use crate::Circuit; -use crate::FromAst; -use crate::Identifier; -use crate::MonoidalDirector; -use crate::ReturnPathReducer; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Type; -use crate::Variable; +use crate::{ + AsgConvertError, + BlockStatement, + Circuit, + FromAst, + Identifier, + MonoidalDirector, + ReturnPathReducer, + Scope, + Span, + Statement, + Type, + Variable, +}; use indexmap::IndexMap; use leo_ast::FunctionInput; -use std::cell::Cell; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; #[derive(Clone, Copy, PartialEq)] pub enum FunctionQualifier { diff --git a/asg/src/program/mod.rs b/asg/src/program/mod.rs index 70d3e39889..cccadd08d3 100644 --- a/asg/src/program/mod.rs +++ b/asg/src/program/mod.rs @@ -24,20 +24,11 @@ pub use circuit::*; mod function; pub use function::*; -use crate::ArenaNode; -use crate::AsgContext; -use crate::AsgConvertError; -use crate::ImportResolver; -use crate::Input; -use crate::Scope; -use leo_ast::Identifier; -use leo_ast::PackageAccess; -use leo_ast::PackageOrPackages; -use leo_ast::Span; +use crate::{ArenaNode, AsgContext, AsgConvertError, ImportResolver, Input, Scope}; +use leo_ast::{Identifier, PackageAccess, PackageOrPackages, Span}; use indexmap::IndexMap; -use std::cell::Cell; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; /// Stores the Leo program abstract semantic graph (ASG). #[derive(Clone)] diff --git a/asg/src/reducer/monoidal_director.rs b/asg/src/reducer/monoidal_director.rs index 539363a95d..40a55d4a30 100644 --- a/asg/src/reducer/monoidal_director.rs +++ b/asg/src/reducer/monoidal_director.rs @@ -15,9 +15,7 @@ // along with the Leo library. If not, see . use super::*; -use crate::expression::*; -use crate::program::*; -use crate::statement::*; +use crate::{expression::*, program::*, statement::*}; use std::marker::PhantomData; diff --git a/asg/src/reducer/monoidal_reducer.rs b/asg/src/reducer/monoidal_reducer.rs index a126bc2807..ba7a177f5b 100644 --- a/asg/src/reducer/monoidal_reducer.rs +++ b/asg/src/reducer/monoidal_reducer.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::expression::*; -use crate::program::*; -use crate::statement::*; -use crate::Monoid; +use crate::{expression::*, program::*, statement::*, Monoid}; #[allow(unused_variables)] pub trait MonoidalReducerExpression<'a, T: Monoid> { diff --git a/asg/src/reducer/visitor.rs b/asg/src/reducer/visitor.rs index 220d920c82..415f3ed265 100644 --- a/asg/src/reducer/visitor.rs +++ b/asg/src/reducer/visitor.rs @@ -16,9 +16,7 @@ use std::cell::Cell; -use crate::expression::*; -use crate::program::*; -use crate::statement::*; +use crate::{expression::*, program::*, statement::*}; pub enum VisitResult { VisitChildren, diff --git a/asg/src/reducer/visitor_director.rs b/asg/src/reducer/visitor_director.rs index fd37311d76..4edc95d106 100644 --- a/asg/src/reducer/visitor_director.rs +++ b/asg/src/reducer/visitor_director.rs @@ -15,12 +15,9 @@ // along with the Leo library. If not, see . use super::*; -use crate::expression::*; -use crate::program::*; -use crate::statement::*; +use crate::{expression::*, program::*, statement::*}; -use std::cell::Cell; -use std::marker::PhantomData; +use std::{cell::Cell, marker::PhantomData}; pub struct VisitorDirector<'a, R: ExpressionVisitor<'a>> { visitor: R, diff --git a/asg/src/scope.rs b/asg/src/scope.rs index 7394d8d4c4..c39506c043 100644 --- a/asg/src/scope.rs +++ b/asg/src/scope.rs @@ -14,20 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ArenaNode; -use crate::AsgContext; -use crate::AsgConvertError; -use crate::Circuit; -use crate::Expression; -use crate::Function; -use crate::Input; -use crate::Statement; -use crate::Type; -use crate::Variable; +use crate::{ArenaNode, AsgContext, AsgConvertError, Circuit, Expression, Function, Input, Statement, Type, Variable}; use indexmap::IndexMap; -use std::cell::Cell; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; /// An abstract data type that track the current bindings for variables, functions, and circuits. #[derive(Clone)] diff --git a/asg/src/statement/assign.rs b/asg/src/statement/assign.rs index f00d419cbd..1eda9119ba 100644 --- a/asg/src/statement/assign.rs +++ b/asg/src/statement/assign.rs @@ -14,22 +14,24 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::CircuitMember; -use crate::ConstInt; -use crate::ConstValue; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::Identifier; -use crate::IntegerType; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Type; -use crate::Variable; +use crate::{ + AsgConvertError, + CircuitMember, + ConstInt, + ConstValue, + Expression, + ExpressionNode, + FromAst, + Identifier, + IntegerType, + Node, + PartialType, + Scope, + Span, + Statement, + Type, + Variable, +}; pub use leo_ast::AssignOperation; use leo_ast::AssigneeAccess as AstAssigneeAccess; diff --git a/asg/src/statement/block.rs b/asg/src/statement/block.rs index 70bd668119..9a64fcdfb9 100644 --- a/asg/src/statement/block.rs +++ b/asg/src/statement/block.rs @@ -14,13 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; +use crate::{AsgConvertError, FromAst, Node, PartialType, Scope, Span, Statement}; use std::cell::Cell; diff --git a/asg/src/statement/conditional.rs b/asg/src/statement/conditional.rs index 5d2d4f30ca..6f0b5f09b7 100644 --- a/asg/src/statement/conditional.rs +++ b/asg/src/statement/conditional.rs @@ -14,16 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::BlockStatement; -use crate::Expression; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Type; +use crate::{AsgConvertError, BlockStatement, Expression, FromAst, Node, PartialType, Scope, Span, Statement, Type}; use std::cell::Cell; diff --git a/asg/src/statement/console.rs b/asg/src/statement/console.rs index f72c172f1b..fdcf2858e5 100644 --- a/asg/src/statement/console.rs +++ b/asg/src/statement/console.rs @@ -14,15 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::Expression; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Type; +use crate::{AsgConvertError, Expression, FromAst, Node, PartialType, Scope, Span, Statement, Type}; use leo_ast::ConsoleFunction as AstConsoleFunction; use std::cell::Cell; diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index dab03e9b7a..a779454996 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -14,23 +14,23 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::InnerVariable; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Type; -use crate::Variable; -use leo_ast::AstError; -use leo_ast::DeprecatedError; +use crate::{ + AsgConvertError, + Expression, + ExpressionNode, + FromAst, + InnerVariable, + Node, + PartialType, + Scope, + Span, + Statement, + Type, + Variable, +}; +use leo_ast::{AstError, DeprecatedError}; -use std::cell::Cell; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; #[derive(Clone)] pub struct DefinitionStatement<'a> { diff --git a/asg/src/statement/expression.rs b/asg/src/statement/expression.rs index e533f87bf3..f00c55c488 100644 --- a/asg/src/statement/expression.rs +++ b/asg/src/statement/expression.rs @@ -14,14 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::Expression; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; +use crate::{AsgConvertError, Expression, FromAst, Node, PartialType, Scope, Span, Statement}; use std::cell::Cell; diff --git a/asg/src/statement/iteration.rs b/asg/src/statement/iteration.rs index 1a441befbd..26cfd2ba74 100644 --- a/asg/src/statement/iteration.rs +++ b/asg/src/statement/iteration.rs @@ -16,20 +16,21 @@ use leo_ast::IntegerType; -use crate::AsgConvertError; -use crate::Expression; -use crate::ExpressionNode; -use crate::FromAst; -use crate::InnerVariable; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Variable; +use crate::{ + AsgConvertError, + Expression, + ExpressionNode, + FromAst, + InnerVariable, + Node, + PartialType, + Scope, + Span, + Statement, + Variable, +}; -use std::cell::Cell; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; #[derive(Clone)] pub struct IterationStatement<'a> { diff --git a/asg/src/statement/mod.rs b/asg/src/statement/mod.rs index 7757ba4d33..bc924f2ae1 100644 --- a/asg/src/statement/mod.rs +++ b/asg/src/statement/mod.rs @@ -42,12 +42,7 @@ pub use iteration::*; mod return_; pub use return_::*; -use crate::AsgConvertError; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; +use crate::{AsgConvertError, FromAst, Node, PartialType, Scope, Span}; #[derive(Clone)] pub enum Statement<'a> { diff --git a/asg/src/statement/return_.rs b/asg/src/statement/return_.rs index eccf6f794f..fb6b640390 100644 --- a/asg/src/statement/return_.rs +++ b/asg/src/statement/return_.rs @@ -14,15 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::AsgConvertError; -use crate::Expression; -use crate::FromAst; -use crate::Node; -use crate::PartialType; -use crate::Scope; -use crate::Span; -use crate::Statement; -use crate::Type; +use crate::{AsgConvertError, Expression, FromAst, Node, PartialType, Scope, Span, Statement, Type}; use std::cell::Cell; #[derive(Clone)] diff --git a/asg/src/variable.rs b/asg/src/variable.rs index a38274c3e9..831de1c63f 100644 --- a/asg/src/variable.rs +++ b/asg/src/variable.rs @@ -16,9 +16,7 @@ use std::cell::RefCell; -use crate::Expression; -use crate::Statement; -use crate::Type; +use crate::{Expression, Statement, Type}; use leo_ast::Identifier; /// Specifies how a program variable was declared. diff --git a/asg/tests/pass/form_ast.rs b/asg/tests/pass/form_ast.rs index 471f938310..d49cb8b970 100644 --- a/asg/tests/pass/form_ast.rs +++ b/asg/tests/pass/form_ast.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::load_asg; -use crate::make_test_context; +use crate::{load_asg, make_test_context}; use leo_ast::Ast; use leo_grammar::Grammar; diff --git a/asg/tests/pass/import/mod.rs b/asg/tests/pass/import/mod.rs index 1c6008557e..870e4fe9ee 100644 --- a/asg/tests/pass/import/mod.rs +++ b/asg/tests/pass/import/mod.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::load_asg; -use crate::load_asg_imports; -use crate::make_test_context; -use crate::mocked_resolver; +use crate::{load_asg, load_asg_imports, make_test_context, mocked_resolver}; #[test] fn test_basic() { diff --git a/ast/benches/leo_ast.rs b/ast/benches/leo_ast.rs index 16619f1971..d5420b0543 100644 --- a/ast/benches/leo_ast.rs +++ b/ast/benches/leo_ast.rs @@ -17,11 +17,8 @@ use leo_ast::Ast; use leo_grammar::Grammar; -use criterion::criterion_group; -use criterion::criterion_main; -use criterion::Criterion; -use std::path::Path; -use std::time::Duration; +use criterion::{criterion_group, criterion_main, Criterion}; +use std::{path::Path, time::Duration}; fn ast(ast: &Grammar) -> Ast { Ast::new("leo_tree", &ast).unwrap() diff --git a/ast/src/annotation.rs b/ast/src/annotation.rs index f1c233c935..9ccc5e833d 100644 --- a/ast/src/annotation.rs +++ b/ast/src/annotation.rs @@ -14,18 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Circuit; -use crate::DeprecatedError; -use crate::Function; -use crate::FunctionInput; -use crate::Identifier; -use crate::ImportStatement; -use crate::TestFunction; -use leo_grammar::annotations::Annotation; -use leo_grammar::annotations::AnnotationArguments; -use leo_grammar::annotations::AnnotationName; -use leo_grammar::definitions::AnnotatedDefinition; -use leo_grammar::definitions::Definition; +use crate::{Circuit, DeprecatedError, Function, FunctionInput, Identifier, ImportStatement, TestFunction}; +use leo_grammar::{ + annotations::{Annotation, AnnotationArguments, AnnotationName}, + definitions::{AnnotatedDefinition, Definition}, +}; use std::convert::TryFrom; diff --git a/ast/src/circuits/circuit.rs b/ast/src/circuits/circuit.rs index de9aa0e88e..79c2280cfc 100644 --- a/ast/src/circuits/circuit.rs +++ b/ast/src/circuits/circuit.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::CircuitMember; -use crate::Identifier; +use crate::{CircuitMember, Identifier}; use leo_grammar::circuits::Circuit as GrammarCircuit; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/circuits/circuit_implied_variable_definition.rs b/ast/src/circuits/circuit_implied_variable_definition.rs index f48ae39ceb..963c153bec 100644 --- a/ast/src/circuits/circuit_implied_variable_definition.rs +++ b/ast/src/circuits/circuit_implied_variable_definition.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Identifier; +use crate::{Expression, Identifier}; use leo_grammar::circuits::CircuitImpliedVariable; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct CircuitImpliedVariableDefinition { diff --git a/ast/src/circuits/circuit_member.rs b/ast/src/circuits/circuit_member.rs index 8661b825be..29b5777587 100644 --- a/ast/src/circuits/circuit_member.rs +++ b/ast/src/circuits/circuit_member.rs @@ -14,15 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Function; -use crate::Identifier; -use crate::Type; -use leo_grammar::circuits::CircuitMember as GrammarCircuitMember; -use leo_grammar::circuits::CircuitVariableDefinition as GrammarCircuitVariableDefinition; -use leo_grammar::functions::Function as GrammarFunction; +use crate::{Function, Identifier, Type}; +use leo_grammar::{ + circuits::{CircuitMember as GrammarCircuitMember, CircuitVariableDefinition as GrammarCircuitVariableDefinition}, + functions::Function as GrammarFunction, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/circuits/circuit_variable_definition.rs b/ast/src/circuits/circuit_variable_definition.rs index f553161a3c..6cd3484f88 100644 --- a/ast/src/circuits/circuit_variable_definition.rs +++ b/ast/src/circuits/circuit_variable_definition.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Identifier; +use crate::{Expression, Identifier}; use leo_grammar::circuits::CircuitVariable; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct CircuitVariableDefinition { diff --git a/ast/src/common/array_dimensions.rs b/ast/src/common/array_dimensions.rs index 1aa523bf68..a401475200 100644 --- a/ast/src/common/array_dimensions.rs +++ b/ast/src/common/array_dimensions.rs @@ -18,8 +18,7 @@ use crate::PositiveNumber; use leo_grammar::types::ArrayDimensions as GrammarArrayDimensions; use leo_input::types::ArrayDimensions as InputArrayDimensions; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// A vector of positive numbers that represent array dimensions. diff --git a/ast/src/common/identifier.rs b/ast/src/common/identifier.rs index 6d5bb779d8..cc9c544e99 100644 --- a/ast/src/common/identifier.rs +++ b/ast/src/common/identifier.rs @@ -14,33 +14,39 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputKeyword; -use crate::MutSelfKeyword; -use crate::SelfKeyword; -use crate::Span; -use leo_grammar::annotations::AnnotationArgument; -use leo_grammar::common::Identifier as GrammarIdentifier; -use leo_grammar::common::KeywordOrIdentifier; -use leo_grammar::common::MutSelfKeyword as GrammarMutSelfKeyword; -use leo_grammar::common::SelfKeyword as GrammarSelfKeyword; -use leo_grammar::common::SelfKeywordOrIdentifier; -use leo_grammar::expressions::CircuitName; -use leo_grammar::functions::InputKeyword as GrammarInputKeyword; -use leo_grammar::imports::PackageName as GrammarPackageName; -use leo_grammar::types::SelfType; +use crate::{InputKeyword, MutSelfKeyword, SelfKeyword, Span}; +use leo_grammar::{ + annotations::AnnotationArgument, + common::{ + Identifier as GrammarIdentifier, + KeywordOrIdentifier, + MutSelfKeyword as GrammarMutSelfKeyword, + SelfKeyword as GrammarSelfKeyword, + SelfKeywordOrIdentifier, + }, + expressions::CircuitName, + functions::InputKeyword as GrammarInputKeyword, + imports::PackageName as GrammarPackageName, + types::SelfType, +}; use leo_input::common::Identifier as InputIdentifier; use crate::Node; -use serde::de::Visitor; -use serde::de::{self}; -use serde::Deserialize; -use serde::Deserializer; -use serde::Serialize; -use serde::Serializer; -use std::collections::BTreeMap; -use std::fmt; -use std::hash::Hash; -use std::hash::Hasher; +use serde::{ + de::{ + Visitor, + {self}, + }, + Deserialize, + Deserializer, + Serialize, + Serializer, +}; +use std::{ + collections::BTreeMap, + fmt, + hash::{Hash, Hasher}, +}; /// An identifier in the constrained program. /// diff --git a/ast/src/common/input_keyword.rs b/ast/src/common/input_keyword.rs index 987237ff94..a6dd0d5e74 100644 --- a/ast/src/common/input_keyword.rs +++ b/ast/src/common/input_keyword.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Node; -use crate::Span; +use crate::{Node, Span}; use leo_grammar::functions::InputKeyword as GrammarInputKeyword; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// The `input` keyword can view program register, record, and state values. diff --git a/ast/src/common/mut_self_keyword.rs b/ast/src/common/mut_self_keyword.rs index a65fa16bdb..0d4bf62168 100644 --- a/ast/src/common/mut_self_keyword.rs +++ b/ast/src/common/mut_self_keyword.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Node; -use crate::Span; +use crate::{Node, Span}; use leo_grammar::common::MutSelfKeyword as GrammarMutSelfKeyword; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// The `mut self` keyword can view and modify circuit values inside of a circuit function. diff --git a/ast/src/common/positive_number.rs b/ast/src/common/positive_number.rs index d7223c6cdb..667727b1b5 100644 --- a/ast/src/common/positive_number.rs +++ b/ast/src/common/positive_number.rs @@ -17,8 +17,7 @@ use leo_grammar::values::PositiveNumber as GrammarPositiveNumber; use leo_input::values::PositiveNumber as InputPositiveNumber; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// A number string guaranteed to be positive by the pest grammar. diff --git a/ast/src/common/self_keyword.rs b/ast/src/common/self_keyword.rs index d491c5fd95..caa9e1b7f6 100644 --- a/ast/src/common/self_keyword.rs +++ b/ast/src/common/self_keyword.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Node; -use crate::Span; +use crate::{Node, Span}; use leo_grammar::common::SelfKeyword as GrammarSelfKeyword; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// The `self` keyword can view circuit values inside of a circuit function. diff --git a/ast/src/common/span.rs b/ast/src/common/span.rs index ff2ff0f795..e6e7a70388 100644 --- a/ast/src/common/span.rs +++ b/ast/src/common/span.rs @@ -15,10 +15,8 @@ // along with the Leo library. If not, see . use pest::Span as GrammarSpan; -use serde::Deserialize; -use serde::Serialize; -use std::hash::Hash; -use std::hash::Hasher; +use serde::{Deserialize, Serialize}; +use std::hash::{Hash, Hasher}; #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct Span { diff --git a/ast/src/common/spread_or_expression.rs b/ast/src/common/spread_or_expression.rs index 345ed83bfd..78f940a5af 100644 --- a/ast/src/common/spread_or_expression.rs +++ b/ast/src/common/spread_or_expression.rs @@ -14,14 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Node; -use crate::Span; -use leo_grammar::common::SpreadOrExpression as GrammarSpreadOrExpression; -use leo_grammar::expressions::Expression as GrammarExpression; +use crate::{Expression, Node, Span}; +use leo_grammar::{ + common::SpreadOrExpression as GrammarSpreadOrExpression, + expressions::Expression as GrammarExpression, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// Spread or expression diff --git a/ast/src/errors/deprecated.rs b/ast/src/errors/deprecated.rs index 65ae83a9d5..c22419d3ee 100644 --- a/ast/src/errors/deprecated.rs +++ b/ast/src/errors/deprecated.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Error as FormattedError; -use crate::Span; -use leo_grammar::annotations::AnnotationName; -use leo_grammar::definitions::Deprecated; +use crate::{Error as FormattedError, Span}; +use leo_grammar::{annotations::AnnotationName, definitions::Deprecated}; -use std::convert::TryFrom; -use std::path::Path; +use std::{convert::TryFrom, path::Path}; #[derive(Debug, Error)] pub enum DeprecatedError { diff --git a/ast/src/errors/error.rs b/ast/src/errors/error.rs index c0fbfce73d..103b0ea9cb 100644 --- a/ast/src/errors/error.rs +++ b/ast/src/errors/error.rs @@ -16,8 +16,7 @@ use crate::Span; -use std::fmt; -use std::path::Path; +use std::{fmt, path::Path}; pub const INDENT: &str = " "; diff --git a/ast/src/expression/mod.rs b/ast/src/expression/mod.rs index 629a77b9a2..fb4050f1f2 100644 --- a/ast/src/expression/mod.rs +++ b/ast/src/expression/mod.rs @@ -14,43 +14,44 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ArrayDimensions; -use crate::CircuitImpliedVariableDefinition; -use crate::GroupValue; -use crate::Identifier; -use crate::IntegerType; -use crate::PositiveNumber; -use crate::Span; -use crate::SpreadOrExpression; -use leo_grammar::access::Access; -use leo_grammar::access::AssigneeAccess; -use leo_grammar::access::SelfAccess; -use leo_grammar::common::Assignee; -use leo_grammar::common::Identifier as GrammarIdentifier; -use leo_grammar::common::RangeOrExpression as GrammarRangeOrExpression; -use leo_grammar::expressions::ArrayInitializerExpression; -use leo_grammar::expressions::ArrayInlineExpression as GrammarArrayInlineExpression; -use leo_grammar::expressions::BinaryExpression as GrammarBinaryExpression; -use leo_grammar::expressions::CircuitInlineExpression; -use leo_grammar::expressions::Expression as GrammarExpression; -use leo_grammar::expressions::PostfixExpression; -use leo_grammar::expressions::SelfPostfixExpression; -use leo_grammar::expressions::TernaryExpression as GrammarTernaryExpression; -use leo_grammar::expressions::UnaryExpression as GrammarUnaryExpression; -use leo_grammar::operations::BinaryOperation as GrammarBinaryOperation; -use leo_grammar::operations::UnaryOperation as GrammarUnaryOperation; -use leo_grammar::values::AddressValue; -use leo_grammar::values::BooleanValue; -use leo_grammar::values::FieldValue; -use leo_grammar::values::GroupValue as GrammarGroupValue; -use leo_grammar::values::IntegerValue; -use leo_grammar::values::NumberValue as GrammarNumber; -use leo_grammar::values::Value; +use crate::{ + ArrayDimensions, + CircuitImpliedVariableDefinition, + GroupValue, + Identifier, + IntegerType, + PositiveNumber, + Span, + SpreadOrExpression, +}; +use leo_grammar::{ + access::{Access, AssigneeAccess, SelfAccess}, + common::{Assignee, Identifier as GrammarIdentifier, RangeOrExpression as GrammarRangeOrExpression}, + expressions::{ + ArrayInitializerExpression, + ArrayInlineExpression as GrammarArrayInlineExpression, + BinaryExpression as GrammarBinaryExpression, + CircuitInlineExpression, + Expression as GrammarExpression, + PostfixExpression, + SelfPostfixExpression, + TernaryExpression as GrammarTernaryExpression, + UnaryExpression as GrammarUnaryExpression, + }, + operations::{BinaryOperation as GrammarBinaryOperation, UnaryOperation as GrammarUnaryOperation}, + values::{ + AddressValue, + BooleanValue, + FieldValue, + GroupValue as GrammarGroupValue, + IntegerValue, + NumberValue as GrammarNumber, + Value, + }, +}; -use leo_grammar::access::TupleAccess; -use leo_grammar::expressions::TupleExpression; -use serde::Deserialize; -use serde::Serialize; +use leo_grammar::{access::TupleAccess, expressions::TupleExpression}; +use serde::{Deserialize, Serialize}; use std::fmt; use crate::Node; diff --git a/ast/src/functions/function.rs b/ast/src/functions/function.rs index 65b05a09cc..e9cea0c8c3 100644 --- a/ast/src/functions/function.rs +++ b/ast/src/functions/function.rs @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Block; -use crate::FunctionInput; -use crate::Identifier; -use crate::Node; -use crate::Span; -use crate::Type; +use crate::{Block, FunctionInput, Identifier, Node, Span, Type}; use leo_grammar::functions::Function as GrammarFunction; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Serialize, Deserialize)] diff --git a/ast/src/functions/input/function_input.rs b/ast/src/functions/input/function_input.rs index f0c30b14d8..8cece828ad 100644 --- a/ast/src/functions/input/function_input.rs +++ b/ast/src/functions/input/function_input.rs @@ -14,14 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Identifier; -use crate::Node; -use crate::Span; -use crate::Type; +use crate::{Identifier, Node, Span, Type}; use leo_grammar::functions::FunctionInput as GrammarFunctionInput; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/functions/input/input_variable.rs b/ast/src/functions/input/input_variable.rs index 4acef0e2c5..ecab44a959 100644 --- a/ast/src/functions/input/input_variable.rs +++ b/ast/src/functions/input/input_variable.rs @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::FunctionInputVariable; -use crate::InputKeyword; -use crate::MutSelfKeyword; -use crate::Node; -use crate::SelfKeyword; -use crate::Span; +use crate::{FunctionInputVariable, InputKeyword, MutSelfKeyword, Node, SelfKeyword, Span}; use leo_grammar::functions::input::Input as GrammarInput; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// Enumerates the possible inputs to a function. diff --git a/ast/src/functions/test_function.rs b/ast/src/functions/test_function.rs index b349094c46..eb9f09a346 100644 --- a/ast/src/functions/test_function.rs +++ b/ast/src/functions/test_function.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Function; -use crate::Identifier; +use crate::{Function, Identifier}; use leo_grammar::functions::TestFunction as GrammarTestFunction; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct TestFunction { diff --git a/ast/src/groups/group_coordinate.rs b/ast/src/groups/group_coordinate.rs index 675337a5d2..fd201856dd 100644 --- a/ast/src/groups/group_coordinate.rs +++ b/ast/src/groups/group_coordinate.rs @@ -15,19 +15,22 @@ // along with the Leo library. If not, see . use crate::common::span::Span; -use leo_grammar::values::GroupCoordinate as GrammarGroupCoordinate; -use leo_grammar::values::Inferred as GrammarInferred; -use leo_grammar::values::NumberValue as GrammarNumberValue; -use leo_grammar::values::SignHigh as GrammarSignHigh; -use leo_grammar::values::SignLow as GrammarSignLow; -use leo_input::values::GroupCoordinate as InputGroupCoordinate; -use leo_input::values::Inferred as InputInferred; -use leo_input::values::NumberValue as InputNumberValue; -use leo_input::values::SignHigh as InputSignHigh; -use leo_input::values::SignLow as InputSignLow; +use leo_grammar::values::{ + GroupCoordinate as GrammarGroupCoordinate, + Inferred as GrammarInferred, + NumberValue as GrammarNumberValue, + SignHigh as GrammarSignHigh, + SignLow as GrammarSignLow, +}; +use leo_input::values::{ + GroupCoordinate as InputGroupCoordinate, + Inferred as InputInferred, + NumberValue as InputNumberValue, + SignHigh as InputSignHigh, + SignLow as InputSignLow, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/groups/group_value.rs b/ast/src/groups/group_value.rs index 32872fb32d..5e0c42113e 100644 --- a/ast/src/groups/group_value.rs +++ b/ast/src/groups/group_value.rs @@ -14,17 +14,19 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::common::span::Span; -use crate::groups::GroupCoordinate; -use leo_grammar::values::GroupRepresentation as GrammarGroupRepresentation; -use leo_grammar::values::GroupTuple as GrammarGroupTuple; -use leo_grammar::values::GroupValue as GrammarGroupValue; -use leo_input::values::GroupRepresentation as InputGroupRepresentation; -use leo_input::values::GroupTuple as InputGroupTuple; -use leo_input::values::GroupValue as InputGroupValue; +use crate::{common::span::Span, groups::GroupCoordinate}; +use leo_grammar::values::{ + GroupRepresentation as GrammarGroupRepresentation, + GroupTuple as GrammarGroupTuple, + GroupValue as GrammarGroupValue, +}; +use leo_input::values::{ + GroupRepresentation as InputGroupRepresentation, + GroupTuple as InputGroupTuple, + GroupValue as InputGroupValue, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/imports/import.rs b/ast/src/imports/import.rs index 8e0d02770f..246f61c3b1 100644 --- a/ast/src/imports/import.rs +++ b/ast/src/imports/import.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::PackageOrPackages; -use crate::Span; +use crate::{PackageOrPackages, Span}; use leo_grammar::imports::Import as GrammarImport; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// Represents an import statement in a Leo program. diff --git a/ast/src/imports/import_symbol.rs b/ast/src/imports/import_symbol.rs index c447624023..20d8650793 100644 --- a/ast/src/imports/import_symbol.rs +++ b/ast/src/imports/import_symbol.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Identifier; -use crate::Span; +use crate::{Identifier, Span}; use leo_grammar::imports::ImportSymbol as GrammarImportSymbol; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] diff --git a/ast/src/imports/package.rs b/ast/src/imports/package.rs index fec57b1fa3..091e72142d 100644 --- a/ast/src/imports/package.rs +++ b/ast/src/imports/package.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::common::Identifier; -use crate::PackageAccess; -use crate::Span; +use crate::{common::Identifier, PackageAccess, Span}; use leo_grammar::imports::Package as GrammarPackage; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] diff --git a/ast/src/imports/package_access.rs b/ast/src/imports/package_access.rs index ade92faed3..b329cc6b82 100644 --- a/ast/src/imports/package_access.rs +++ b/ast/src/imports/package_access.rs @@ -14,14 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ImportSymbol; -use crate::Package; -use crate::Packages; -use crate::Span; +use crate::{ImportSymbol, Package, Packages, Span}; use leo_grammar::imports::PackageAccess as GrammarPackageAccess; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] diff --git a/ast/src/imports/package_or_packages.rs b/ast/src/imports/package_or_packages.rs index 0be227fd26..2f1b9bc717 100644 --- a/ast/src/imports/package_or_packages.rs +++ b/ast/src/imports/package_or_packages.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Package; -use crate::Packages; +use crate::{Package, Packages}; use leo_grammar::imports::PackageOrPackages as GrammarPackageOrPackages; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] diff --git a/ast/src/imports/packages.rs b/ast/src/imports/packages.rs index 420c401ef7..fab9542716 100644 --- a/ast/src/imports/packages.rs +++ b/ast/src/imports/packages.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::common::Identifier; -use crate::PackageAccess; -use crate::Span; +use crate::{common::Identifier, PackageAccess, Span}; use leo_grammar::imports::Packages as GrammarPackages; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Eq, Hash, PartialEq, Serialize, Deserialize)] diff --git a/ast/src/input/input.rs b/ast/src/input/input.rs index a72577dc3a..ae201c2aec 100644 --- a/ast/src/input/input.rs +++ b/ast/src/input/input.rs @@ -14,17 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputValue; -use crate::MainInput; -use crate::ProgramInput; -use crate::ProgramState; -use crate::Record; -use crate::Registers; -use crate::State; -use crate::StateLeaf; -use leo_input::files::File; -use leo_input::files::TableOrSection; -use leo_input::InputParserError; +use crate::{InputValue, MainInput, ProgramInput, ProgramState, Record, Registers, State, StateLeaf}; +use leo_input::{ + files::{File, TableOrSection}, + InputParserError, +}; #[derive(Clone, PartialEq, Eq)] pub struct Input { diff --git a/ast/src/input/input_value.rs b/ast/src/input/input_value.rs index ffbd5ce4e4..5d6fba2a9e 100644 --- a/ast/src/input/input_value.rs +++ b/ast/src/input/input_value.rs @@ -14,25 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ArrayDimensions; -use crate::GroupValue; -use leo_input::errors::InputParserError; -use leo_input::expressions::ArrayInitializerExpression; -use leo_input::expressions::ArrayInlineExpression; -use leo_input::expressions::Expression; -use leo_input::expressions::TupleExpression; -use leo_input::types::ArrayType; -use leo_input::types::DataType; -use leo_input::types::IntegerType; -use leo_input::types::TupleType; -use leo_input::types::Type; -use leo_input::values::Address; -use leo_input::values::AddressValue; -use leo_input::values::BooleanValue; -use leo_input::values::FieldValue; -use leo_input::values::GroupValue as InputGroupValue; -use leo_input::values::NumberValue; -use leo_input::values::Value; +use crate::{ArrayDimensions, GroupValue}; +use leo_input::{ + errors::InputParserError, + expressions::{ArrayInitializerExpression, ArrayInlineExpression, Expression, TupleExpression}, + types::{ArrayType, DataType, IntegerType, TupleType, Type}, + values::{Address, AddressValue, BooleanValue, FieldValue, GroupValue as InputGroupValue, NumberValue, Value}, +}; use pest::Span; use std::fmt; diff --git a/ast/src/input/parameters/parameter.rs b/ast/src/input/parameters/parameter.rs index 4031d57795..7f275f2fea 100644 --- a/ast/src/input/parameters/parameter.rs +++ b/ast/src/input/parameters/parameter.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Identifier; -use crate::Span; -use crate::Type; +use crate::{Identifier, Span, Type}; use leo_input::parameters::Parameter as GrammarParameter; #[derive(Clone, PartialEq, Eq, Hash)] diff --git a/ast/src/input/program_input/main_input.rs b/ast/src/input/program_input/main_input.rs index 5683d3f161..7d1b496134 100644 --- a/ast/src/input/program_input/main_input.rs +++ b/ast/src/input/program_input/main_input.rs @@ -15,8 +15,7 @@ // along with the Leo library. If not, see . use crate::InputValue; -use leo_input::definitions::Definition; -use leo_input::InputParserError; +use leo_input::{definitions::Definition, InputParserError}; use indexmap::IndexMap; diff --git a/ast/src/input/program_input/program_input.rs b/ast/src/input/program_input/program_input.rs index 17e933f211..42efab1a25 100644 --- a/ast/src/input/program_input/program_input.rs +++ b/ast/src/input/program_input/program_input.rs @@ -14,12 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputValue; -use crate::MainInput; -use crate::Registers; -use leo_input::sections::Header; -use leo_input::sections::Section; -use leo_input::InputParserError; +use crate::{InputValue, MainInput, Registers}; +use leo_input::{ + sections::{Header, Section}, + InputParserError, +}; #[derive(Clone, PartialEq, Eq, Default)] pub struct ProgramInput { diff --git a/ast/src/input/program_input/registers.rs b/ast/src/input/program_input/registers.rs index 5478e5df3a..21e25030e3 100644 --- a/ast/src/input/program_input/registers.rs +++ b/ast/src/input/program_input/registers.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputValue; -use crate::Parameter; -use leo_input::definitions::Definition; -use leo_input::InputParserError; +use crate::{InputValue, Parameter}; +use leo_input::{definitions::Definition, InputParserError}; use indexmap::IndexMap; diff --git a/ast/src/input/program_state/private_state/private_state.rs b/ast/src/input/program_state/private_state/private_state.rs index 895674d711..f7f1f9edc9 100644 --- a/ast/src/input/program_state/private_state/private_state.rs +++ b/ast/src/input/program_state/private_state/private_state.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Record; -use crate::StateLeaf; -use leo_input::sections::Header; -use leo_input::sections::Section; -use leo_input::InputParserError; +use crate::{Record, StateLeaf}; +use leo_input::{ + sections::{Header, Section}, + InputParserError, +}; #[derive(Clone, PartialEq, Eq, Default)] pub struct PrivateState { diff --git a/ast/src/input/program_state/private_state/record.rs b/ast/src/input/program_state/private_state/record.rs index 7439c57bd5..4cb71920aa 100644 --- a/ast/src/input/program_state/private_state/record.rs +++ b/ast/src/input/program_state/private_state/record.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputValue; -use crate::Parameter; -use leo_input::definitions::Definition; -use leo_input::InputParserError; +use crate::{InputValue, Parameter}; +use leo_input::{definitions::Definition, InputParserError}; use indexmap::IndexMap; diff --git a/ast/src/input/program_state/private_state/state_leaf.rs b/ast/src/input/program_state/private_state/state_leaf.rs index 138d053b34..8e9b0e231b 100644 --- a/ast/src/input/program_state/private_state/state_leaf.rs +++ b/ast/src/input/program_state/private_state/state_leaf.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputValue; -use crate::Parameter; -use leo_input::definitions::Definition; -use leo_input::InputParserError; +use crate::{InputValue, Parameter}; +use leo_input::{definitions::Definition, InputParserError}; use indexmap::IndexMap; diff --git a/ast/src/input/program_state/program_state.rs b/ast/src/input/program_state/program_state.rs index 693c88fdc5..04275d176c 100644 --- a/ast/src/input/program_state/program_state.rs +++ b/ast/src/input/program_state/program_state.rs @@ -14,14 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::PrivateState; -use crate::PublicState; -use crate::Record; -use crate::State; -use crate::StateLeaf; -use leo_input::tables::Table; -use leo_input::tables::Visibility; -use leo_input::InputParserError; +use crate::{PrivateState, PublicState, Record, State, StateLeaf}; +use leo_input::{ + tables::{Table, Visibility}, + InputParserError, +}; #[derive(Clone, PartialEq, Eq, Default)] pub struct ProgramState { diff --git a/ast/src/input/program_state/public_state/public_state.rs b/ast/src/input/program_state/public_state/public_state.rs index 7fe4acd2a2..995aa06759 100644 --- a/ast/src/input/program_state/public_state/public_state.rs +++ b/ast/src/input/program_state/public_state/public_state.rs @@ -15,9 +15,10 @@ // along with the Leo library. If not, see . use crate::State; -use leo_input::sections::Header; -use leo_input::sections::Section; -use leo_input::InputParserError; +use leo_input::{ + sections::{Header, Section}, + InputParserError, +}; #[derive(Clone, PartialEq, Eq, Default)] pub struct PublicState { diff --git a/ast/src/input/program_state/public_state/state.rs b/ast/src/input/program_state/public_state/state.rs index 04d32b6db2..dda85ddf94 100644 --- a/ast/src/input/program_state/public_state/state.rs +++ b/ast/src/input/program_state/public_state/state.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputValue; -use crate::Parameter; -use leo_input::definitions::Definition; -use leo_input::InputParserError; +use crate::{InputValue, Parameter}; +use leo_input::{definitions::Definition, InputParserError}; use indexmap::IndexMap; diff --git a/ast/src/main.rs b/ast/src/main.rs index 19f34a4e50..02f627cc4a 100644 --- a/ast/src/main.rs +++ b/ast/src/main.rs @@ -14,12 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Ast; -use leo_ast::AstError; +use leo_ast::{Ast, AstError}; use leo_grammar::Grammar; -use std::env; -use std::fs; -use std::path::Path; +use std::{env, fs, path::Path}; fn to_leo_tree(filepath: &Path) -> Result { // Loads the Leo code as a string from the given file path. diff --git a/ast/src/program.rs b/ast/src/program.rs index 9a669f25f0..531a6316bb 100644 --- a/ast/src/program.rs +++ b/ast/src/program.rs @@ -17,20 +17,20 @@ //! A Leo program consists of import, circuit, and function definitions. //! Each defined type consists of ast statements and expressions. -use crate::load_annotation; -use crate::Circuit; -use crate::DeprecatedError; -use crate::Function; -use crate::FunctionInput; -use crate::Identifier; -use crate::ImportStatement; -use crate::TestFunction; -use leo_grammar::definitions::Definition; -use leo_grammar::files::File; +use crate::{ + load_annotation, + Circuit, + DeprecatedError, + Function, + FunctionInput, + Identifier, + ImportStatement, + TestFunction, +}; +use leo_grammar::{definitions::Definition, files::File}; use indexmap::IndexMap; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// Stores the Leo program abstract syntax tree. diff --git a/ast/src/statements/assign/assignee.rs b/ast/src/statements/assign/assignee.rs index 98dae1a57e..e84cccf2a9 100644 --- a/ast/src/statements/assign/assignee.rs +++ b/ast/src/statements/assign/assignee.rs @@ -14,18 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Identifier; -use crate::PositiveNumber; -use crate::Span; -use leo_grammar::access::ArrayAccess; -use leo_grammar::access::AssigneeAccess as GrammarAssigneeAccess; -use leo_grammar::common::Assignee as GrammarAssignee; -use leo_grammar::common::Range; -use leo_grammar::common::RangeOrExpression; +use crate::{Expression, Identifier, PositiveNumber, Span}; +use leo_grammar::{ + access::{ArrayAccess, AssigneeAccess as GrammarAssigneeAccess}, + common::{Assignee as GrammarAssignee, Range, RangeOrExpression}, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/statements/assign/mod.rs b/ast/src/statements/assign/mod.rs index fa729749d8..947472d14c 100644 --- a/ast/src/statements/assign/mod.rs +++ b/ast/src/statements/assign/mod.rs @@ -14,14 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Node; -use crate::Span; +use crate::{Expression, Node, Span}; pub use leo_grammar::operations::AssignOperation as GrammarAssignOperation; use leo_grammar::statements::AssignStatement as GrammarAssignStatement; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; mod assignee; diff --git a/ast/src/statements/block.rs b/ast/src/statements/block.rs index db0ccc8028..d6cb72f26f 100644 --- a/ast/src/statements/block.rs +++ b/ast/src/statements/block.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Node; -use crate::Span; -use crate::Statement; +use crate::{Node, Span, Statement}; use leo_grammar::statements::Block as GrammarBlock; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/ast/src/statements/conditional.rs b/ast/src/statements/conditional.rs index 7ea09f39e3..cf836ef3ed 100644 --- a/ast/src/statements/conditional.rs +++ b/ast/src/statements/conditional.rs @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Block; -use crate::Expression; -use crate::Node; -use crate::Span; -use crate::Statement; -use leo_grammar::statements::ConditionalNestedOrEndStatement; -use leo_grammar::statements::ConditionalStatement as GrammarConditionalStatement; +use crate::{Block, Expression, Node, Span, Statement}; +use leo_grammar::statements::{ConditionalNestedOrEndStatement, ConditionalStatement as GrammarConditionalStatement}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/ast/src/statements/console/console_function.rs b/ast/src/statements/console/console_function.rs index 6bbad1da57..7e9f9892ca 100644 --- a/ast/src/statements/console/console_function.rs +++ b/ast/src/statements/console/console_function.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::FormattedString; -use leo_grammar::console::ConsoleAssert as GrammarConsoleAssert; -use leo_grammar::console::ConsoleDebug as GrammarConsoleDebug; -use leo_grammar::console::ConsoleError as GrammarConsoleError; -use leo_grammar::console::ConsoleFunction as GrammarConsoleFunction; -use leo_grammar::console::ConsoleLog as GrammarConsoleLog; +use crate::{Expression, FormattedString}; +use leo_grammar::console::{ + ConsoleAssert as GrammarConsoleAssert, + ConsoleDebug as GrammarConsoleDebug, + ConsoleError as GrammarConsoleError, + ConsoleFunction as GrammarConsoleFunction, + ConsoleLog as GrammarConsoleLog, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/statements/console/console_statement.rs b/ast/src/statements/console/console_statement.rs index d51b4d8670..ad837f42f5 100644 --- a/ast/src/statements/console/console_statement.rs +++ b/ast/src/statements/console/console_statement.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ConsoleFunction; -use crate::Node; -use crate::Span; +use crate::{ConsoleFunction, Node, Span}; use leo_grammar::console::ConsoleFunctionCall as GrammarConsoleFunctionCall; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/statements/console/formatted_container.rs b/ast/src/statements/console/formatted_container.rs index 1c35df5981..4634aa4c4a 100644 --- a/ast/src/statements/console/formatted_container.rs +++ b/ast/src/statements/console/formatted_container.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Node; -use crate::Span; +use crate::{Node, Span}; use leo_grammar::console::FormattedContainer as GrammarFormattedContainer; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/ast/src/statements/console/formatted_string.rs b/ast/src/statements/console/formatted_string.rs index e94f6175be..f96baa1fe1 100644 --- a/ast/src/statements/console/formatted_string.rs +++ b/ast/src/statements/console/formatted_string.rs @@ -14,14 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::FormattedContainer; -use crate::Node; -use crate::Span; +use crate::{Expression, FormattedContainer, Node, Span}; use leo_grammar::console::FormattedString as GrammarFormattedString; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/ast/src/statements/definition/declare.rs b/ast/src/statements/definition/declare.rs index 799702fa28..de00d5f210 100644 --- a/ast/src/statements/definition/declare.rs +++ b/ast/src/statements/definition/declare.rs @@ -16,8 +16,7 @@ use leo_grammar::common::Declare as GrammarDeclare; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/statements/definition/mod.rs b/ast/src/statements/definition/mod.rs index ac24a4a37b..78ad5ea933 100644 --- a/ast/src/statements/definition/mod.rs +++ b/ast/src/statements/definition/mod.rs @@ -14,13 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Node; -use crate::Span; -use crate::Type; +use crate::{Expression, Node, Span, Type}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; mod variable_name; diff --git a/ast/src/statements/definition/variable_name.rs b/ast/src/statements/definition/variable_name.rs index fa27f9c20f..7384b8ee1d 100644 --- a/ast/src/statements/definition/variable_name.rs +++ b/ast/src/statements/definition/variable_name.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Identifier; -use crate::Node; -use crate::Span; +use crate::{Identifier, Node, Span}; use leo_grammar::common::VariableName as GrammarVariableName; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] diff --git a/ast/src/statements/expression.rs b/ast/src/statements/expression.rs index 542da065ca..f9ff66313c 100644 --- a/ast/src/statements/expression.rs +++ b/ast/src/statements/expression.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Node; -use crate::Span; +use crate::{Expression, Node, Span}; use leo_grammar::statements::ExpressionStatement as GrammarExpressionStatement; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/ast/src/statements/iteration.rs b/ast/src/statements/iteration.rs index 74afb710fd..70126ff8ad 100644 --- a/ast/src/statements/iteration.rs +++ b/ast/src/statements/iteration.rs @@ -14,15 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Block; -use crate::Expression; -use crate::Identifier; -use crate::Node; -use crate::Span; +use crate::{Block, Expression, Identifier, Node, Span}; use leo_grammar::statements::ForStatement; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/ast/src/statements/return_statement.rs b/ast/src/statements/return_statement.rs index 6de10692fa..e1279b09c2 100644 --- a/ast/src/statements/return_statement.rs +++ b/ast/src/statements/return_statement.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Expression; -use crate::Node; -use crate::Span; +use crate::{Expression, Node, Span}; use leo_grammar::statements::ReturnStatement as GrammarReturnStatement; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/ast/src/statements/statement.rs b/ast/src/statements/statement.rs index f44b62a262..31067093e7 100644 --- a/ast/src/statements/statement.rs +++ b/ast/src/statements/statement.rs @@ -14,15 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ConditionalStatement; -use crate::Node; -use crate::Span; +use crate::{ConditionalStatement, Node, Span}; use leo_grammar::statements::Statement as GrammarStatement; use super::*; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// Program statement that defines some action (or expression) to be carried out. diff --git a/ast/src/types/integer_type.rs b/ast/src/types/integer_type.rs index d667fe7259..1ced1e76f7 100644 --- a/ast/src/types/integer_type.rs +++ b/ast/src/types/integer_type.rs @@ -14,15 +14,18 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::types::IntegerType as GrammarIntegerType; -use leo_grammar::types::SignedIntegerType as GrammarSignedIntegerType; -use leo_grammar::types::UnsignedIntegerType as GrammarUnsignedIntegerType; -use leo_input::types::IntegerType as InputIntegerType; -use leo_input::types::SignedIntegerType as InputSignedIntegerType; -use leo_input::types::UnsignedIntegerType as InputUnsignedIntegerType; +use leo_grammar::types::{ + IntegerType as GrammarIntegerType, + SignedIntegerType as GrammarSignedIntegerType, + UnsignedIntegerType as GrammarUnsignedIntegerType, +}; +use leo_input::types::{ + IntegerType as InputIntegerType, + SignedIntegerType as InputSignedIntegerType, + UnsignedIntegerType as InputUnsignedIntegerType, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// Explicit integer type diff --git a/ast/src/types/type_.rs b/ast/src/types/type_.rs index 0ad451a8c4..1d20699c31 100644 --- a/ast/src/types/type_.rs +++ b/ast/src/types/type_.rs @@ -14,21 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ArrayDimensions; -use crate::Identifier; -use crate::IntegerType; -use leo_grammar::types::ArrayType; -use leo_grammar::types::CircuitType; -use leo_grammar::types::DataType; -use leo_grammar::types::TupleType; -use leo_grammar::types::Type as GrammarType; -use leo_input::types::ArrayType as InputArrayType; -use leo_input::types::DataType as InputDataType; -use leo_input::types::TupleType as InputTupleType; -use leo_input::types::Type as InputType; +use crate::{ArrayDimensions, Identifier, IntegerType}; +use leo_grammar::types::{ArrayType, CircuitType, DataType, TupleType, Type as GrammarType}; +use leo_input::types::{ + ArrayType as InputArrayType, + DataType as InputDataType, + TupleType as InputTupleType, + Type as InputType, +}; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// Explicit type used for defining a variable or expression type diff --git a/ast/tests/serialization/json.rs b/ast/tests/serialization/json.rs index 4257cc9af3..5a58ff12c5 100644 --- a/ast/tests/serialization/json.rs +++ b/ast/tests/serialization/json.rs @@ -14,15 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Ast; -use leo_ast::AstError; #[cfg(not(feature = "ci_skip"))] use leo_ast::Program; -use leo_grammar::Grammar; -use leo_grammar::ParserError; +use leo_ast::{Ast, AstError}; +use leo_grammar::{Grammar, ParserError}; -use std::path::Path; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; fn to_ast(program_filepath: &Path) -> Result { // Loads the Leo code as a string from the given file path. diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 55195e043e..9410ca7100 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -16,39 +16,32 @@ //! Compiles a Leo program from a file path. -use crate::constraints::generate_constraints; -use crate::constraints::generate_test_constraints; -use crate::errors::CompilerError; -use crate::GroupType; -use crate::OutputBytes; -use crate::OutputFile; +use crate::{ + constraints::{generate_constraints, generate_test_constraints}, + errors::CompilerError, + GroupType, + OutputBytes, + OutputFile, +}; use leo_asg::Asg; -use leo_ast::Ast; -use leo_ast::Input; -use leo_ast::MainInput; -use leo_ast::Program; +use leo_ast::{Ast, Input, MainInput, Program}; use leo_grammar::Grammar; use leo_input::LeoInputParser; use leo_package::inputs::InputPairs; use leo_state::verify_local_data_commitment; -use snarkvm_dpc::base_dpc::instantiated::Components; -use snarkvm_dpc::SystemParameters; +use snarkvm_dpc::{base_dpc::instantiated::Components, SystemParameters}; use snarkvm_fields::PrimeField; -use snarkvm_r1cs::ConstraintSynthesizer; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_r1cs::{ConstraintSynthesizer, ConstraintSystem, SynthesisError}; -use sha2::Digest; -use sha2::Sha256; -use std::fs; -use std::marker::PhantomData; -use std::path::Path; -use std::path::PathBuf; +use sha2::{Digest, Sha256}; +use std::{ + fs, + marker::PhantomData, + path::{Path, PathBuf}, +}; -pub use leo_asg::new_context; -pub use leo_asg::AsgContext as Context; -pub use leo_asg::AsgContext; +pub use leo_asg::{new_context, AsgContext as Context, AsgContext}; thread_local! { static THREAD_GLOBAL_CONTEXT: AsgContext<'static> = { diff --git a/compiler/src/console/assert.rs b/compiler/src/console/assert.rs index deb4abf99c..cab7f1cf11 100644 --- a/compiler/src/console/assert.rs +++ b/compiler/src/console/assert.rs @@ -16,13 +16,14 @@ //! Enforces an assert equals statement in a compiled Leo program. -use crate::errors::ConsoleError; -use crate::get_indicator_value; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::Expression; -use leo_asg::Span; +use crate::{ + errors::ConsoleError, + get_indicator_value, + program::ConstrainedProgram, + value::ConstrainedValue, + GroupType, +}; +use leo_asg::{Expression, Span}; use snarkvm_fields::PrimeField; use snarkvm_gadgets::traits::utilities::boolean::Boolean; diff --git a/compiler/src/console/console.rs b/compiler/src/console/console.rs index d6765f7ae8..90c490aefc 100644 --- a/compiler/src/console/console.rs +++ b/compiler/src/console/console.rs @@ -16,12 +16,8 @@ //! Evaluates a macro in a compiled Leo program. -use crate::errors::ConsoleError; -use crate::program::ConstrainedProgram; -use crate::statement::get_indicator_value; -use crate::GroupType; -use leo_asg::ConsoleFunction; -use leo_asg::ConsoleStatement; +use crate::{errors::ConsoleError, program::ConstrainedProgram, statement::get_indicator_value, GroupType}; +use leo_asg::{ConsoleFunction, ConsoleStatement}; use snarkvm_fields::PrimeField; use snarkvm_gadgets::traits::utilities::boolean::Boolean; diff --git a/compiler/src/console/format.rs b/compiler/src/console/format.rs index 6154039232..2a20f389ac 100644 --- a/compiler/src/console/format.rs +++ b/compiler/src/console/format.rs @@ -16,9 +16,7 @@ //! Evaluates a formatted string in a compiled Leo program. -use crate::errors::ConsoleError; -use crate::program::ConstrainedProgram; -use crate::GroupType; +use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType}; use leo_asg::FormattedString; use snarkvm_fields::PrimeField; diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index 5b02a313bb..a1d574cfba 100644 --- a/compiler/src/constraints/constraints.rs +++ b/compiler/src/constraints/constraints.rs @@ -16,19 +16,14 @@ //! Generates R1CS constraints for a compiled Leo program. -use crate::errors::CompilerError; -use crate::ConstrainedProgram; -use crate::GroupType; -use crate::OutputBytes; -use crate::OutputFile; +use crate::{errors::CompilerError, ConstrainedProgram, GroupType, OutputBytes, OutputFile}; use leo_asg::Asg; use leo_ast::Input; use leo_input::LeoInputParser; use leo_package::inputs::InputPairs; use snarkvm_fields::PrimeField; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::TestConstraintSystem; +use snarkvm_r1cs::{ConstraintSystem, TestConstraintSystem}; use std::path::Path; pub fn generate_constraints<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( diff --git a/compiler/src/definition/definition.rs b/compiler/src/definition/definition.rs index a542b0e565..5c36b80388 100644 --- a/compiler/src/definition/definition.rs +++ b/compiler/src/definition/definition.rs @@ -16,9 +16,7 @@ //! Stores all defined names in a compiled Leo program. -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Variable; use snarkvm_fields::PrimeField; diff --git a/compiler/src/errors/compiler.rs b/compiler/src/errors/compiler.rs index 4fb6e9f09e..c8e7b496a9 100644 --- a/compiler/src/errors/compiler.rs +++ b/compiler/src/errors/compiler.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::FunctionError; -use crate::errors::ImportError; -use crate::errors::OutputBytesError; -use crate::errors::OutputFileError; +use crate::errors::{FunctionError, ImportError, OutputBytesError, OutputFileError}; use leo_asg::AsgConvertError; use leo_ast::AstError; use leo_grammar::ParserError; @@ -26,8 +23,7 @@ use leo_input::InputParserError; use leo_state::LocalDataVerificationError; use bincode::Error as SerdeError; -use std::path::Path; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; #[derive(Debug, Error)] pub enum CompilerError { diff --git a/compiler/src/errors/console.rs b/compiler/src/errors/console.rs index f16baf21c7..c68a0035dd 100644 --- a/compiler/src/errors/console.rs +++ b/compiler/src/errors/console.rs @@ -15,8 +15,7 @@ // along with the Leo library. If not, see . use crate::errors::ExpressionError; -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Span}; use std::path::Path; diff --git a/compiler/src/errors/expression.rs b/compiler/src/errors/expression.rs index e109e7fdb8..ac58aada16 100644 --- a/compiler/src/errors/expression.rs +++ b/compiler/src/errors/expression.rs @@ -14,18 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::AddressError; -use crate::errors::BooleanError; -use crate::errors::FieldError; -use crate::errors::FunctionError; -use crate::errors::GroupError; -use crate::errors::IntegerError; -use crate::errors::ValueError; -use leo_ast::ArrayDimensions; -use leo_ast::Error as FormattedError; -use leo_ast::Identifier; -use leo_ast::PositiveNumber; -use leo_ast::Span; +use crate::errors::{AddressError, BooleanError, FieldError, FunctionError, GroupError, IntegerError, ValueError}; +use leo_ast::{ArrayDimensions, Error as FormattedError, Identifier, PositiveNumber, Span}; use snarkvm_r1cs::SynthesisError; use std::path::Path; diff --git a/compiler/src/errors/function.rs b/compiler/src/errors/function.rs index 4c66df6de3..5422761581 100644 --- a/compiler/src/errors/function.rs +++ b/compiler/src/errors/function.rs @@ -14,18 +14,19 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::AddressError; -use crate::errors::BooleanError; -use crate::errors::ExpressionError; -use crate::errors::FieldError; -use crate::errors::GroupError; -use crate::errors::IntegerError; -use crate::errors::OutputBytesError; -use crate::errors::StatementError; -use crate::errors::ValueError; +use crate::errors::{ + AddressError, + BooleanError, + ExpressionError, + FieldError, + GroupError, + IntegerError, + OutputBytesError, + StatementError, + ValueError, +}; use leo_asg::AsgConvertError; -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Span}; use std::path::Path; diff --git a/compiler/src/errors/import.rs b/compiler/src/errors/import.rs index 325c2d3789..74ee48cc83 100644 --- a/compiler/src/errors/import.rs +++ b/compiler/src/errors/import.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Error as FormattedError; -use leo_ast::Identifier; -use leo_ast::ImportSymbol; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Identifier, ImportSymbol, Span}; #[derive(Debug, Error)] pub enum ImportError { diff --git a/compiler/src/errors/output_bytes.rs b/compiler/src/errors/output_bytes.rs index d1cb4508e5..71649b0910 100644 --- a/compiler/src/errors/output_bytes.rs +++ b/compiler/src/errors/output_bytes.rs @@ -15,10 +15,8 @@ // along with the Leo library. If not, see . use crate::errors::ValueError; -use leo_asg::AsgConvertError; -use leo_asg::Type; -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_asg::{AsgConvertError, Type}; +use leo_ast::{Error as FormattedError, Span}; use std::path::Path; diff --git a/compiler/src/errors/output_file.rs b/compiler/src/errors/output_file.rs index 0d584ea0d3..c8b18185d6 100644 --- a/compiler/src/errors/output_file.rs +++ b/compiler/src/errors/output_file.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum OutputFileError { diff --git a/compiler/src/errors/statement.rs b/compiler/src/errors/statement.rs index c35c2d155a..d915d40dff 100644 --- a/compiler/src/errors/statement.rs +++ b/compiler/src/errors/statement.rs @@ -14,15 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::AddressError; -use crate::errors::BooleanError; -use crate::errors::ConsoleError; -use crate::errors::ExpressionError; -use crate::errors::IntegerError; -use crate::errors::ValueError; +use crate::errors::{AddressError, BooleanError, ConsoleError, ExpressionError, IntegerError, ValueError}; use leo_asg::Type; -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Span}; use std::path::Path; diff --git a/compiler/src/errors/value/address.rs b/compiler/src/errors/value/address.rs index 4cd9889c8f..a6dfdd840d 100644 --- a/compiler/src/errors/value/address.rs +++ b/compiler/src/errors/value/address.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Span}; use snarkvm_dpc::AccountError; use snarkvm_r1cs::SynthesisError; diff --git a/compiler/src/errors/value/boolean.rs b/compiler/src/errors/value/boolean.rs index e6472dfaf1..7f7c264148 100644 --- a/compiler/src/errors/value/boolean.rs +++ b/compiler/src/errors/value/boolean.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Span}; use snarkvm_r1cs::SynthesisError; use std::path::Path; diff --git a/compiler/src/errors/value/field.rs b/compiler/src/errors/value/field.rs index f1e2c2e152..0a6766f3e1 100644 --- a/compiler/src/errors/value/field.rs +++ b/compiler/src/errors/value/field.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Span}; use snarkvm_r1cs::SynthesisError; use std::path::Path; diff --git a/compiler/src/errors/value/group.rs b/compiler/src/errors/value/group.rs index 1bfa2c53f7..e83d8af596 100644 --- a/compiler/src/errors/value/group.rs +++ b/compiler/src/errors/value/group.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use leo_ast::{Error as FormattedError, Span}; use snarkvm_r1cs::SynthesisError; use std::path::Path; diff --git a/compiler/src/errors/value/integer.rs b/compiler/src/errors/value/integer.rs index 6aabfe6dd2..bd8f44cad3 100644 --- a/compiler/src/errors/value/integer.rs +++ b/compiler/src/errors/value/integer.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_ast::error::Error as FormattedError; -use leo_ast::IntegerType; -use leo_ast::Span; -use leo_ast::Type; +use leo_ast::{error::Error as FormattedError, IntegerType, Span, Type}; use leo_gadgets::errors::SignedIntegerError; use snarkvm_r1cs::SynthesisError; diff --git a/compiler/src/errors/value/value.rs b/compiler/src/errors/value/value.rs index cd478445c4..66a7d50e83 100644 --- a/compiler/src/errors/value/value.rs +++ b/compiler/src/errors/value/value.rs @@ -14,13 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::AddressError; -use crate::errors::BooleanError; -use crate::errors::FieldError; -use crate::errors::GroupError; -use crate::errors::IntegerError; -use leo_ast::Error as FormattedError; -use leo_ast::Span; +use crate::errors::{AddressError, BooleanError, FieldError, GroupError, IntegerError}; +use leo_ast::{Error as FormattedError, Span}; use std::path::Path; diff --git a/compiler/src/expression/arithmetic/add.rs b/compiler/src/expression/arithmetic/add.rs index 4086114e4b..67baf70950 100644 --- a/compiler/src/expression/arithmetic/add.rs +++ b/compiler/src/expression/arithmetic/add.rs @@ -16,9 +16,7 @@ //! Enforces an arithmetic `+` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/arithmetic/div.rs b/compiler/src/expression/arithmetic/div.rs index b0fd7dc2b5..37fec2c641 100644 --- a/compiler/src/expression/arithmetic/div.rs +++ b/compiler/src/expression/arithmetic/div.rs @@ -16,9 +16,7 @@ //! Enforces an arithmetic `/` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/arithmetic/mul.rs b/compiler/src/expression/arithmetic/mul.rs index 88204ff7e0..995ba21002 100644 --- a/compiler/src/expression/arithmetic/mul.rs +++ b/compiler/src/expression/arithmetic/mul.rs @@ -16,9 +16,7 @@ //! Enforces an arithmetic `*` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/arithmetic/negate.rs b/compiler/src/expression/arithmetic/negate.rs index e4ad3dfadd..bee6106f34 100644 --- a/compiler/src/expression/arithmetic/negate.rs +++ b/compiler/src/expression/arithmetic/negate.rs @@ -16,9 +16,7 @@ //! Enforces a unary negate `-` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/arithmetic/pow.rs b/compiler/src/expression/arithmetic/pow.rs index 3ec3db06a0..48230b49e6 100644 --- a/compiler/src/expression/arithmetic/pow.rs +++ b/compiler/src/expression/arithmetic/pow.rs @@ -16,9 +16,7 @@ //! Enforces an arithmetic `**` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/arithmetic/sub.rs b/compiler/src/expression/arithmetic/sub.rs index 8a12764a79..a86c154956 100644 --- a/compiler/src/expression/arithmetic/sub.rs +++ b/compiler/src/expression/arithmetic/sub.rs @@ -16,9 +16,7 @@ //! Enforces an arithmetic `-` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/array/access.rs b/compiler/src/expression/array/access.rs index 371a195e19..363f552087 100644 --- a/compiler/src/expression/array/access.rs +++ b/compiler/src/expression/array/access.rs @@ -16,12 +16,8 @@ //! Enforces array access in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::Expression; -use leo_asg::Span; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{Expression, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/array/array.rs b/compiler/src/expression/array/array.rs index d904356a49..0630bf0869 100644 --- a/compiler/src/expression/array/array.rs +++ b/compiler/src/expression/array/array.rs @@ -18,12 +18,8 @@ use std::cell::Cell; -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::Expression; -use leo_asg::Span; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{Expression, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/array/index.rs b/compiler/src/expression/array/index.rs index fe281f85de..1b5dde5a67 100644 --- a/compiler/src/expression/array/index.rs +++ b/compiler/src/expression/array/index.rs @@ -16,12 +16,8 @@ //! Enforces an array index expression in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::Expression; -use leo_asg::Span; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{Expression, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/binary/binary.rs b/compiler/src/expression/binary/binary.rs index 2bab64f405..d5b250d507 100644 --- a/compiler/src/expression/binary/binary.rs +++ b/compiler/src/expression/binary/binary.rs @@ -16,10 +16,7 @@ //! Enforces a binary expression in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Expression; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/circuit/access.rs b/compiler/src/expression/circuit/access.rs index 047d8fb32c..87e6ec7320 100644 --- a/compiler/src/expression/circuit/access.rs +++ b/compiler/src/expression/circuit/access.rs @@ -16,12 +16,8 @@ //! Enforces a circuit access expression in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::CircuitAccessExpression; -use leo_asg::Node; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{CircuitAccessExpression, Node}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/circuit/circuit.rs b/compiler/src/expression/circuit/circuit.rs index 6e25db67a5..7ad2eb7079 100644 --- a/compiler/src/expression/circuit/circuit.rs +++ b/compiler/src/expression/circuit/circuit.rs @@ -16,14 +16,13 @@ //! Enforces a circuit expression in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedCircuitMember; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::CircuitInitExpression; -use leo_asg::CircuitMember; -use leo_asg::Span; +use crate::{ + errors::ExpressionError, + program::ConstrainedProgram, + value::{ConstrainedCircuitMember, ConstrainedValue}, + GroupType, +}; +use leo_asg::{CircuitInitExpression, CircuitMember, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/conditional/conditional.rs b/compiler/src/expression/conditional/conditional.rs index 572c7ec737..0fab6b027b 100644 --- a/compiler/src/expression/conditional/conditional.rs +++ b/compiler/src/expression/conditional/conditional.rs @@ -16,12 +16,8 @@ //! Enforces a conditional expression in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::Expression; -use leo_asg::Span; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{Expression, Span}; use snarkvm_fields::PrimeField; use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; diff --git a/compiler/src/expression/expression.rs b/compiler/src/expression/expression.rs index 46e7021ba1..49eaf97a5b 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -16,21 +16,18 @@ //! Enforce constraints on an expression in a compiled Leo program. -use crate::arithmetic::*; -use crate::errors::ExpressionError; -use crate::logical::*; -use crate::program::ConstrainedProgram; -use crate::relational::*; -use crate::resolve_core_circuit; -use crate::value::Address; -use crate::value::ConstrainedValue; -use crate::value::Integer; -use crate::FieldType; -use crate::GroupType; -use leo_asg::expression::*; -use leo_asg::ConstValue; -use leo_asg::Expression; -use leo_asg::Node; +use crate::{ + arithmetic::*, + errors::ExpressionError, + logical::*, + program::ConstrainedProgram, + relational::*, + resolve_core_circuit, + value::{Address, ConstrainedValue, Integer}, + FieldType, + GroupType, +}; +use leo_asg::{expression::*, ConstValue, Expression, Node}; use snarkvm_fields::PrimeField; use snarkvm_gadgets::traits::utilities::boolean::Boolean; diff --git a/compiler/src/expression/function/core_circuit.rs b/compiler/src/expression/function/core_circuit.rs index 0c8ffa808a..c1a467724d 100644 --- a/compiler/src/expression/function/core_circuit.rs +++ b/compiler/src/expression/function/core_circuit.rs @@ -16,15 +16,10 @@ use std::cell::Cell; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::CoreCircuit; -use crate::GroupType; +use crate::{program::ConstrainedProgram, value::ConstrainedValue, CoreCircuit, GroupType}; use crate::errors::ExpressionError; -use leo_asg::Expression; -use leo_asg::Function; -use leo_asg::Span; +use leo_asg::{Expression, Function, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/function/function.rs b/compiler/src/expression/function/function.rs index 5ef05dacb8..3276918328 100644 --- a/compiler/src/expression/function/function.rs +++ b/compiler/src/expression/function/function.rs @@ -18,13 +18,8 @@ use std::cell::Cell; -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::Expression; -use leo_asg::Function; -use leo_asg::Span; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{Expression, Function, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/logical/and.rs b/compiler/src/expression/logical/and.rs index 6243fb3698..623feb844c 100644 --- a/compiler/src/expression/logical/and.rs +++ b/compiler/src/expression/logical/and.rs @@ -16,9 +16,7 @@ //! Enforces a logical `&&` operator in a resolved Leo program. -use crate::errors::BooleanError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/logical/not.rs b/compiler/src/expression/logical/not.rs index 3e7022bd57..06556dc13f 100644 --- a/compiler/src/expression/logical/not.rs +++ b/compiler/src/expression/logical/not.rs @@ -16,9 +16,7 @@ //! Enforces a logical `!` operator in a resolved Leo program. -use crate::errors::BooleanError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/logical/or.rs b/compiler/src/expression/logical/or.rs index d8e42df918..b6e37fd459 100644 --- a/compiler/src/expression/logical/or.rs +++ b/compiler/src/expression/logical/or.rs @@ -16,9 +16,7 @@ //! Enforces a logical `||` operator in a resolved Leo program. -use crate::errors::BooleanError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/relational/eq.rs b/compiler/src/expression/relational/eq.rs index 29fb597390..325a35f466 100644 --- a/compiler/src/expression/relational/eq.rs +++ b/compiler/src/expression/relational/eq.rs @@ -16,15 +16,11 @@ //! Enforces a relational `==` operator in a resolved Leo program. -use crate::enforce_and; -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{enforce_and, errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, eq::EvaluateEqGadget}; use snarkvm_r1cs::ConstraintSystem; pub fn evaluate_eq<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( diff --git a/compiler/src/expression/relational/ge.rs b/compiler/src/expression/relational/ge.rs index faa4f7c69a..18e44ff0c8 100644 --- a/compiler/src/expression/relational/ge.rs +++ b/compiler/src/expression/relational/ge.rs @@ -16,9 +16,7 @@ //! Enforces a relational `>=` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; diff --git a/compiler/src/expression/relational/gt.rs b/compiler/src/expression/relational/gt.rs index b30a97553b..726d81da2a 100644 --- a/compiler/src/expression/relational/gt.rs +++ b/compiler/src/expression/relational/gt.rs @@ -16,9 +16,7 @@ //! Enforces a relational `>` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; diff --git a/compiler/src/expression/relational/le.rs b/compiler/src/expression/relational/le.rs index 6c247048bc..547aa519a1 100644 --- a/compiler/src/expression/relational/le.rs +++ b/compiler/src/expression/relational/le.rs @@ -16,9 +16,7 @@ //! Enforces a relational `<=` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; diff --git a/compiler/src/expression/relational/lt.rs b/compiler/src/expression/relational/lt.rs index 19c98f63a2..a47f1f8735 100644 --- a/compiler/src/expression/relational/lt.rs +++ b/compiler/src/expression/relational/lt.rs @@ -16,9 +16,7 @@ //! Enforces a relational `<` operator in a resolved Leo program. -use crate::errors::ExpressionError; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::comparator::EvaluateLtGadget; diff --git a/compiler/src/expression/tuple/access.rs b/compiler/src/expression/tuple/access.rs index 46d37d6a10..40e5efe64e 100644 --- a/compiler/src/expression/tuple/access.rs +++ b/compiler/src/expression/tuple/access.rs @@ -16,12 +16,8 @@ //! Enforces array access in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::Expression; -use leo_asg::Span; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{Expression, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/expression/tuple/tuple.rs b/compiler/src/expression/tuple/tuple.rs index 5ab7b4da88..45ce92d86d 100644 --- a/compiler/src/expression/tuple/tuple.rs +++ b/compiler/src/expression/tuple/tuple.rs @@ -18,10 +18,7 @@ use std::cell::Cell; -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Expression; use snarkvm_fields::PrimeField; diff --git a/compiler/src/expression/variable_ref/variable_ref.rs b/compiler/src/expression/variable_ref/variable_ref.rs index 076b3dee3a..d2bef6e489 100644 --- a/compiler/src/expression/variable_ref/variable_ref.rs +++ b/compiler/src/expression/variable_ref/variable_ref.rs @@ -16,10 +16,7 @@ //! Enforces an identifier expression in a compiled Leo program. -use crate::errors::ExpressionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::VariableRef; use snarkvm_fields::PrimeField; diff --git a/compiler/src/function/function.rs b/compiler/src/function/function.rs index 98df36cb2e..840c3d5619 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -16,14 +16,9 @@ //! Enforces constraints on a function in a compiled Leo program. -use crate::errors::FunctionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::FunctionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; -use leo_asg::Expression; -use leo_asg::Function; -use leo_asg::FunctionQualifier; +use leo_asg::{Expression, Function, FunctionQualifier}; use std::cell::Cell; use snarkvm_fields::PrimeField; diff --git a/compiler/src/function/input/array.rs b/compiler/src/function/input/array.rs index 5e6d9fd976..dcb88e6422 100644 --- a/compiler/src/function/input/array.rs +++ b/compiler/src/function/input/array.rs @@ -16,14 +16,10 @@ //! Allocates an array as a main function input parameter in a compiled Leo program. -use crate::errors::FunctionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::FunctionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Type; -use leo_ast::InputValue; -use leo_ast::Span; +use leo_ast::{InputValue, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/function/input/input_keyword.rs b/compiler/src/function/input/input_keyword.rs index ae5cd8386a..1a5dcd6e34 100644 --- a/compiler/src/function/input/input_keyword.rs +++ b/compiler/src/function/input/input_keyword.rs @@ -14,17 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::FunctionError; -use crate::ConstrainedCircuitMember; -use crate::ConstrainedProgram; -use crate::ConstrainedValue; -use crate::GroupType; -use leo_asg::Circuit; -use leo_asg::CircuitMember; -use leo_asg::Type; -use leo_ast::Identifier; -use leo_ast::Input; -use leo_ast::Span; +use crate::{errors::FunctionError, ConstrainedCircuitMember, ConstrainedProgram, ConstrainedValue, GroupType}; +use leo_asg::{Circuit, CircuitMember, Type}; +use leo_ast::{Identifier, Input, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/function/input/input_section.rs b/compiler/src/function/input/input_section.rs index 0e7cdac513..e188b82f3b 100644 --- a/compiler/src/function/input/input_section.rs +++ b/compiler/src/function/input/input_section.rs @@ -14,17 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::FunctionError; -use crate::ConstrainedCircuitMember; -use crate::ConstrainedProgram; -use crate::ConstrainedValue; -use crate::GroupType; -use leo_asg::AsgConvertError; -use leo_asg::Circuit; -use leo_asg::CircuitMember; -use leo_ast::Identifier; -use leo_ast::InputValue; -use leo_ast::Parameter; +use crate::{errors::FunctionError, ConstrainedCircuitMember, ConstrainedProgram, ConstrainedValue, GroupType}; +use leo_asg::{AsgConvertError, Circuit, CircuitMember}; +use leo_ast::{Identifier, InputValue, Parameter}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/function/input/main_function_input.rs b/compiler/src/function/input/main_function_input.rs index 0ad5f707ad..cbf9150a64 100644 --- a/compiler/src/function/input/main_function_input.rs +++ b/compiler/src/function/input/main_function_input.rs @@ -16,19 +16,22 @@ //! Allocates a main function input parameter in a compiled Leo program. -use crate::address::Address; -use crate::errors::FunctionError; -use crate::program::ConstrainedProgram; -use crate::value::boolean::input::bool_from_input; -use crate::value::field::input::field_from_input; -use crate::value::group::input::group_from_input; -use crate::value::ConstrainedValue; -use crate::GroupType; -use crate::Integer; +use crate::{ + address::Address, + errors::FunctionError, + program::ConstrainedProgram, + value::{ + boolean::input::bool_from_input, + field::input::field_from_input, + group::input::group_from_input, + ConstrainedValue, + }, + GroupType, + Integer, +}; use leo_asg::Type; -use leo_ast::InputValue; -use leo_ast::Span; +use leo_ast::{InputValue, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/function/input/tuple.rs b/compiler/src/function/input/tuple.rs index 3bb8587406..e83133e279 100644 --- a/compiler/src/function/input/tuple.rs +++ b/compiler/src/function/input/tuple.rs @@ -16,14 +16,10 @@ //! Allocates an array as a main function input parameter in a compiled Leo program. -use crate::errors::FunctionError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::FunctionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Type; -use leo_ast::InputValue; -use leo_ast::Span; +use leo_ast::{InputValue, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index 86c601426d..5ce77a009f 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -16,14 +16,9 @@ //! Enforces constraints on the main function of a compiled Leo program. -use crate::errors::FunctionError; -use crate::program::ConstrainedProgram; -use crate::GroupType; -use crate::OutputBytes; +use crate::{errors::FunctionError, program::ConstrainedProgram, GroupType, OutputBytes}; -use leo_asg::Expression; -use leo_asg::Function; -use leo_asg::FunctionQualifier; +use leo_asg::{Expression, Function, FunctionQualifier}; use leo_ast::Input; use std::cell::Cell; diff --git a/compiler/src/function/mut_target.rs b/compiler/src/function/mut_target.rs index 1d7927ad2b..00a7c17d6d 100644 --- a/compiler/src/function/mut_target.rs +++ b/compiler/src/function/mut_target.rs @@ -16,19 +16,23 @@ //! Resolves assignees in a compiled Leo program. -use crate::errors::StatementError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use crate::ResolvedAssigneeAccess; -use leo_asg::ArrayAccessExpression; -use leo_asg::ArrayRangeAccessExpression; -use leo_asg::CircuitAccessExpression; -use leo_asg::Expression; -use leo_asg::Node; -use leo_asg::Span; -use leo_asg::TupleAccessExpression; -use leo_asg::Variable; +use crate::{ + errors::StatementError, + program::ConstrainedProgram, + value::ConstrainedValue, + GroupType, + ResolvedAssigneeAccess, +}; +use leo_asg::{ + ArrayAccessExpression, + ArrayRangeAccessExpression, + CircuitAccessExpression, + Expression, + Node, + Span, + TupleAccessExpression, + Variable, +}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index 499af03122..29b6aed420 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -16,18 +16,18 @@ //! Enforces that one return value is produced in a compiled Leo program. -use crate::errors::StatementError; -use crate::get_indicator_value; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{ + errors::StatementError, + get_indicator_value, + program::ConstrainedProgram, + value::ConstrainedValue, + GroupType, +}; -use leo_asg::Span; -use leo_asg::Type; +use leo_asg::{Span, Type}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, select::CondSelectGadget}; use snarkvm_r1cs::ConstraintSystem; impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { diff --git a/compiler/src/output/output_bytes.rs b/compiler/src/output/output_bytes.rs index 6e4fc29423..ecbaffe408 100644 --- a/compiler/src/output/output_bytes.rs +++ b/compiler/src/output/output_bytes.rs @@ -14,19 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::OutputBytesError; -use crate::ConstrainedValue; -use crate::GroupType; -use crate::REGISTERS_VARIABLE_NAME; +use crate::{errors::OutputBytesError, ConstrainedValue, GroupType, REGISTERS_VARIABLE_NAME}; use leo_asg::Program; -use leo_ast::Parameter; -use leo_ast::Registers; -use leo_ast::Span; +use leo_ast::{Parameter, Registers, Span}; use snarkvm_fields::PrimeField; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; /// Serialized program return output. #[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] diff --git a/compiler/src/output/output_file.rs b/compiler/src/output/output_file.rs index d2aced5cdd..f9dd6eeda1 100644 --- a/compiler/src/output/output_file.rs +++ b/compiler/src/output/output_file.rs @@ -18,11 +18,15 @@ use crate::errors::OutputFileError; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static OUTPUTS_DIRECTORY_NAME: &str = "outputs/"; pub static OUTPUT_FILE_EXTENSION: &str = ".out"; diff --git a/compiler/src/prelude/blake2s.rs b/compiler/src/prelude/blake2s.rs index ab21175a87..c8659425ad 100644 --- a/compiler/src/prelude/blake2s.rs +++ b/compiler/src/prelude/blake2s.rs @@ -15,17 +15,16 @@ // along with the Leo library. If not, see . use super::CoreCircuit; -use crate::errors::ExpressionError; -use crate::ConstrainedValue; -use crate::GroupType; -use crate::Integer; -use leo_asg::Function; -use leo_asg::Span; +use crate::{errors::ExpressionError, ConstrainedValue, GroupType, Integer}; +use leo_asg::{Function, Span}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::algorithms::prf::Blake2sGadget; -use snarkvm_gadgets::traits::algorithms::PRFGadget; -use snarkvm_gadgets::traits::utilities::uint::UInt8; -use snarkvm_gadgets::traits::utilities::ToBytesGadget; +use snarkvm_gadgets::{ + algorithms::prf::Blake2sGadget, + traits::{ + algorithms::PRFGadget, + utilities::{uint::UInt8, ToBytesGadget}, + }, +}; use snarkvm_r1cs::ConstraintSystem; pub struct Blake2s; diff --git a/compiler/src/prelude/mod.rs b/compiler/src/prelude/mod.rs index 70799088aa..736308274b 100644 --- a/compiler/src/prelude/mod.rs +++ b/compiler/src/prelude/mod.rs @@ -17,11 +17,8 @@ pub mod blake2s; pub use blake2s::*; -use crate::errors::ExpressionError; -use crate::ConstrainedValue; -use crate::GroupType; -use leo_asg::Function; -use leo_asg::Span; +use crate::{errors::ExpressionError, ConstrainedValue, GroupType}; +use leo_asg::{Function, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/program/program.rs b/compiler/src/program/program.rs index 329134643d..1110e9a7c0 100644 --- a/compiler/src/program/program.rs +++ b/compiler/src/program/program.rs @@ -16,8 +16,7 @@ //! An in memory store to keep track of defined names when constraining a Leo program. -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{value::ConstrainedValue, GroupType}; use leo_asg::Program; use snarkvm_fields::PrimeField; diff --git a/compiler/src/statement/assign/assign.rs b/compiler/src/statement/assign/assign.rs index f738529c9f..232d03d125 100644 --- a/compiler/src/statement/assign/assign.rs +++ b/compiler/src/statement/assign/assign.rs @@ -16,18 +16,11 @@ //! Enforces an assign statement in a compiled Leo program. -use crate::arithmetic::*; -use crate::errors::StatementError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::AssignOperation; -use leo_asg::AssignStatement; -use leo_asg::Span; +use crate::{arithmetic::*, errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{AssignOperation, AssignStatement, Span}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, select::CondSelectGadget}; use snarkvm_r1cs::ConstraintSystem; impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { diff --git a/compiler/src/statement/assign/assignee.rs b/compiler/src/statement/assign/assignee.rs index 598bc95d17..71e758688d 100644 --- a/compiler/src/statement/assign/assignee.rs +++ b/compiler/src/statement/assign/assignee.rs @@ -16,14 +16,8 @@ //! Resolves assignees in a compiled Leo program. -use crate::errors::StatementError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_asg::AssignAccess; -use leo_asg::AssignStatement; -use leo_asg::Identifier; -use leo_asg::Span; +use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use leo_asg::{AssignAccess, AssignStatement, Identifier, Span}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/statement/block/block.rs b/compiler/src/statement/block/block.rs index 5c81c3b6d9..ed9d7577df 100644 --- a/compiler/src/statement/block/block.rs +++ b/compiler/src/statement/block/block.rs @@ -16,10 +16,7 @@ //! Enforces a branch of a conditional or iteration statement in a compiled Leo program. -use crate::program::ConstrainedProgram; -use crate::GroupType; -use crate::IndicatorAndConstrainedValue; -use crate::StatementResult; +use crate::{program::ConstrainedProgram, GroupType, IndicatorAndConstrainedValue, StatementResult}; use leo_asg::BlockStatement; use snarkvm_fields::PrimeField; diff --git a/compiler/src/statement/conditional/conditional.rs b/compiler/src/statement/conditional/conditional.rs index 22bfbdb7ae..84368ed307 100644 --- a/compiler/src/statement/conditional/conditional.rs +++ b/compiler/src/statement/conditional/conditional.rs @@ -16,12 +16,14 @@ //! Methods to enforce constraints on statements in a compiled Leo program. -use crate::errors::StatementError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use crate::IndicatorAndConstrainedValue; -use crate::StatementResult; +use crate::{ + errors::StatementError, + program::ConstrainedProgram, + value::ConstrainedValue, + GroupType, + IndicatorAndConstrainedValue, + StatementResult, +}; use leo_asg::ConditionalStatement; use snarkvm_fields::PrimeField; diff --git a/compiler/src/statement/definition/definition.rs b/compiler/src/statement/definition/definition.rs index 8199c80f8a..a021b52ed1 100644 --- a/compiler/src/statement/definition/definition.rs +++ b/compiler/src/statement/definition/definition.rs @@ -16,13 +16,8 @@ //! Enforces a definition statement in a compiled Leo program. -use crate::errors::StatementError; -use crate::program::ConstrainedProgram; -use crate::ConstrainedValue; -use crate::GroupType; -use leo_asg::DefinitionStatement; -use leo_asg::Span; -use leo_asg::Variable; +use crate::{errors::StatementError, program::ConstrainedProgram, ConstrainedValue, GroupType}; +use leo_asg::{DefinitionStatement, Span, Variable}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index c70b2690de..a5fe0e8b30 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -16,17 +16,18 @@ //! Enforces an iteration statement in a compiled Leo program. -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; -use crate::IndicatorAndConstrainedValue; -use crate::Integer; -use crate::StatementResult; +use crate::{ + program::ConstrainedProgram, + value::ConstrainedValue, + GroupType, + IndicatorAndConstrainedValue, + Integer, + StatementResult, +}; use leo_asg::IterationStatement; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::uint::UInt32; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, uint::UInt32}; use snarkvm_r1cs::ConstraintSystem; impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { diff --git a/compiler/src/statement/return_/return_.rs b/compiler/src/statement/return_/return_.rs index ae0172002d..91e23c9e04 100644 --- a/compiler/src/statement/return_/return_.rs +++ b/compiler/src/statement/return_/return_.rs @@ -16,10 +16,7 @@ //! Enforces a return statement in a compiled Leo program. -use crate::errors::StatementError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::ReturnStatement; use snarkvm_fields::PrimeField; diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index e5eef59ec6..135c7932fd 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -16,10 +16,7 @@ //! Enforces a statement in a compiled Leo program. -use crate::errors::StatementError; -use crate::program::ConstrainedProgram; -use crate::value::ConstrainedValue; -use crate::GroupType; +use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Statement; use snarkvm_fields::PrimeField; diff --git a/compiler/src/value/address/address.rs b/compiler/src/value/address/address.rs index 8dc60b3007..b7d9e013b2 100644 --- a/compiler/src/value/address/address.rs +++ b/compiler/src/value/address/address.rs @@ -14,29 +14,21 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::AddressError; -use crate::ConstrainedValue; -use crate::GroupType; -use leo_ast::InputValue; -use leo_ast::Span; +use crate::{errors::AddressError, ConstrainedValue, GroupType}; +use leo_ast::{InputValue, Span}; -use snarkvm_dpc::account::AccountAddress; -use snarkvm_dpc::base_dpc::instantiated::Components; +use snarkvm_dpc::{account::AccountAddress, base_dpc::instantiated::Components}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::ConditionalEqGadget; -use snarkvm_gadgets::traits::utilities::eq::EqGadget; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_gadgets::traits::utilities::uint::UInt; -use snarkvm_gadgets::traits::utilities::uint::UInt8; -use snarkvm_r1cs::Assignment; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + boolean::Boolean, + eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget}, + select::CondSelectGadget, + uint::{UInt, UInt8}, +}; +use snarkvm_r1cs::{Assignment, ConstraintSystem, SynthesisError}; use snarkvm_utilities::ToBytes; -use std::borrow::Borrow; -use std::str::FromStr; +use std::{borrow::Borrow, str::FromStr}; /// A public address #[derive(Clone, Debug, PartialEq, Eq)] @@ -207,11 +199,7 @@ impl ConditionalEqGadget for Address { } fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address { - if cond { - first.clone() - } else { - second.clone() - } + if cond { first.clone() } else { second.clone() } } impl CondSelectGadget for Address { diff --git a/compiler/src/value/boolean/input.rs b/compiler/src/value/boolean/input.rs index 7ab9ce591e..e60cda1a68 100644 --- a/compiler/src/value/boolean/input.rs +++ b/compiler/src/value/boolean/input.rs @@ -16,17 +16,12 @@ //! Methods to enforce constraints on input boolean values in a resolved Leo program. -use crate::errors::BooleanError; -use crate::value::ConstrainedValue; -use crate::GroupType; -use leo_ast::InputValue; -use leo_ast::Span; +use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; +use leo_ast::{InputValue, Span}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{alloc::AllocGadget, boolean::Boolean}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; pub(crate) fn allocate_bool>( cs: &mut CS, diff --git a/compiler/src/value/field/field_type.rs b/compiler/src/value/field/field_type.rs index a03e6e1bc4..21819c6ed3 100644 --- a/compiler/src/value/field/field_type.rs +++ b/compiler/src/value/field/field_type.rs @@ -16,28 +16,28 @@ //! A data type that represents a field value -use crate::errors::FieldError; -use crate::number_string_typing; +use crate::{errors::FieldError, number_string_typing}; use leo_ast::Span; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::fields::AllocatedFp; -use snarkvm_gadgets::fields::FpGadget; -use snarkvm_gadgets::traits::fields::FieldGadget; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::ConditionalEqGadget; -use snarkvm_gadgets::traits::utilities::eq::EqGadget; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_gadgets::traits::utilities::uint::UInt8; -use snarkvm_gadgets::traits::utilities::ToBitsGadget; -use snarkvm_gadgets::traits::utilities::ToBytesGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::{ + fields::{AllocatedFp, FpGadget}, + traits::{ + fields::FieldGadget, + utilities::{ + alloc::AllocGadget, + boolean::Boolean, + eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget}, + select::CondSelectGadget, + uint::UInt8, + ToBitsGadget, + ToBytesGadget, + }, + }, +}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; -use std::borrow::Borrow; -use std::cmp::Ordering; +use std::{borrow::Borrow, cmp::Ordering}; #[derive(Clone, Debug)] pub enum FieldType { @@ -293,11 +293,7 @@ impl CondSelectGadget for FieldType { second: &Self, ) -> Result { if let Boolean::Constant(cond) = *cond { - if cond { - Ok(first.clone()) - } else { - Ok(second.clone()) - } + if cond { Ok(first.clone()) } else { Ok(second.clone()) } } else { let first_gadget = first.allocated(&mut cs)?; let second_gadget = second.allocated(&mut cs)?; diff --git a/compiler/src/value/field/input.rs b/compiler/src/value/field/input.rs index 299c2e1cc6..4172fa23b0 100644 --- a/compiler/src/value/field/input.rs +++ b/compiler/src/value/field/input.rs @@ -16,18 +16,12 @@ //! Methods to enforce constraints on input field values in a compiled Leo program. -use crate::errors::FieldError; -use crate::number_string_typing; -use crate::value::ConstrainedValue; -use crate::FieldType; -use crate::GroupType; -use leo_ast::InputValue; -use leo_ast::Span; +use crate::{errors::FieldError, number_string_typing, value::ConstrainedValue, FieldType, GroupType}; +use leo_ast::{InputValue, Span}; use snarkvm_fields::PrimeField; use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; pub(crate) fn allocate_field>( cs: &mut CS, diff --git a/compiler/src/value/group/group_type.rs b/compiler/src/value/group/group_type.rs index eb7969546e..8c822938ea 100644 --- a/compiler/src/value/group/group_type.rs +++ b/compiler/src/value/group/group_type.rs @@ -17,21 +17,18 @@ //! A data type that represents members in the group formed by the set of affine points on a curve. use crate::errors::GroupError; -use leo_asg::GroupValue; -use leo_asg::Span; +use leo_asg::{GroupValue, Span}; -use snarkvm_fields::Field; -use snarkvm_fields::One; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::eq::ConditionalEqGadget; -use snarkvm_gadgets::traits::utilities::eq::EqGadget; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_gadgets::traits::utilities::ToBitsGadget; -use snarkvm_gadgets::traits::utilities::ToBytesGadget; +use snarkvm_fields::{Field, One}; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget}, + select::CondSelectGadget, + ToBitsGadget, + ToBytesGadget, +}; use snarkvm_r1cs::ConstraintSystem; -use std::fmt::Debug; -use std::fmt::Display; +use std::fmt::{Debug, Display}; pub trait GroupType: Sized diff --git a/compiler/src/value/group/input.rs b/compiler/src/value/group/input.rs index ff4f084e75..df56ff5564 100644 --- a/compiler/src/value/group/input.rs +++ b/compiler/src/value/group/input.rs @@ -16,16 +16,12 @@ //! Methods to enforce constraints on input group values in a Leo program. -use crate::errors::GroupError; -use crate::ConstrainedValue; -use crate::GroupType; -use leo_asg::GroupValue; -use leo_asg::Span; +use crate::{errors::GroupError, ConstrainedValue, GroupType}; +use leo_asg::{GroupValue, Span}; use leo_ast::InputValue; use snarkvm_fields::PrimeField; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; pub(crate) fn allocate_group, CS: ConstraintSystem>( cs: &mut CS, diff --git a/compiler/src/value/group/targets/edwards_bls12.rs b/compiler/src/value/group/targets/edwards_bls12.rs index 66cc727cef..9c8cecb525 100644 --- a/compiler/src/value/group/targets/edwards_bls12.rs +++ b/compiler/src/value/group/targets/edwards_bls12.rs @@ -14,43 +14,39 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::GroupError; -use crate::number_string_typing; -use crate::GroupType; -use leo_asg::GroupCoordinate; -use leo_asg::GroupValue; -use leo_asg::Span; +use crate::{errors::GroupError, number_string_typing, GroupType}; +use leo_asg::{GroupCoordinate, GroupValue, Span}; -use snarkvm_curves::edwards_bls12::EdwardsAffine; -use snarkvm_curves::edwards_bls12::EdwardsParameters; -use snarkvm_curves::edwards_bls12::Fq; -use snarkvm_curves::templates::twisted_edwards_extended::GroupAffine; -use snarkvm_curves::AffineCurve; -use snarkvm_curves::TEModelParameters; -use snarkvm_fields::Fp256; -use snarkvm_fields::One; -use snarkvm_fields::Zero; -use snarkvm_gadgets::curves::edwards_bls12::EdwardsBlsGadget; -use snarkvm_gadgets::fields::AllocatedFp; -use snarkvm_gadgets::fields::FpGadget; -use snarkvm_gadgets::traits::curves::GroupGadget; -use snarkvm_gadgets::traits::fields::FieldGadget; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::ConditionalEqGadget; -use snarkvm_gadgets::traits::utilities::eq::EqGadget; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_gadgets::traits::utilities::uint::UInt8; -use snarkvm_gadgets::traits::utilities::ToBitsGadget; -use snarkvm_gadgets::traits::utilities::ToBytesGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; -use std::borrow::Borrow; -use std::ops::Mul; -use std::ops::Neg; -use std::ops::Sub; -use std::str::FromStr; +use snarkvm_curves::{ + edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq}, + templates::twisted_edwards_extended::GroupAffine, + AffineCurve, + TEModelParameters, +}; +use snarkvm_fields::{Fp256, One, Zero}; +use snarkvm_gadgets::{ + curves::edwards_bls12::EdwardsBlsGadget, + fields::{AllocatedFp, FpGadget}, + traits::{ + curves::GroupGadget, + fields::FieldGadget, + utilities::{ + alloc::AllocGadget, + boolean::Boolean, + eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget}, + select::CondSelectGadget, + uint::UInt8, + ToBitsGadget, + ToBytesGadget, + }, + }, +}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; +use std::{ + borrow::Borrow, + ops::{Mul, Neg, Sub}, + str::FromStr, +}; #[derive(Clone, Debug)] pub enum EdwardsGroupType { @@ -488,11 +484,7 @@ impl CondSelectGadget for EdwardsGroupType { second: &Self, ) -> Result { if let Boolean::Constant(cond) = *cond { - if cond { - Ok(first.clone()) - } else { - Ok(second.clone()) - } + if cond { Ok(first.clone()) } else { Ok(second.clone()) } } else { let first_gadget = first.allocated(cs.ns(|| "first"))?; let second_gadget = second.allocated(cs.ns(|| "second"))?; diff --git a/compiler/src/value/integer/integer.rs b/compiler/src/value/integer/integer.rs index aadcad705f..812aa457ef 100644 --- a/compiler/src/value/integer/integer.rs +++ b/compiler/src/value/integer/integer.rs @@ -15,28 +15,24 @@ // along with the Leo library. If not, see . //! Conversion of integer declarations to constraints in Leo. -use crate::errors::IntegerError; -use crate::IntegerTrait; -use leo_asg::ConstInt; -use leo_asg::IntegerType; -use leo_asg::Span; +use crate::{errors::IntegerError, IntegerTrait}; +use leo_asg::{ConstInt, IntegerType, Span}; use leo_ast::InputValue; -use leo_gadgets::arithmetic::*; -use leo_gadgets::bits::comparator::ComparatorGadget; -use leo_gadgets::bits::comparator::EvaluateLtGadget; -use leo_gadgets::signed_integer::*; +use leo_gadgets::{ + arithmetic::*, + bits::comparator::{ComparatorGadget, EvaluateLtGadget}, + signed_integer::*, +}; -use snarkvm_fields::Field; -use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::ConditionalEqGadget; -use snarkvm_gadgets::traits::utilities::eq::EqGadget; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_gadgets::traits::utilities::uint::*; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_fields::{Field, PrimeField}; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + boolean::Boolean, + eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget}, + select::CondSelectGadget, + uint::*, +}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; use std::fmt; /// An integer type enum wrapping the integer value. diff --git a/compiler/src/value/integer/macros.rs b/compiler/src/value/integer/macros.rs index e62ee6fcb5..13d0ad2b2a 100644 --- a/compiler/src/value/integer/macros.rs +++ b/compiler/src/value/integer/macros.rs @@ -16,12 +16,10 @@ use leo_gadgets::signed_integer::*; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::uint::UInt128; -use snarkvm_gadgets::traits::utilities::uint::UInt16; -use snarkvm_gadgets::traits::utilities::uint::UInt32; -use snarkvm_gadgets::traits::utilities::uint::UInt64; -use snarkvm_gadgets::traits::utilities::uint::UInt8; +use snarkvm_gadgets::traits::utilities::{ + boolean::Boolean, + uint::{UInt128, UInt16, UInt32, UInt64, UInt8}, +}; use std::fmt::Debug; pub trait IntegerTrait: Sized + Clone + Debug { diff --git a/compiler/src/value/value.rs b/compiler/src/value/value.rs index 99cdbfffe8..78bb36846f 100644 --- a/compiler/src/value/value.rs +++ b/compiler/src/value/value.rs @@ -16,22 +16,12 @@ //! The in memory stored value for a defined name in a compiled Leo program. -use crate::errors::ValueError; -use crate::Address; -use crate::FieldType; -use crate::GroupType; -use crate::Integer; -use leo_asg::Circuit; -use leo_asg::Identifier; -use leo_asg::Span; -use leo_asg::Type; +use crate::{errors::ValueError, Address, FieldType, GroupType, Integer}; +use leo_asg::{Circuit, Identifier, Span, Type}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::ConditionalEqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, eq::ConditionalEqGadget, select::CondSelectGadget}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; use std::fmt; #[derive(Clone, PartialEq, Eq)] diff --git a/compiler/tests/address/mod.rs b/compiler/tests/address/mod.rs index d673192650..b0193ffbdf 100644 --- a/compiler/tests/address/mod.rs +++ b/compiler/tests/address/mod.rs @@ -14,11 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::parse_program; +use crate::{assert_satisfied, expect_asg_error, expect_compiler_error, generate_main_input, parse_program}; use leo_ast::InputValue; static TEST_ADDRESS_1: &str = "aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8"; diff --git a/compiler/tests/array/mod.rs b/compiler/tests/array/mod.rs index 6c41ce7c3d..fb01748d2f 100644 --- a/compiler/tests/array/mod.rs +++ b/compiler/tests/array/mod.rs @@ -14,13 +14,15 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::get_output; -use crate::parse_program; -use crate::parse_program_with_input; -use crate::EdwardsTestCompiler; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + get_output, + parse_program, + parse_program_with_input, + EdwardsTestCompiler, +}; pub fn output_ones(program: EdwardsTestCompiler) { let expected = include_bytes!("output/registers_ones.out"); diff --git a/compiler/tests/boolean/mod.rs b/compiler/tests/boolean/mod.rs index 768920731c..4051bf83d9 100644 --- a/compiler/tests/boolean/mod.rs +++ b/compiler/tests/boolean/mod.rs @@ -14,13 +14,15 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::get_output; -use crate::parse_program; -use crate::parse_program_with_input; -use crate::EdwardsTestCompiler; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + get_output, + parse_program, + parse_program_with_input, + EdwardsTestCompiler, +}; pub fn output_true(program: EdwardsTestCompiler) { let expected = include_bytes!("output/registers_true.out"); diff --git a/compiler/tests/circuits/mod.rs b/compiler/tests/circuits/mod.rs index 1c57e896dc..3fe4b54955 100644 --- a/compiler/tests/circuits/mod.rs +++ b/compiler/tests/circuits/mod.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::parse_program; +use crate::{assert_satisfied, expect_asg_error, parse_program}; // Expressions diff --git a/compiler/tests/compiler/mod.rs b/compiler/tests/compiler/mod.rs index ec9b64bc53..d07b11b69a 100644 --- a/compiler/tests/compiler/mod.rs +++ b/compiler/tests/compiler/mod.rs @@ -14,11 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::get_output; -use crate::EdwardsTestCompiler; +use crate::{get_output, EdwardsTestCompiler}; -use std::env::current_dir; -use std::path::PathBuf; +use std::{env::current_dir, path::PathBuf}; static MAIN_FILE_NAME: &str = "tests/compiler/main.leo"; diff --git a/compiler/tests/console/mod.rs b/compiler/tests/console/mod.rs index 954918cb94..62ff5bce6f 100644 --- a/compiler/tests/console/mod.rs +++ b/compiler/tests/console/mod.rs @@ -14,12 +14,14 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::parse_program; -use crate::parse_program_with_input; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + parse_program, + parse_program_with_input, +}; use leo_ast::InputValue; #[test] diff --git a/compiler/tests/core/mod.rs b/compiler/tests/core/mod.rs index 598606fba7..c4a6bb48a5 100644 --- a/compiler/tests/core/mod.rs +++ b/compiler/tests/core/mod.rs @@ -16,9 +16,7 @@ pub mod packages; -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::parse_program; +use crate::{assert_satisfied, expect_asg_error, parse_program}; #[test] fn test_core_circuit_invalid() { diff --git a/compiler/tests/core/packages/unstable/blake2s/mod.rs b/compiler/tests/core/packages/unstable/blake2s/mod.rs index 63e044a514..ce9a23b2f3 100644 --- a/compiler/tests/core/packages/unstable/blake2s/mod.rs +++ b/compiler/tests/core/packages/unstable/blake2s/mod.rs @@ -14,22 +14,21 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::generate_main_input; -use crate::get_output; -use crate::parse_program; -use crate::parse_program_with_input; +use crate::{ + assert_satisfied, + expect_asg_error, + generate_main_input, + get_output, + parse_program, + parse_program_with_input, +}; use leo_ast::InputValue; -use leo_input::types::IntegerType; -use leo_input::types::U8Type; -use leo_input::types::UnsignedIntegerType; +use leo_input::types::{IntegerType, U8Type, UnsignedIntegerType}; use rand::Rng; use rand_core::SeedableRng; use rand_xorshift::XorShiftRng; -use snarkvm_algorithms::prf::blake2s::Blake2s as B2SPRF; -use snarkvm_algorithms::traits::PRF; +use snarkvm_algorithms::{prf::blake2s::Blake2s as B2SPRF, traits::PRF}; #[test] fn test_arguments_length_fail() { diff --git a/compiler/tests/definition/mod.rs b/compiler/tests/definition/mod.rs index b6d4f463c9..e5faf8b2de 100644 --- a/compiler/tests/definition/mod.rs +++ b/compiler/tests/definition/mod.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::import::set_local_dir; -use crate::parse_program; +use crate::{assert_satisfied, import::set_local_dir, parse_program}; #[test] fn test_out_of_order() { diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index c3a7f9654f..6de6cd8153 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -14,11 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::get_output; -use crate::parse_program; -use crate::parse_program_with_input; +use crate::{assert_satisfied, expect_asg_error, get_output, parse_program, parse_program_with_input}; #[test] fn test_conditional_return() { diff --git a/compiler/tests/import/mod.rs b/compiler/tests/import/mod.rs index fccae4c6c6..1a3440b577 100644 --- a/compiler/tests/import/mod.rs +++ b/compiler/tests/import/mod.rs @@ -14,11 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::parse_program; +use crate::{assert_satisfied, parse_program}; -use std::env::current_dir; -use std::env::set_current_dir; +use std::env::{current_dir, set_current_dir}; static TEST_SOURCE_DIRECTORY: &str = "tests/import"; diff --git a/compiler/tests/input_files/program_input/mod.rs b/compiler/tests/input_files/program_input/mod.rs index c82135b381..529a512fdb 100644 --- a/compiler/tests/input_files/program_input/mod.rs +++ b/compiler/tests/input_files/program_input/mod.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_compiler_error; -use crate::parse_program_with_input; -use crate::EdwardsTestCompiler; +use crate::{assert_satisfied, expect_compiler_error, parse_program_with_input, EdwardsTestCompiler}; use leo_compiler::errors::CompilerError; fn expect_fail(program: EdwardsTestCompiler) { diff --git a/compiler/tests/input_files/program_input_and_program_state/mod.rs b/compiler/tests/input_files/program_input_and_program_state/mod.rs index 14d433c07b..25541030ab 100644 --- a/compiler/tests/input_files/program_input_and_program_state/mod.rs +++ b/compiler/tests/input_files/program_input_and_program_state/mod.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::parse_input_and_state; -use crate::parse_program_with_input_and_state; +use crate::{assert_satisfied, parse_input_and_state, parse_program_with_input_and_state}; #[test] fn test_basic() { diff --git a/compiler/tests/input_files/program_registers/mod.rs b/compiler/tests/input_files/program_registers/mod.rs index 43565f75d6..b172c141e0 100644 --- a/compiler/tests/input_files/program_registers/mod.rs +++ b/compiler/tests/input_files/program_registers/mod.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::expect_compiler_error; -use crate::get_output; -use crate::parse_program_with_input; +use crate::{expect_compiler_error, get_output, parse_program_with_input}; #[test] fn test_registers_pass() { diff --git a/compiler/tests/input_files/program_state/mod.rs b/compiler/tests/input_files/program_state/mod.rs index 5a9c1ff24c..c5959196f5 100644 --- a/compiler/tests/input_files/program_state/mod.rs +++ b/compiler/tests/input_files/program_state/mod.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::parse_program_with_state; -use crate::parse_state; +use crate::{assert_satisfied, parse_program_with_state, parse_state}; #[test] fn test_basic() { diff --git a/compiler/tests/integers/i128/mod.rs b/compiler/tests/integers/i128/mod.rs index e1885f7ffe..e62e07260e 100644 --- a/compiler/tests/integers/i128/mod.rs +++ b/compiler/tests/integers/i128/mod.rs @@ -14,17 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::expect_computation_error; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::I128Type; -use leo_input::types::IntegerType; -use leo_input::types::SignedIntegerType; +use leo_input::types::{I128Type, IntegerType, SignedIntegerType}; test_int!( TestI128, diff --git a/compiler/tests/integers/i16/mod.rs b/compiler/tests/integers/i16/mod.rs index 57404f5a30..49b45f5b3e 100644 --- a/compiler/tests/integers/i16/mod.rs +++ b/compiler/tests/integers/i16/mod.rs @@ -14,17 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::expect_computation_error; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::I16Type; -use leo_input::types::IntegerType; -use leo_input::types::SignedIntegerType; +use leo_input::types::{I16Type, IntegerType, SignedIntegerType}; test_int!( TestI16, diff --git a/compiler/tests/integers/i32/mod.rs b/compiler/tests/integers/i32/mod.rs index 965c96573f..ee9e25701a 100644 --- a/compiler/tests/integers/i32/mod.rs +++ b/compiler/tests/integers/i32/mod.rs @@ -14,17 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::expect_computation_error; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::I32Type; -use leo_input::types::IntegerType; -use leo_input::types::SignedIntegerType; +use leo_input::types::{I32Type, IntegerType, SignedIntegerType}; test_int!( TestI32, diff --git a/compiler/tests/integers/i64/mod.rs b/compiler/tests/integers/i64/mod.rs index 083f04368b..066ac9956f 100644 --- a/compiler/tests/integers/i64/mod.rs +++ b/compiler/tests/integers/i64/mod.rs @@ -14,17 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::expect_computation_error; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::I64Type; -use leo_input::types::IntegerType; -use leo_input::types::SignedIntegerType; +use leo_input::types::{I64Type, IntegerType, SignedIntegerType}; test_int!( TestI64, diff --git a/compiler/tests/integers/i8/mod.rs b/compiler/tests/integers/i8/mod.rs index f7b4e46446..9133a72248 100644 --- a/compiler/tests/integers/i8/mod.rs +++ b/compiler/tests/integers/i8/mod.rs @@ -14,17 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::expect_computation_error; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::{expect_computation_error, IntegerTester}, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::I8Type; -use leo_input::types::IntegerType; -use leo_input::types::SignedIntegerType; +use leo_input::types::{I8Type, IntegerType, SignedIntegerType}; test_int!( TestI8, diff --git a/compiler/tests/integers/integer_tester.rs b/compiler/tests/integers/integer_tester.rs index bec296d6e2..23085d5aac 100644 --- a/compiler/tests/integers/integer_tester.rs +++ b/compiler/tests/integers/integer_tester.rs @@ -14,13 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::expect_compiler_error; -use crate::EdwardsTestCompiler; -use leo_compiler::errors::CompilerError; -use leo_compiler::errors::ExpressionError; -use leo_compiler::errors::FunctionError; -use leo_compiler::errors::IntegerError; -use leo_compiler::errors::StatementError; +use crate::{expect_compiler_error, EdwardsTestCompiler}; +use leo_compiler::errors::{CompilerError, ExpressionError, FunctionError, IntegerError, StatementError}; pub trait IntegerTester { /// Tests defining the smalled value that can be represented by the integer type diff --git a/compiler/tests/integers/u128/mod.rs b/compiler/tests/integers/u128/mod.rs index db276cea75..2c110af0a5 100644 --- a/compiler/tests/integers/u128/mod.rs +++ b/compiler/tests/integers/u128/mod.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::IntegerType; -use leo_input::types::U128Type; -use leo_input::types::UnsignedIntegerType; +use leo_input::types::{IntegerType, U128Type, UnsignedIntegerType}; test_uint!( TestU128, diff --git a/compiler/tests/integers/u16/mod.rs b/compiler/tests/integers/u16/mod.rs index 68b66429cd..b4b202b9da 100644 --- a/compiler/tests/integers/u16/mod.rs +++ b/compiler/tests/integers/u16/mod.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::IntegerType; -use leo_input::types::U16Type; -use leo_input::types::UnsignedIntegerType; +use leo_input::types::{IntegerType, U16Type, UnsignedIntegerType}; test_uint!( TestU16, diff --git a/compiler/tests/integers/u32/mod.rs b/compiler/tests/integers/u32/mod.rs index 7a646f0720..920fc6ed5b 100644 --- a/compiler/tests/integers/u32/mod.rs +++ b/compiler/tests/integers/u32/mod.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::IntegerType; -use leo_input::types::U32Type; -use leo_input::types::UnsignedIntegerType; +use leo_input::types::{IntegerType, U32Type, UnsignedIntegerType}; test_uint!( TestU32, diff --git a/compiler/tests/integers/u64/mod.rs b/compiler/tests/integers/u64/mod.rs index 4a76455959..ec86c868f1 100644 --- a/compiler/tests/integers/u64/mod.rs +++ b/compiler/tests/integers/u64/mod.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::IntegerType; -use leo_input::types::U64Type; -use leo_input::types::UnsignedIntegerType; +use leo_input::types::{IntegerType, U64Type, UnsignedIntegerType}; test_uint!( TestU64, diff --git a/compiler/tests/integers/u8/mod.rs b/compiler/tests/integers/u8/mod.rs index d8ea4ade30..a61e28246d 100644 --- a/compiler/tests/integers/u8/mod.rs +++ b/compiler/tests/integers/u8/mod.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::integers::IntegerTester; -use crate::parse_program; +use crate::{ + assert_satisfied, + expect_asg_error, + expect_compiler_error, + generate_main_input, + integers::IntegerTester, + parse_program, +}; use leo_ast::InputValue; -use leo_input::types::IntegerType; -use leo_input::types::U8Type; -use leo_input::types::UnsignedIntegerType; +use leo_input::types::{IntegerType, U8Type, UnsignedIntegerType}; test_uint!( TestU8, diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index 1b7b3d47be..5b34767f43 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -36,19 +36,16 @@ pub mod statements; pub mod syntax; pub mod tuples; -use leo_asg::new_alloc_context; -use leo_asg::new_context; -use leo_asg::AsgContext; -use leo_ast::InputValue; -use leo_ast::MainInput; -use leo_compiler::compiler::Compiler; -use leo_compiler::errors::CompilerError; -use leo_compiler::group::targets::edwards_bls12::EdwardsGroupType; -use leo_compiler::ConstrainedValue; -use leo_compiler::OutputBytes; -use leo_input::types::IntegerType; -use leo_input::types::U32Type; -use leo_input::types::UnsignedIntegerType; +use leo_asg::{new_alloc_context, new_context, AsgContext}; +use leo_ast::{InputValue, MainInput}; +use leo_compiler::{ + compiler::Compiler, + errors::CompilerError, + group::targets::edwards_bls12::EdwardsGroupType, + ConstrainedValue, + OutputBytes, +}; +use leo_input::types::{IntegerType, U32Type, UnsignedIntegerType}; use snarkvm_curves::edwards_bls12::Fq; use snarkvm_r1cs::TestConstraintSystem; diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index 4583d007d1..ded55960bb 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::generate_main_input; -use crate::parse_program; +use crate::{assert_satisfied, expect_asg_error, generate_main_input, parse_program}; use leo_ast::InputValue; #[test] diff --git a/compiler/tests/statements/conditional/mod.rs b/compiler/tests/statements/conditional/mod.rs index f3ea03a39f..040c8108dd 100644 --- a/compiler/tests/statements/conditional/mod.rs +++ b/compiler/tests/statements/conditional/mod.rs @@ -14,14 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_compiler_error; -use crate::generate_main_input; -use crate::generate_test_input_u32; -use crate::get_output; -use crate::parse_program; -use crate::parse_program_with_input; -use crate::EdwardsTestCompiler; +use crate::{ + assert_satisfied, + expect_compiler_error, + generate_main_input, + generate_test_input_u32, + get_output, + parse_program, + parse_program_with_input, + EdwardsTestCompiler, +}; use leo_ast::InputValue; #[test] diff --git a/compiler/tests/statements/mod.rs b/compiler/tests/statements/mod.rs index a200744c7b..3aeb3f858b 100644 --- a/compiler/tests/statements/mod.rs +++ b/compiler/tests/statements/mod.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::expect_asg_error; -use crate::generate_main_input; -use crate::parse_program; +use crate::{assert_satisfied, expect_asg_error, generate_main_input, parse_program}; use leo_ast::InputValue; pub mod conditional; diff --git a/compiler/tests/syntax/mod.rs b/compiler/tests/syntax/mod.rs index 684af5468d..2fb1a100ea 100644 --- a/compiler/tests/syntax/mod.rs +++ b/compiler/tests/syntax/mod.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::expect_asg_error; -use crate::parse_input; -use crate::parse_program; +use crate::{expect_asg_error, parse_input, parse_program}; use leo_compiler::errors::CompilerError; use leo_grammar::ParserError; use leo_input::InputParserError; diff --git a/compiler/tests/tuples/mod.rs b/compiler/tests/tuples/mod.rs index 3afece0f86..67798288a6 100644 --- a/compiler/tests/tuples/mod.rs +++ b/compiler/tests/tuples/mod.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::assert_satisfied; -use crate::parse_program; +use crate::{assert_satisfied, parse_program}; #[test] fn test_tuple_basic() { diff --git a/gadgets/benches/integer_arithmetic.rs b/gadgets/benches/integer_arithmetic.rs index f8d788daa0..a75546d7e4 100644 --- a/gadgets/benches/integer_arithmetic.rs +++ b/gadgets/benches/integer_arithmetic.rs @@ -14,26 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::arithmetic::*; -use leo_gadgets::Int128; -use leo_gadgets::Int16; -use leo_gadgets::Int32; -use leo_gadgets::Int64; -use leo_gadgets::Int8; +use leo_gadgets::{arithmetic::*, Int128, Int16, Int32, Int64, Int8}; use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Fr; -use snarkvm_r1cs::TestConstraintSystem; +use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem}; -use rand::Rng; -use rand::SeedableRng; +use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; use std::i128; -use criterion::criterion_group; -use criterion::criterion_main; -use criterion::Criterion; +use criterion::{criterion_group, criterion_main, Criterion}; macro_rules! create_add_bench { ($bench_name:ident, $bench_id:expr, $foo_name:ident, $std_type:ty, $bit_type:ty) => { diff --git a/gadgets/src/arithmetic/add.rs b/gadgets/src/arithmetic/add.rs index d4ea613984..eada6b2c3b 100644 --- a/gadgets/src/arithmetic/add.rs +++ b/gadgets/src/arithmetic/add.rs @@ -14,16 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use snarkvm_fields::Field; -use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::uint::UInt; -use snarkvm_gadgets::traits::utilities::uint::UInt128; -use snarkvm_gadgets::traits::utilities::uint::UInt16; -use snarkvm_gadgets::traits::utilities::uint::UInt32; -use snarkvm_gadgets::traits::utilities::uint::UInt64; -use snarkvm_gadgets::traits::utilities::uint::UInt8; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_fields::{Field, PrimeField}; +use snarkvm_gadgets::traits::utilities::uint::{UInt, UInt128, UInt16, UInt32, UInt64, UInt8}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; /// Returns addition of `self` + `other` in the constraint system. pub trait Add diff --git a/gadgets/src/arithmetic/neg.rs b/gadgets/src/arithmetic/neg.rs index 62afbe45ea..170014950a 100644 --- a/gadgets/src/arithmetic/neg.rs +++ b/gadgets/src/arithmetic/neg.rs @@ -18,8 +18,7 @@ use crate::bits::RippleCarryAdder; use snarkvm_fields::Field; use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; use std::iter; diff --git a/gadgets/src/bits/adder.rs b/gadgets/src/bits/adder.rs index fdca3fe2ee..9ebc028a7e 100644 --- a/gadgets/src/bits/adder.rs +++ b/gadgets/src/bits/adder.rs @@ -16,8 +16,7 @@ use snarkvm_fields::Field; use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; /// Single bit binary adder with carry bit /// https://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder diff --git a/gadgets/src/bits/comparator.rs b/gadgets/src/bits/comparator.rs index 881dcd8434..ef0a6fc5ad 100644 --- a/gadgets/src/bits/comparator.rs +++ b/gadgets/src/bits/comparator.rs @@ -14,17 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use snarkvm_fields::Field; -use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_gadgets::traits::utilities::uint::UInt128; -use snarkvm_gadgets::traits::utilities::uint::UInt16; -use snarkvm_gadgets::traits::utilities::uint::UInt32; -use snarkvm_gadgets::traits::utilities::uint::UInt64; -use snarkvm_gadgets::traits::utilities::uint::UInt8; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_fields::{Field, PrimeField}; +use snarkvm_gadgets::traits::utilities::{ + boolean::Boolean, + select::CondSelectGadget, + uint::{UInt128, UInt16, UInt32, UInt64, UInt8}, +}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; pub trait EvaluateLtGadget { fn less_than>(&self, cs: CS, other: &Self) -> Result; diff --git a/gadgets/src/bits/rca.rs b/gadgets/src/bits/rca.rs index 1954ab5865..270e7d2415 100644 --- a/gadgets/src/bits/rca.rs +++ b/gadgets/src/bits/rca.rs @@ -14,14 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::bits::FullAdder; -use crate::signed_integer::*; +use crate::{bits::FullAdder, signed_integer::*}; -use snarkvm_fields::Field; -use snarkvm_fields::PrimeField; +use snarkvm_fields::{Field, PrimeField}; use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; /// Returns the bitwise sum of a n-bit number with carry bit pub trait RippleCarryAdder diff --git a/gadgets/src/signed_integer/arithmetic/add.rs b/gadgets/src/signed_integer/arithmetic/add.rs index af2020c3ed..be7ae00cea 100644 --- a/gadgets/src/signed_integer/arithmetic/add.rs +++ b/gadgets/src/signed_integer/arithmetic/add.rs @@ -14,24 +14,24 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::arithmetic::Add; -use crate::bits::RippleCarryAdder; -use crate::errors::SignedIntegerError; -use crate::Int; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; +use crate::{ + arithmetic::Add, + bits::RippleCarryAdder, + errors::SignedIntegerError, + Int, + Int128, + Int16, + Int32, + Int64, + Int8, +}; -use snarkvm_fields::fp_parameters::FpParameters; -use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::AllocatedBit; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::Assignment; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::LinearCombination; +use snarkvm_fields::{fp_parameters::FpParameters, PrimeField}; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + boolean::{AllocatedBit, Boolean}, +}; +use snarkvm_r1cs::{Assignment, ConstraintSystem, LinearCombination}; macro_rules! add_int_impl { ($($gadget: ident)*) => ($( diff --git a/gadgets/src/signed_integer/arithmetic/div.rs b/gadgets/src/signed_integer/arithmetic/div.rs index b0f93b21a3..6f93029abc 100644 --- a/gadgets/src/signed_integer/arithmetic/div.rs +++ b/gadgets/src/signed_integer/arithmetic/div.rs @@ -14,24 +14,24 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::arithmetic::Add; -use crate::arithmetic::Div; -use crate::arithmetic::Neg; -use crate::arithmetic::Sub; -use crate::bits::ComparatorGadget; -use crate::errors::SignedIntegerError; -use crate::Int; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; +use crate::{ + arithmetic::{Add, Div, Neg, Sub}, + bits::ComparatorGadget, + errors::SignedIntegerError, + Int, + Int128, + Int16, + Int32, + Int64, + Int8, +}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::AllocatedBit; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + boolean::{AllocatedBit, Boolean}, + eq::EvaluateEqGadget, + select::CondSelectGadget, +}; use snarkvm_r1cs::ConstraintSystem; macro_rules! div_int_impl { diff --git a/gadgets/src/signed_integer/arithmetic/mul.rs b/gadgets/src/signed_integer/arithmetic/mul.rs index 4e0d3568a4..fb6b792715 100644 --- a/gadgets/src/signed_integer/arithmetic/mul.rs +++ b/gadgets/src/signed_integer/arithmetic/mul.rs @@ -14,25 +14,24 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::arithmetic::Mul; -use crate::bits::RippleCarryAdder; -use crate::bits::SignExtend; -use crate::errors::SignedIntegerError; -use crate::Int; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; -use snarkvm_fields::FpParameters; -use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::AllocatedBit; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_r1cs::Assignment; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::LinearCombination; +use crate::{ + arithmetic::Mul, + bits::{RippleCarryAdder, SignExtend}, + errors::SignedIntegerError, + Int, + Int128, + Int16, + Int32, + Int64, + Int8, +}; +use snarkvm_fields::{FpParameters, PrimeField}; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + boolean::{AllocatedBit, Boolean}, + select::CondSelectGadget, +}; +use snarkvm_r1cs::{Assignment, ConstraintSystem, LinearCombination}; use std::iter; diff --git a/gadgets/src/signed_integer/arithmetic/neg.rs b/gadgets/src/signed_integer/arithmetic/neg.rs index 28955cced5..3f802878bf 100644 --- a/gadgets/src/signed_integer/arithmetic/neg.rs +++ b/gadgets/src/signed_integer/arithmetic/neg.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::arithmetic::Neg; -use crate::errors::SignedIntegerError; -use crate::signed_integer::*; +use crate::{arithmetic::Neg, errors::SignedIntegerError, signed_integer::*}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/gadgets/src/signed_integer/arithmetic/pow.rs b/gadgets/src/signed_integer/arithmetic/pow.rs index 7838fd7625..3f6467978f 100644 --- a/gadgets/src/signed_integer/arithmetic/pow.rs +++ b/gadgets/src/signed_integer/arithmetic/pow.rs @@ -14,20 +14,19 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::arithmetic::Mul; -use crate::arithmetic::Pow; -use crate::errors::SignedIntegerError; -use crate::Int; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; +use crate::{ + arithmetic::{Mul, Pow}, + errors::SignedIntegerError, + Int, + Int128, + Int16, + Int32, + Int64, + Int8, +}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; +use snarkvm_gadgets::traits::utilities::{alloc::AllocGadget, boolean::Boolean, select::CondSelectGadget}; use snarkvm_r1cs::ConstraintSystem; macro_rules! pow_int_impl { diff --git a/gadgets/src/signed_integer/arithmetic/sub.rs b/gadgets/src/signed_integer/arithmetic/sub.rs index 77eebd25ca..fc3ae9a539 100644 --- a/gadgets/src/signed_integer/arithmetic/sub.rs +++ b/gadgets/src/signed_integer/arithmetic/sub.rs @@ -14,15 +14,15 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::arithmetic::Add; -use crate::arithmetic::Neg; -use crate::arithmetic::Sub; -use crate::errors::SignedIntegerError; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; +use crate::{ + arithmetic::{Add, Neg, Sub}, + errors::SignedIntegerError, + Int128, + Int16, + Int32, + Int64, + Int8, +}; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; diff --git a/gadgets/src/signed_integer/relational/cmp.rs b/gadgets/src/signed_integer/relational/cmp.rs index 167b729925..07b2537748 100644 --- a/gadgets/src/signed_integer/relational/cmp.rs +++ b/gadgets/src/signed_integer/relational/cmp.rs @@ -14,19 +14,18 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::bits::ComparatorGadget; -use crate::bits::EvaluateLtGadget; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; +use crate::{ + bits::{ComparatorGadget, EvaluateLtGadget}, + Int128, + Int16, + Int32, + Int64, + Int8, +}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, select::CondSelectGadget}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; use std::cmp::Ordering; macro_rules! cmp_gadget_impl { diff --git a/gadgets/src/signed_integer/relational/eq.rs b/gadgets/src/signed_integer/relational/eq.rs index d48330bdc4..0cc1dcf792 100644 --- a/gadgets/src/signed_integer/relational/eq.rs +++ b/gadgets/src/signed_integer/relational/eq.rs @@ -14,18 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Int; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; +use crate::{Int, Int128, Int16, Int32, Int64, Int8}; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::EvaluateEqGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, eq::EvaluateEqGadget}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; macro_rules! eq_gadget_impl { ($($gadget: ident)*) => ($( diff --git a/gadgets/src/signed_integer/utilities/alloc.rs b/gadgets/src/signed_integer/utilities/alloc.rs index efc856637c..154b12f48c 100644 --- a/gadgets/src/signed_integer/utilities/alloc.rs +++ b/gadgets/src/signed_integer/utilities/alloc.rs @@ -14,21 +14,15 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::Int; -use crate::Int128; -use crate::Int16; -use crate::Int32; -use crate::Int64; -use crate::Int8; +use crate::{Int, Int128, Int16, Int32, Int64, Int8}; -use core::borrow::Borrow; -use core::iter; +use core::{borrow::Borrow, iter}; use snarkvm_fields::Field; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::AllocatedBit; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + boolean::{AllocatedBit, Boolean}, +}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; fn create_value, I: IntoIterator>, F: Field, CS: ConstraintSystem>( cs: &mut CS, diff --git a/gadgets/src/signed_integer/utilities/eq.rs b/gadgets/src/signed_integer/utilities/eq.rs index 83a97a7daa..d3d9066f9c 100644 --- a/gadgets/src/signed_integer/utilities/eq.rs +++ b/gadgets/src/signed_integer/utilities/eq.rs @@ -17,10 +17,8 @@ use crate::signed_integer::*; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::ConditionalEqGadget; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{boolean::Boolean, eq::ConditionalEqGadget}; +use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; macro_rules! cond_eq_int_impl { ($($gadget: ident),*) => ($( diff --git a/gadgets/src/signed_integer/utilities/select.rs b/gadgets/src/signed_integer/utilities/select.rs index 22482ee801..8cbcede327 100644 --- a/gadgets/src/signed_integer/utilities/select.rs +++ b/gadgets/src/signed_integer/utilities/select.rs @@ -17,13 +17,13 @@ use crate::signed_integer::*; use snarkvm_fields::PrimeField; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_gadgets::traits::utilities::eq::EqGadget; -use snarkvm_gadgets::traits::utilities::select::CondSelectGadget; -use snarkvm_r1cs::Assignment; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::SynthesisError; +use snarkvm_gadgets::traits::utilities::{ + alloc::AllocGadget, + boolean::Boolean, + eq::EqGadget, + select::CondSelectGadget, +}; +use snarkvm_r1cs::{Assignment, ConstraintSystem, SynthesisError}; macro_rules! select_int_impl { ($($gadget: ident)*) => ($( diff --git a/gadgets/tests/signed_integer/i128.rs b/gadgets/tests/signed_integer/i128.rs index 7c0d38a67f..9efa1f4c7a 100644 --- a/gadgets/tests/signed_integer/i128.rs +++ b/gadgets/tests/signed_integer/i128.rs @@ -14,16 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::arithmetic::*; -use leo_gadgets::Int128; +use leo_gadgets::{arithmetic::*, Int128}; -use snarkvm_fields::One; -use snarkvm_fields::Zero; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Fr; -use snarkvm_r1cs::TestConstraintSystem; +use snarkvm_fields::{One, Zero}; +use snarkvm_gadgets::traits::utilities::{alloc::AllocGadget, boolean::Boolean}; +use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem}; use rand::Rng; use rand_core::SeedableRng; diff --git a/gadgets/tests/signed_integer/i16.rs b/gadgets/tests/signed_integer/i16.rs index dc6eaee2fb..c6e5af960b 100644 --- a/gadgets/tests/signed_integer/i16.rs +++ b/gadgets/tests/signed_integer/i16.rs @@ -14,16 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::arithmetic::*; -use leo_gadgets::Int16; +use leo_gadgets::{arithmetic::*, Int16}; -use snarkvm_fields::One; -use snarkvm_fields::Zero; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Fr; -use snarkvm_r1cs::TestConstraintSystem; +use snarkvm_fields::{One, Zero}; +use snarkvm_gadgets::traits::utilities::{alloc::AllocGadget, boolean::Boolean}; +use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem}; use rand::Rng; use rand_core::SeedableRng; diff --git a/gadgets/tests/signed_integer/i32.rs b/gadgets/tests/signed_integer/i32.rs index 9170aa98d0..fb9fee1c94 100644 --- a/gadgets/tests/signed_integer/i32.rs +++ b/gadgets/tests/signed_integer/i32.rs @@ -14,16 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::arithmetic::*; -use leo_gadgets::Int32; +use leo_gadgets::{arithmetic::*, Int32}; -use snarkvm_fields::One; -use snarkvm_fields::Zero; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Fr; -use snarkvm_r1cs::TestConstraintSystem; +use snarkvm_fields::{One, Zero}; +use snarkvm_gadgets::traits::utilities::{alloc::AllocGadget, boolean::Boolean}; +use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem}; use rand::Rng; use rand_core::SeedableRng; diff --git a/gadgets/tests/signed_integer/i64.rs b/gadgets/tests/signed_integer/i64.rs index 030cac373c..2aee9111c5 100644 --- a/gadgets/tests/signed_integer/i64.rs +++ b/gadgets/tests/signed_integer/i64.rs @@ -14,16 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::arithmetic::*; -use leo_gadgets::Int64; +use leo_gadgets::{arithmetic::*, Int64}; -use snarkvm_fields::One; -use snarkvm_fields::Zero; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Fr; -use snarkvm_r1cs::TestConstraintSystem; +use snarkvm_fields::{One, Zero}; +use snarkvm_gadgets::traits::utilities::{alloc::AllocGadget, boolean::Boolean}; +use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem}; use rand::Rng; use rand_core::SeedableRng; diff --git a/gadgets/tests/signed_integer/i8.rs b/gadgets/tests/signed_integer/i8.rs index 9a3aad4340..b8eaef23ed 100644 --- a/gadgets/tests/signed_integer/i8.rs +++ b/gadgets/tests/signed_integer/i8.rs @@ -14,16 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::arithmetic::*; -use leo_gadgets::Int8; +use leo_gadgets::{arithmetic::*, Int8}; -use snarkvm_fields::One; -use snarkvm_fields::Zero; -use snarkvm_gadgets::traits::utilities::alloc::AllocGadget; -use snarkvm_gadgets::traits::utilities::boolean::Boolean; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Fr; -use snarkvm_r1cs::TestConstraintSystem; +use snarkvm_fields::{One, Zero}; +use snarkvm_gadgets::traits::utilities::{alloc::AllocGadget, boolean::Boolean}; +use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem}; use rand::Rng; use rand_core::SeedableRng; diff --git a/grammar/benches/grammar.rs b/grammar/benches/grammar.rs index ed493c740a..ec24d5edb7 100644 --- a/grammar/benches/grammar.rs +++ b/grammar/benches/grammar.rs @@ -16,10 +16,7 @@ use leo_grammar::Grammar; -use criterion::black_box; -use criterion::criterion_group; -use criterion::criterion_main; -use criterion::Criterion; +use criterion::{black_box, criterion_group, criterion_main, Criterion}; use std::path::Path; fn leo_grammar<'ast>(filepath: &'ast Path, program_string: &'ast str) { diff --git a/grammar/src/access/access.rs b/grammar/src/access/access.rs index 914e994783..1c33808692 100644 --- a/grammar/src/access/access.rs +++ b/grammar/src/access/access.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::access::*; -use crate::ast::Rule; +use crate::{access::*, ast::Rule}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/access/array_access.rs b/grammar/src/access/array_access.rs index 3f99db6242..fe98590ce9 100644 --- a/grammar/src/access/array_access.rs +++ b/grammar/src/access/array_access.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::RangeOrExpression; -use crate::SpanDef; +use crate::{ast::Rule, common::RangeOrExpression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/access/assignee_access.rs b/grammar/src/access/assignee_access.rs index 26cd172fa1..880ad65255 100644 --- a/grammar/src/access/assignee_access.rs +++ b/grammar/src/access/assignee_access.rs @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::access::ArrayAccess; -use crate::access::MemberAccess; -use crate::access::TupleAccess; -use crate::ast::Rule; +use crate::{ + access::{ArrayAccess, MemberAccess, TupleAccess}, + ast::Rule, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/access/call_access.rs b/grammar/src/access/call_access.rs index dcfaefd692..398c05a3f9 100644 --- a/grammar/src/access/call_access.rs +++ b/grammar/src/access/call_access.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/access/member_access.rs b/grammar/src/access/member_access.rs index 45d05e18e7..a3e2e9e030 100644 --- a/grammar/src/access/member_access.rs +++ b/grammar/src/access/member_access.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/access/self_access.rs b/grammar/src/access/self_access.rs index 2fc38d50ae..4c4c171835 100644 --- a/grammar/src/access/self_access.rs +++ b/grammar/src/access/self_access.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::access::*; -use crate::ast::Rule; +use crate::{access::*, ast::Rule}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/access/static_member_access.rs b/grammar/src/access/static_member_access.rs index dd195cabeb..7452d3e804 100644 --- a/grammar/src/access/static_member_access.rs +++ b/grammar/src/access/static_member_access.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/access/tuple_access.rs b/grammar/src/access/tuple_access.rs index 25631d6cfb..952e6a426f 100644 --- a/grammar/src/access/tuple_access.rs +++ b/grammar/src/access/tuple_access.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::PositiveNumber; -use crate::SpanDef; +use crate::{ast::Rule, values::PositiveNumber, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/annotations/annotation_arguments.rs b/grammar/src/annotations/annotation_arguments.rs index 9447b490c2..bf58a2c358 100644 --- a/grammar/src/annotations/annotation_arguments.rs +++ b/grammar/src/annotations/annotation_arguments.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/annotations/annotation_name.rs b/grammar/src/annotations/annotation_name.rs index ebda9440cd..d7cb1c12c9 100644 --- a/grammar/src/annotations/annotation_name.rs +++ b/grammar/src/annotations/annotation_name.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ast::Rule, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/annotations/annotation_symbol.rs b/grammar/src/annotations/annotation_symbol.rs index f555884ab7..16f042be92 100644 --- a/grammar/src/annotations/annotation_symbol.rs +++ b/grammar/src/annotations/annotation_symbol.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ast::Rule, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/annotations/annotations.rs b/grammar/src/annotations/annotations.rs index d84d105d60..045eb3a47e 100644 --- a/grammar/src/annotations/annotations.rs +++ b/grammar/src/annotations/annotations.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::annotations::AnnotationArguments; -use crate::annotations::AnnotationName; -use crate::annotations::AnnotationSymbol; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + annotations::{AnnotationArguments, AnnotationName, AnnotationSymbol}, + ast::Rule, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/ast.rs b/grammar/src/ast.rs index b1c63f8f82..87da0a1967 100644 --- a/grammar/src/ast.rs +++ b/grammar/src/ast.rs @@ -15,31 +15,31 @@ // along with the Leo library. If not, see . //! Abstract syntax tree (ast) representation from leo.pest. -use crate::common::Identifier; -use crate::expressions::ArrayInitializerExpression; -use crate::expressions::ArrayInlineExpression; -use crate::expressions::CircuitInlineExpression; -use crate::expressions::Expression; -use crate::expressions::PostfixExpression; -use crate::expressions::SelfPostfixExpression; -use crate::expressions::TernaryExpression; -use crate::expressions::UnaryExpression; -use crate::operations::BinaryOperation; -use crate::operations::UnaryOperation; -use crate::values::Value; +use crate::{ + common::Identifier, + expressions::{ + ArrayInitializerExpression, + ArrayInlineExpression, + CircuitInlineExpression, + Expression, + PostfixExpression, + SelfPostfixExpression, + TernaryExpression, + UnaryExpression, + }, + operations::{BinaryOperation, UnaryOperation}, + values::Value, +}; use crate::expressions::TupleExpression; -use from_pest::ConversionError; -use from_pest::FromPest; -use from_pest::Void; -use pest::error::Error; -use pest::iterators::Pair; -use pest::iterators::Pairs; -use pest::prec_climber::Assoc; -use pest::prec_climber::Operator; -use pest::prec_climber::PrecClimber; -use pest::Parser; -use pest::Span; +use from_pest::{ConversionError, FromPest, Void}; +use pest::{ + error::Error, + iterators::{Pair, Pairs}, + prec_climber::{Assoc, Operator, PrecClimber}, + Parser, + Span, +}; #[derive(Parser)] #[grammar = "leo.pest"] diff --git a/grammar/src/circuits/circuit.rs b/grammar/src/circuits/circuit.rs index e719a7605c..a704df6962 100644 --- a/grammar/src/circuits/circuit.rs +++ b/grammar/src/circuits/circuit.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::circuits::CircuitMember; -use crate::common::Identifier; -use crate::SpanDef; +use crate::{ast::Rule, circuits::CircuitMember, common::Identifier, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/circuits/circuit_implied_variable.rs b/grammar/src/circuits/circuit_implied_variable.rs index 0f8111e549..eeb9aee4bb 100644 --- a/grammar/src/circuits/circuit_implied_variable.rs +++ b/grammar/src/circuits/circuit_implied_variable.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::circuits::CircuitVariable; -use crate::common::Identifier; +use crate::{ast::Rule, circuits::CircuitVariable, common::Identifier}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/circuits/circuit_member.rs b/grammar/src/circuits/circuit_member.rs index f451a28ffd..6ce1c822b8 100644 --- a/grammar/src/circuits/circuit_member.rs +++ b/grammar/src/circuits/circuit_member.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::circuits::CircuitVariableDefinition; -use crate::functions::Function; +use crate::{ast::Rule, circuits::CircuitVariableDefinition, functions::Function}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/circuits/circuit_variable.rs b/grammar/src/circuits/circuit_variable.rs index 099422b632..30c35bbb0a 100644 --- a/grammar/src/circuits/circuit_variable.rs +++ b/grammar/src/circuits/circuit_variable.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/circuits/circuit_variable_definition.rs b/grammar/src/circuits/circuit_variable_definition.rs index e1da1f7bc6..cef9933bc6 100644 --- a/grammar/src/circuits/circuit_variable_definition.rs +++ b/grammar/src/circuits/circuit_variable_definition.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::types::Type; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, types::Type, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/assignee.rs b/grammar/src/common/assignee.rs index 77d8038db5..066fe1b0dd 100644 --- a/grammar/src/common/assignee.rs +++ b/grammar/src/common/assignee.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::access::AssigneeAccess; -use crate::ast::Rule; -use crate::common::SelfKeywordOrIdentifier; -use crate::SpanDef; +use crate::{access::AssigneeAccess, ast::Rule, common::SelfKeywordOrIdentifier, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/eoi.rs b/grammar/src/common/eoi.rs index 34d32d9ba0..b37cf4f230 100644 --- a/grammar/src/common/eoi.rs +++ b/grammar/src/common/eoi.rs @@ -17,8 +17,7 @@ use crate::ast::Rule; use pest_ast::FromPest; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, FromPest, PartialEq, Serialize, Deserialize)] #[pest_ast(rule(Rule::EOI))] diff --git a/grammar/src/common/identifier.rs b/grammar/src/common/identifier.rs index 9326593bff..0406e51336 100644 --- a/grammar/src/common/identifier.rs +++ b/grammar/src/common/identifier.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/keyword_or_identifier.rs b/grammar/src/common/keyword_or_identifier.rs index 71e28485fa..5ab05f5dad 100644 --- a/grammar/src/common/keyword_or_identifier.rs +++ b/grammar/src/common/keyword_or_identifier.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::functions::InputKeyword; -use crate::types::SelfType; +use crate::{ast::Rule, common::Identifier, functions::InputKeyword, types::SelfType}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/common/mut_self_keyword.rs b/grammar/src/common/mut_self_keyword.rs index 9c0cb39ee3..1ddc0cfa57 100644 --- a/grammar/src/common/mut_self_keyword.rs +++ b/grammar/src/common/mut_self_keyword.rs @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Mutable; -use crate::common::SelfKeyword; -use crate::SpanDef; +use crate::{ + ast::Rule, + common::{Mutable, SelfKeyword}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/range.rs b/grammar/src/common/range.rs index 9d5a26fdd1..cdb1f923f5 100644 --- a/grammar/src/common/range.rs +++ b/grammar/src/common/range.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/range_or_expression.rs b/grammar/src/common/range_or_expression.rs index c740ddf486..2b7ae2eb68 100644 --- a/grammar/src/common/range_or_expression.rs +++ b/grammar/src/common/range_or_expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Range; -use crate::expressions::Expression; +use crate::{ast::Rule, common::Range, expressions::Expression}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/common/self_keyword.rs b/grammar/src/common/self_keyword.rs index 40ccedb74a..60721a7fab 100644 --- a/grammar/src/common/self_keyword.rs +++ b/grammar/src/common/self_keyword.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/self_keyword_or_identifier.rs b/grammar/src/common/self_keyword_or_identifier.rs index 0912a76f2d..83e27901eb 100644 --- a/grammar/src/common/self_keyword_or_identifier.rs +++ b/grammar/src/common/self_keyword_or_identifier.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::common::SelfKeyword; +use crate::{ + ast::Rule, + common::{Identifier, SelfKeyword}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/common/spread.rs b/grammar/src/common/spread.rs index 4dd09cf5ff..c9dd266816 100644 --- a/grammar/src/common/spread.rs +++ b/grammar/src/common/spread.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/spread_or_expression.rs b/grammar/src/common/spread_or_expression.rs index 859147cda0..cd4bbc21d6 100644 --- a/grammar/src/common/spread_or_expression.rs +++ b/grammar/src/common/spread_or_expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Spread; -use crate::expressions::Expression; +use crate::{ast::Rule, common::Spread, expressions::Expression}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/common/variable_name.rs b/grammar/src/common/variable_name.rs index a9c862f586..f9c6fe2e28 100644 --- a/grammar/src/common/variable_name.rs +++ b/grammar/src/common/variable_name.rs @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::common::Mutable; -use crate::SpanDef; +use crate::{ + ast::Rule, + common::{Identifier, Mutable}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/common/variables.rs b/grammar/src/common/variables.rs index 6a7b7f4751..939107fd7a 100644 --- a/grammar/src/common/variables.rs +++ b/grammar/src/common/variables.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::VariableName; -use crate::types::Type; -use crate::SpanDef; +use crate::{ast::Rule, common::VariableName, types::Type, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/console_assert.rs b/grammar/src/console/console_assert.rs index d5ed36d0c2..681f10dfc9 100644 --- a/grammar/src/console/console_assert.rs +++ b/grammar/src/console/console_assert.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/console_debug.rs b/grammar/src/console/console_debug.rs index 61583f53a4..81b463947e 100644 --- a/grammar/src/console/console_debug.rs +++ b/grammar/src/console/console_debug.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::console::FormattedString; -use crate::SpanDef; +use crate::{ast::Rule, console::FormattedString, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/console_error.rs b/grammar/src/console/console_error.rs index ce342c2896..8155c8d75f 100644 --- a/grammar/src/console/console_error.rs +++ b/grammar/src/console/console_error.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::console::FormattedString; -use crate::SpanDef; +use crate::{ast::Rule, console::FormattedString, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/console_function.rs b/grammar/src/console/console_function.rs index da32c2095b..b2cb97a418 100644 --- a/grammar/src/console/console_function.rs +++ b/grammar/src/console/console_function.rs @@ -14,11 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::console::ConsoleAssert; -use crate::console::ConsoleDebug; -use crate::console::ConsoleError; -use crate::console::ConsoleLog; +use crate::{ + ast::Rule, + console::{ConsoleAssert, ConsoleDebug, ConsoleError, ConsoleLog}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/console/console_function_call.rs b/grammar/src/console/console_function_call.rs index 08d1455896..18183927e9 100644 --- a/grammar/src/console/console_function_call.rs +++ b/grammar/src/console/console_function_call.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::LineEnd; -use crate::console::ConsoleFunction; -use crate::console::ConsoleKeyword; -use crate::SpanDef; +use crate::{ + ast::Rule, + common::LineEnd, + console::{ConsoleFunction, ConsoleKeyword}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/console_keyword.rs b/grammar/src/console/console_keyword.rs index 952d83933f..b9f98355ed 100644 --- a/grammar/src/console/console_keyword.rs +++ b/grammar/src/console/console_keyword.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ast::Rule, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/console_log.rs b/grammar/src/console/console_log.rs index b4fa3d1069..06e6f457f0 100644 --- a/grammar/src/console/console_log.rs +++ b/grammar/src/console/console_log.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::console::FormattedString; -use crate::SpanDef; +use crate::{ast::Rule, console::FormattedString, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/formatted_container.rs b/grammar/src/console/formatted_container.rs index cedcc96bea..2943280b52 100644 --- a/grammar/src/console/formatted_container.rs +++ b/grammar/src/console/formatted_container.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ast::Rule, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/console/formatted_string.rs b/grammar/src/console/formatted_string.rs index adbdfbdffb..f0e80d3209 100644 --- a/grammar/src/console/formatted_string.rs +++ b/grammar/src/console/formatted_string.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::console::FormattedContainer; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + console::FormattedContainer, + expressions::Expression, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/definitions/annotated_definition.rs b/grammar/src/definitions/annotated_definition.rs index 70f56ff93f..2bb3bf2d77 100644 --- a/grammar/src/definitions/annotated_definition.rs +++ b/grammar/src/definitions/annotated_definition.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::annotations::Annotation; -use crate::ast::Rule; -use crate::definitions::Definition; -use crate::SpanDef; +use crate::{annotations::Annotation, ast::Rule, definitions::Definition, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/definitions/definition.rs b/grammar/src/definitions/definition.rs index d3a8e4a909..7fd46ef7f5 100644 --- a/grammar/src/definitions/definition.rs +++ b/grammar/src/definitions/definition.rs @@ -14,12 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::circuits::Circuit; -use crate::definitions::AnnotatedDefinition; -use crate::definitions::Deprecated; -use crate::functions::Function; -use crate::imports::Import; +use crate::{ + ast::Rule, + circuits::Circuit, + definitions::{AnnotatedDefinition, Deprecated}, + functions::Function, + imports::Import, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/definitions/deprecated.rs b/grammar/src/definitions/deprecated.rs index a8b4cd5e0f..5c8d514113 100644 --- a/grammar/src/definitions/deprecated.rs +++ b/grammar/src/definitions/deprecated.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::functions::TestFunction; +use crate::{ast::Rule, functions::TestFunction}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/errors/parser.rs b/grammar/src/errors/parser.rs index 39f936f59a..6f831d0ec2 100644 --- a/grammar/src/errors/parser.rs +++ b/grammar/src/errors/parser.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::errors::SyntaxError; +use crate::{ast::Rule, errors::SyntaxError}; use pest::error::Error; -use std::path::Path; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; #[derive(Debug, Error)] pub enum ParserError { diff --git a/grammar/src/expressions/array_initializer_expression.rs b/grammar/src/expressions/array_initializer_expression.rs index a724e3ebd9..c2a73e0d09 100644 --- a/grammar/src/expressions/array_initializer_expression.rs +++ b/grammar/src/expressions/array_initializer_expression.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::types::ArrayDimensions; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, types::ArrayDimensions, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/expressions/array_inline_expression.rs b/grammar/src/expressions/array_inline_expression.rs index 53ad6b1a9f..5b3f4b7810 100644 --- a/grammar/src/expressions/array_inline_expression.rs +++ b/grammar/src/expressions/array_inline_expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::SpreadOrExpression; -use crate::SpanDef; +use crate::{ast::Rule, common::SpreadOrExpression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/expressions/binary_expression.rs b/grammar/src/expressions/binary_expression.rs index c61b3f5f47..1086121d5b 100644 --- a/grammar/src/expressions/binary_expression.rs +++ b/grammar/src/expressions/binary_expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::expressions::Expression; -use crate::operations::BinaryOperation; -use crate::SpanDef; +use crate::{expressions::Expression, operations::BinaryOperation, SpanDef}; use pest::Span; use serde::Serialize; diff --git a/grammar/src/expressions/circuit_inline_expression.rs b/grammar/src/expressions/circuit_inline_expression.rs index f6dbe9d0fe..6a51792bae 100644 --- a/grammar/src/expressions/circuit_inline_expression.rs +++ b/grammar/src/expressions/circuit_inline_expression.rs @@ -14,11 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::circuits::CircuitImpliedVariable; -use crate::common::Identifier; -use crate::types::SelfType; -use crate::SpanDef; +use crate::{ast::Rule, circuits::CircuitImpliedVariable, common::Identifier, types::SelfType, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/expressions/expression.rs b/grammar/src/expressions/expression.rs index dd5d9fee92..7d71761a5c 100644 --- a/grammar/src/expressions/expression.rs +++ b/grammar/src/expressions/expression.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::common::Identifier; -use crate::expressions::*; -use crate::operations::BinaryOperation; -use crate::values::Value; +use crate::{common::Identifier, expressions::*, operations::BinaryOperation, values::Value}; use pest::Span; use serde::Serialize; diff --git a/grammar/src/expressions/postfix_expression.rs b/grammar/src/expressions/postfix_expression.rs index 7701984f26..923de16161 100644 --- a/grammar/src/expressions/postfix_expression.rs +++ b/grammar/src/expressions/postfix_expression.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::access::Access; -use crate::ast::Rule; -use crate::common::KeywordOrIdentifier; -use crate::SpanDef; +use crate::{access::Access, ast::Rule, common::KeywordOrIdentifier, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/expressions/self_postfix_expression.rs b/grammar/src/expressions/self_postfix_expression.rs index 7c53e13912..21017bda2d 100644 --- a/grammar/src/expressions/self_postfix_expression.rs +++ b/grammar/src/expressions/self_postfix_expression.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::access::Access; -use crate::access::SelfAccess; -use crate::ast::Rule; -use crate::common::SelfKeyword; -use crate::SpanDef; +use crate::{ + access::{Access, SelfAccess}, + ast::Rule, + common::SelfKeyword, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/expressions/ternary_expression.rs b/grammar/src/expressions/ternary_expression.rs index 59a31e8844..163750bd61 100644 --- a/grammar/src/expressions/ternary_expression.rs +++ b/grammar/src/expressions/ternary_expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/expressions/tuple_expression.rs b/grammar/src/expressions/tuple_expression.rs index b15428f080..16b8727fe9 100644 --- a/grammar/src/expressions/tuple_expression.rs +++ b/grammar/src/expressions/tuple_expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/expressions/unary_expression.rs b/grammar/src/expressions/unary_expression.rs index c9e5ac74f9..b2d50fb4c4 100644 --- a/grammar/src/expressions/unary_expression.rs +++ b/grammar/src/expressions/unary_expression.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::operations::UnaryOperation; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, operations::UnaryOperation, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/files/file.rs b/grammar/src/files/file.rs index 25eafba04b..6d1bc2fea3 100644 --- a/grammar/src/files/file.rs +++ b/grammar/src/files/file.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::EOI; -use crate::definitions::Definition; -use crate::SpanDef; +use crate::{ast::Rule, common::EOI, definitions::Definition, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/functions/function.rs b/grammar/src/functions/function.rs index 1be25b8ac5..cd342b34bf 100644 --- a/grammar/src/functions/function.rs +++ b/grammar/src/functions/function.rs @@ -14,12 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::functions::input::Input; -use crate::statements::Block; -use crate::types::Type; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, functions::input::Input, statements::Block, types::Type, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/functions/input/function_input.rs b/grammar/src/functions/input/function_input.rs index fbe85c730d..3cac32b798 100644 --- a/grammar/src/functions/input/function_input.rs +++ b/grammar/src/functions/input/function_input.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Const; -use crate::common::Identifier; -use crate::common::Mutable; -use crate::types::Type; -use crate::SpanDef; +use crate::{ + ast::Rule, + common::{Const, Identifier, Mutable}, + types::Type, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/functions/input/input.rs b/grammar/src/functions/input/input.rs index cecc2ed01a..9b2ef22ab7 100644 --- a/grammar/src/functions/input/input.rs +++ b/grammar/src/functions/input/input.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::MutSelfKeyword; -use crate::common::SelfKeyword; -use crate::functions::FunctionInput; -use crate::functions::InputKeyword; +use crate::{ + ast::Rule, + common::{MutSelfKeyword, SelfKeyword}, + functions::{FunctionInput, InputKeyword}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/functions/input/input_keyword.rs b/grammar/src/functions/input/input_keyword.rs index 1a76c63512..5032ae4436 100644 --- a/grammar/src/functions/input/input_keyword.rs +++ b/grammar/src/functions/input/input_keyword.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/functions/test_function.rs b/grammar/src/functions/test_function.rs index 834df3f2a9..1e28efc53c 100644 --- a/grammar/src/functions/test_function.rs +++ b/grammar/src/functions/test_function.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::functions::Function; -use crate::SpanDef; +use crate::{ast::Rule, functions::Function, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/imports/import.rs b/grammar/src/imports/import.rs index 2c72ebc50c..1b62df80f3 100644 --- a/grammar/src/imports/import.rs +++ b/grammar/src/imports/import.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::LineEnd; -use crate::imports::PackageOrPackages; -use crate::SpanDef; +use crate::{ast::Rule, common::LineEnd, imports::PackageOrPackages, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/imports/import_symbol.rs b/grammar/src/imports/import_symbol.rs index c0d4304b66..3643406618 100644 --- a/grammar/src/imports/import_symbol.rs +++ b/grammar/src/imports/import_symbol.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/imports/package.rs b/grammar/src/imports/package.rs index caffcaa13b..0b3f1a0ecb 100644 --- a/grammar/src/imports/package.rs +++ b/grammar/src/imports/package.rs @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::imports::PackageAccess; -use crate::imports::PackageName; -use crate::SpanDef; +use crate::{ + ast::Rule, + imports::{PackageAccess, PackageName}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/imports/package_access.rs b/grammar/src/imports/package_access.rs index 379520d6d4..7d172bd545 100644 --- a/grammar/src/imports/package_access.rs +++ b/grammar/src/imports/package_access.rs @@ -14,11 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::imports::ImportSymbol; -use crate::imports::Package; -use crate::imports::Packages; -use crate::imports::Star; +use crate::{ + ast::Rule, + imports::{ImportSymbol, Package, Packages, Star}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/imports/package_name.rs b/grammar/src/imports/package_name.rs index efe48335f4..a2e400460e 100644 --- a/grammar/src/imports/package_name.rs +++ b/grammar/src/imports/package_name.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/imports/package_or_packages.rs b/grammar/src/imports/package_or_packages.rs index 9f3cc1049e..3cd0324480 100644 --- a/grammar/src/imports/package_or_packages.rs +++ b/grammar/src/imports/package_or_packages.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::imports::Package; -use crate::imports::Packages; +use crate::{ + ast::Rule, + imports::{Package, Packages}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/imports/packages.rs b/grammar/src/imports/packages.rs index 1cfa0f2a74..32003ffb16 100644 --- a/grammar/src/imports/packages.rs +++ b/grammar/src/imports/packages.rs @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::imports::PackageAccess; -use crate::imports::PackageName; -use crate::SpanDef; +use crate::{ + ast::Rule, + imports::{PackageAccess, PackageName}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/imports/star.rs b/grammar/src/imports/star.rs index fc646aefe1..29cb6b6e35 100644 --- a/grammar/src/imports/star.rs +++ b/grammar/src/imports/star.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ast::Rule, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/lib.rs b/grammar/src/lib.rs index 850dc37ff2..2f9e0fac02 100644 --- a/grammar/src/lib.rs +++ b/grammar/src/lib.rs @@ -51,8 +51,7 @@ pub(crate) mod span; pub(crate) use span::*; use from_pest::FromPest; -use std::fs; -use std::path::Path; +use std::{fs, path::Path}; /// /// The grammar of a Leo program, encoded as an abstract syntax tree (AST). diff --git a/grammar/src/main.rs b/grammar/src/main.rs index 30ba62d972..ae9259084c 100644 --- a/grammar/src/main.rs +++ b/grammar/src/main.rs @@ -14,11 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::Grammar; -use leo_grammar::ParserError; -use std::env; -use std::fs; -use std::path::Path; +use leo_grammar::{Grammar, ParserError}; +use std::{env, fs, path::Path}; fn to_grammar(filepath: &Path) -> Result { // Loads the Leo code as a string from the given file path. diff --git a/grammar/src/span.rs b/grammar/src/span.rs index ba1be46daf..f7c0eae89d 100644 --- a/grammar/src/span.rs +++ b/grammar/src/span.rs @@ -15,8 +15,7 @@ // along with the Leo library. If not, see . use pest::Span; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; // Provide getters for every private field of the remote struct. The getter must // return either `T` or `&T` where `T` is the type of the field. diff --git a/grammar/src/statements/assign_statement.rs b/grammar/src/statements/assign_statement.rs index 3bea311ab2..5325fd7b17 100644 --- a/grammar/src/statements/assign_statement.rs +++ b/grammar/src/statements/assign_statement.rs @@ -14,12 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Assignee; -use crate::common::LineEnd; -use crate::expressions::Expression; -use crate::operations::AssignOperation; -use crate::SpanDef; +use crate::{ + ast::Rule, + common::{Assignee, LineEnd}, + expressions::Expression, + operations::AssignOperation, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/statements/block.rs b/grammar/src/statements/block.rs index 12b3d856bf..bbbfe41ff7 100644 --- a/grammar/src/statements/block.rs +++ b/grammar/src/statements/block.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::statements::Statement; -use crate::SpanDef; +use crate::{ast::Rule, statements::Statement, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/statements/conditional_nested_or_end_statement.rs b/grammar/src/statements/conditional_nested_or_end_statement.rs index a6807f1286..3bab38d701 100644 --- a/grammar/src/statements/conditional_nested_or_end_statement.rs +++ b/grammar/src/statements/conditional_nested_or_end_statement.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::statements::Block; -use crate::statements::ConditionalStatement; +use crate::{ + ast::Rule, + statements::{Block, ConditionalStatement}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/statements/conditional_statement.rs b/grammar/src/statements/conditional_statement.rs index 3145712852..2e6861f98b 100644 --- a/grammar/src/statements/conditional_statement.rs +++ b/grammar/src/statements/conditional_statement.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::statements::Block; -use crate::statements::ConditionalNestedOrEndStatement; -use crate::SpanDef; +use crate::{ + ast::Rule, + expressions::Expression, + statements::{Block, ConditionalNestedOrEndStatement}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/statements/definition_statement.rs b/grammar/src/statements/definition_statement.rs index 9b076d6a7c..c1db3c212d 100644 --- a/grammar/src/statements/definition_statement.rs +++ b/grammar/src/statements/definition_statement.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Declare; -use crate::common::LineEnd; -use crate::common::Variables; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ + ast::Rule, + common::{Declare, LineEnd, Variables}, + expressions::Expression, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/statements/expression_statement.rs b/grammar/src/statements/expression_statement.rs index 3b78a62b5f..bbef3f3568 100644 --- a/grammar/src/statements/expression_statement.rs +++ b/grammar/src/statements/expression_statement.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::LineEnd; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, common::LineEnd, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/statements/for_statement.rs b/grammar/src/statements/for_statement.rs index c14b868e36..c1be00e303 100644 --- a/grammar/src/statements/for_statement.rs +++ b/grammar/src/statements/for_statement.rs @@ -14,11 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::expressions::Expression; -use crate::statements::Block; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, expressions::Expression, statements::Block, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/statements/return_statement.rs b/grammar/src/statements/return_statement.rs index 22ce5597be..11d6b4ddcb 100644 --- a/grammar/src/statements/return_statement.rs +++ b/grammar/src/statements/return_statement.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::SpanDef; +use crate::{ast::Rule, expressions::Expression, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/statements/statement.rs b/grammar/src/statements/statement.rs index 771477c8f4..d01c5d072e 100644 --- a/grammar/src/statements/statement.rs +++ b/grammar/src/statements/statement.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::console::ConsoleFunctionCall; -use crate::statements::*; +use crate::{ast::Rule, console::ConsoleFunctionCall, statements::*}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/types/array_dimensions.rs b/grammar/src/types/array_dimensions.rs index 45928210bb..eb0aa89b1c 100644 --- a/grammar/src/types/array_dimensions.rs +++ b/grammar/src/types/array_dimensions.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::PositiveNumber; -use crate::SpanDef; +use crate::{ast::Rule, values::PositiveNumber, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/types/array_type.rs b/grammar/src/types/array_type.rs index 33ca7f227e..a91b08558b 100644 --- a/grammar/src/types/array_type.rs +++ b/grammar/src/types/array_type.rs @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::ArrayDimensions; -use crate::types::Type; -use crate::SpanDef; +use crate::{ + ast::Rule, + types::{ArrayDimensions, Type}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/types/circuit_type.rs b/grammar/src/types/circuit_type.rs index 586267544d..c0156e100a 100644 --- a/grammar/src/types/circuit_type.rs +++ b/grammar/src/types/circuit_type.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::SpanDef; +use crate::{ast::Rule, common::Identifier, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/types/data_type.rs b/grammar/src/types/data_type.rs index acb7a17fe0..78143384a5 100644 --- a/grammar/src/types/data_type.rs +++ b/grammar/src/types/data_type.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::AddressType; -use crate::types::BooleanType; -use crate::types::FieldType; -use crate::types::GroupType; -use crate::types::IntegerType; +use crate::{ + ast::Rule, + types::{AddressType, BooleanType, FieldType, GroupType, IntegerType}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/types/integer_type.rs b/grammar/src/types/integer_type.rs index d9003fb402..729ac0fcc4 100644 --- a/grammar/src/types/integer_type.rs +++ b/grammar/src/types/integer_type.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::SignedIntegerType; -use crate::types::UnsignedIntegerType; +use crate::{ + ast::Rule, + types::{SignedIntegerType, UnsignedIntegerType}, +}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/types/self_type.rs b/grammar/src/types/self_type.rs index 99949e41f7..e3fb6bd072 100644 --- a/grammar/src/types/self_type.rs +++ b/grammar/src/types/self_type.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/types/tuple_type.rs b/grammar/src/types/tuple_type.rs index f2ff4a9e5f..57f39c9261 100644 --- a/grammar/src/types/tuple_type.rs +++ b/grammar/src/types/tuple_type.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::Type; -use crate::SpanDef; +use crate::{ast::Rule, types::Type, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/types/type_.rs b/grammar/src/types/type_.rs index ec1e7a9da6..d020a7ef07 100644 --- a/grammar/src/types/type_.rs +++ b/grammar/src/types/type_.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::*; +use crate::{ast::Rule, types::*}; use pest_ast::FromPest; use serde::Serialize; diff --git a/grammar/src/values/address.rs b/grammar/src/values/address.rs index 9c5372aa09..e1e815a6e7 100644 --- a/grammar/src/values/address.rs +++ b/grammar/src/values/address.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/address_value.rs b/grammar/src/values/address_value.rs index 2d7c67e8d5..decf47431e 100644 --- a/grammar/src/values/address_value.rs +++ b/grammar/src/values/address_value.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::AddressType; -use crate::values::address::Address; -use crate::SpanDef; +use crate::{ast::Rule, types::AddressType, values::address::Address, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/boolean_value.rs b/grammar/src/values/boolean_value.rs index 9a0219f655..9e26d369f9 100644 --- a/grammar/src/values/boolean_value.rs +++ b/grammar/src/values/boolean_value.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/field_value.rs b/grammar/src/values/field_value.rs index dc7464bcbc..fad986b83e 100644 --- a/grammar/src/values/field_value.rs +++ b/grammar/src/values/field_value.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::FieldType; -use crate::values::NumberValue; -use crate::SpanDef; +use crate::{ast::Rule, types::FieldType, values::NumberValue, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/group_coordinate.rs b/grammar/src/values/group_coordinate.rs index da1861c79d..4f12c477d4 100644 --- a/grammar/src/values/group_coordinate.rs +++ b/grammar/src/values/group_coordinate.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::NumberValue; -use crate::SpanDef; +use crate::{ast::Rule, values::NumberValue, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/group_value.rs b/grammar/src/values/group_value.rs index 4b9c7cc3d7..56ab231908 100644 --- a/grammar/src/values/group_value.rs +++ b/grammar/src/values/group_value.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::GroupType; -use crate::values::GroupCoordinate; -use crate::values::NumberValue; -use crate::SpanDef; +use crate::{ + ast::Rule, + types::GroupType, + values::{GroupCoordinate, NumberValue}, + SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/integer_value.rs b/grammar/src/values/integer_value.rs index 49b00b6fc7..64c0ebd640 100644 --- a/grammar/src/values/integer_value.rs +++ b/grammar/src/values/integer_value.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::SignedIntegerValue; -use crate::values::UnsignedIntegerValue; +use crate::{ + ast::Rule, + values::{SignedIntegerValue, UnsignedIntegerValue}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/negative_number.rs b/grammar/src/values/negative_number.rs index b0fd99eb7f..5cd52eaef0 100644 --- a/grammar/src/values/negative_number.rs +++ b/grammar/src/values/negative_number.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::span::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + span::SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/number_value.rs b/grammar/src/values/number_value.rs index e0c63164fc..1d090c7528 100644 --- a/grammar/src/values/number_value.rs +++ b/grammar/src/values/number_value.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::NegativeNumber; -use crate::values::PositiveNumber; +use crate::{ + ast::Rule, + values::{NegativeNumber, PositiveNumber}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/positive_number.rs b/grammar/src/values/positive_number.rs index a432b099ce..8fd522836f 100644 --- a/grammar/src/values/positive_number.rs +++ b/grammar/src/values/positive_number.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; -use crate::span::SpanDef; +use crate::{ + ast::{span_into_string, Rule}, + span::SpanDef, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/signed_integer_value.rs b/grammar/src/values/signed_integer_value.rs index 08e5884522..5c49a0ebf1 100644 --- a/grammar/src/values/signed_integer_value.rs +++ b/grammar/src/values/signed_integer_value.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::SignedIntegerType; -use crate::values::NumberValue; -use crate::SpanDef; +use crate::{ast::Rule, types::SignedIntegerType, values::NumberValue, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/unsigned_integer_value.rs b/grammar/src/values/unsigned_integer_value.rs index c17d541dcf..9b85ae8eea 100644 --- a/grammar/src/values/unsigned_integer_value.rs +++ b/grammar/src/values/unsigned_integer_value.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::UnsignedIntegerType; -use crate::values::PositiveNumber; -use crate::SpanDef; +use crate::{ast::Rule, types::UnsignedIntegerType, values::PositiveNumber, SpanDef}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/src/values/value.rs b/grammar/src/values/value.rs index 0314286277..2d92362c28 100644 --- a/grammar/src/values/value.rs +++ b/grammar/src/values/value.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::AddressValue; -use crate::values::BooleanValue; -use crate::values::FieldValue; -use crate::values::GroupValue; -use crate::values::IntegerValue; -use crate::values::NumberValue; +use crate::{ + ast::Rule, + values::{AddressValue, BooleanValue, FieldValue, GroupValue, IntegerValue, NumberValue}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/grammar/tests/annotated.rs b/grammar/tests/annotated.rs index 0f31370018..32ac106dba 100644 --- a/grammar/tests/annotated.rs +++ b/grammar/tests/annotated.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; diff --git a/grammar/tests/circuits.rs b/grammar/tests/circuits.rs index 161c8ce467..33c77151ca 100644 --- a/grammar/tests/circuits.rs +++ b/grammar/tests/circuits.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; diff --git a/grammar/tests/deprecated.rs b/grammar/tests/deprecated.rs index e9090c4566..5ff8f94cb0 100644 --- a/grammar/tests/deprecated.rs +++ b/grammar/tests/deprecated.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; diff --git a/grammar/tests/display.rs b/grammar/tests/display.rs index ff67f18d42..38aaf42a70 100644 --- a/grammar/tests/display.rs +++ b/grammar/tests/display.rs @@ -15,9 +15,10 @@ // along with the Leo library. If not, see . use from_pest::FromPest; -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; -use leo_grammar::statements::ConditionalStatement; +use leo_grammar::{ + ast::{LanguageParser, Rule}, + statements::ConditionalStatement, +}; use pest::*; diff --git a/grammar/tests/expression.rs b/grammar/tests/expression.rs index f728b95b0f..589c16bcee 100644 --- a/grammar/tests/expression.rs +++ b/grammar/tests/expression.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; diff --git a/grammar/tests/function.rs b/grammar/tests/function.rs index 3b85e6e186..4bc1de7bf7 100644 --- a/grammar/tests/function.rs +++ b/grammar/tests/function.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; diff --git a/grammar/tests/imports.rs b/grammar/tests/imports.rs index 94ceabcce8..8ddd874e3d 100644 --- a/grammar/tests/imports.rs +++ b/grammar/tests/imports.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; diff --git a/grammar/tests/multiline.rs b/grammar/tests/multiline.rs index d5d03b5ebb..2c3fca1706 100644 --- a/grammar/tests/multiline.rs +++ b/grammar/tests/multiline.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; #[test] diff --git a/grammar/tests/self.rs b/grammar/tests/self.rs index 4a5ccf05c9..8157639e42 100644 --- a/grammar/tests/self.rs +++ b/grammar/tests/self.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; #[test] diff --git a/grammar/tests/tuple.rs b/grammar/tests/tuple.rs index 1a602e4f5e..1408d5c0d8 100644 --- a/grammar/tests/tuple.rs +++ b/grammar/tests/tuple.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_grammar::ast::LanguageParser; -use leo_grammar::ast::Rule; +use leo_grammar::ast::{LanguageParser, Rule}; use pest::*; diff --git a/imports/src/errors/import_parser.rs b/imports/src/errors/import_parser.rs index 378af76230..f3d901560c 100644 --- a/imports/src/errors/import_parser.rs +++ b/imports/src/errors/import_parser.rs @@ -14,15 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . use leo_asg::AsgConvertError; -use leo_ast::AstError; -use leo_ast::DeprecatedError; -use leo_ast::Error as FormattedError; -use leo_ast::Identifier; -use leo_ast::Span; +use leo_ast::{AstError, DeprecatedError, Error as FormattedError, Identifier, Span}; use leo_grammar::ParserError; -use std::io; -use std::path::Path; +use std::{io, path::Path}; #[derive(Debug, Error)] pub enum ImportParserError { diff --git a/imports/src/parser/import_parser.rs b/imports/src/parser/import_parser.rs index 2e803ac303..300408cffb 100644 --- a/imports/src/parser/import_parser.rs +++ b/imports/src/parser/import_parser.rs @@ -15,14 +15,9 @@ // along with the Leo library. If not, see . use crate::errors::ImportParserError; -use leo_asg::AsgContext; -use leo_asg::AsgConvertError; -use leo_asg::ImportResolver; -use leo_asg::Program; -use leo_asg::Span; +use leo_asg::{AsgContext, AsgConvertError, ImportResolver, Program, Span}; -use indexmap::IndexMap; -use indexmap::IndexSet; +use indexmap::{IndexMap, IndexSet}; use std::env::current_dir; /// Stores imported packages. diff --git a/imports/src/parser/parse_package.rs b/imports/src/parser/parse_package.rs index 44d20b0b35..3acd05e41b 100644 --- a/imports/src/parser/parse_package.rs +++ b/imports/src/parser/parse_package.rs @@ -14,16 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::ImportParserError; -use crate::ImportParser; -use leo_asg::AsgContext; -use leo_asg::Identifier; -use leo_asg::Program; -use leo_asg::Span; +use crate::{errors::ImportParserError, ImportParser}; +use leo_asg::{AsgContext, Identifier, Program, Span}; -use std::fs; -use std::fs::DirEntry; -use std::path::PathBuf; +use std::{fs, fs::DirEntry, path::PathBuf}; static SOURCE_FILE_EXTENSION: &str = ".leo"; static SOURCE_DIRECTORY_NAME: &str = "src/"; diff --git a/imports/src/parser/parse_symbol.rs b/imports/src/parser/parse_symbol.rs index 8cc27a706f..9b02656d75 100644 --- a/imports/src/parser/parse_symbol.rs +++ b/imports/src/parser/parse_symbol.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::ImportParserError; -use crate::ImportParser; -use leo_ast::Program; -use leo_ast::Span; +use crate::{errors::ImportParserError, ImportParser}; +use leo_ast::{Program, Span}; use leo_grammar::Grammar; use std::fs::DirEntry; diff --git a/input/src/ast.rs b/input/src/ast.rs index 74176907b3..cfb3deef07 100644 --- a/input/src/ast.rs +++ b/input/src/ast.rs @@ -15,10 +15,7 @@ // along with the Leo library. If not, see . //! Abstract syntax tree (ast) representation from leo-input.pest. -use pest::error::Error; -use pest::iterators::Pairs; -use pest::Parser; -use pest::Span; +use pest::{error::Error, iterators::Pairs, Parser, Span}; #[derive(Parser)] #[grammar = "leo-input.pest"] diff --git a/input/src/common/identifier.rs b/input/src/common/identifier.rs index 8af41c89ee..606ac424ee 100644 --- a/input/src/common/identifier.rs +++ b/input/src/common/identifier.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; +use crate::ast::{span_into_string, Rule}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/definitions/definition.rs b/input/src/definitions/definition.rs index 0f682e3628..c0c64bbe67 100644 --- a/input/src/definitions/definition.rs +++ b/input/src/definitions/definition.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::LineEnd; -use crate::expressions::Expression; -use crate::parameters::Parameter; +use crate::{ast::Rule, common::LineEnd, expressions::Expression, parameters::Parameter}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/errors/parser.rs b/input/src/errors/parser.rs index e67b4db760..71bdbee253 100644 --- a/input/src/errors/parser.rs +++ b/input/src/errors/parser.rs @@ -14,24 +14,25 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::errors::SyntaxError as InputSyntaxError; -use crate::expressions::ArrayInlineExpression; -use crate::expressions::Expression; -use crate::sections::Header; -use crate::tables::Table; -use crate::types::DataType; -use crate::types::Type; -use crate::values::NumberValue; -use crate::values::Value; +use crate::{ + ast::Rule, + errors::SyntaxError as InputSyntaxError, + expressions::{ArrayInlineExpression, Expression}, + sections::Header, + tables::Table, + types::{DataType, Type}, + values::{NumberValue, Value}, +}; -use pest::error::Error; -use pest::error::ErrorVariant; -use pest::Span; -use std::num::ParseIntError; -use std::path::Path; -use std::path::PathBuf; -use std::str::ParseBoolError; +use pest::{ + error::{Error, ErrorVariant}, + Span, +}; +use std::{ + num::ParseIntError, + path::{Path, PathBuf}, + str::ParseBoolError, +}; #[derive(Debug, Error)] pub enum InputParserError { diff --git a/input/src/expressions/array_initializer_expression.rs b/input/src/expressions/array_initializer_expression.rs index 812ddd21e5..7870ac76ba 100644 --- a/input/src/expressions/array_initializer_expression.rs +++ b/input/src/expressions/array_initializer_expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; -use crate::types::ArrayDimensions; +use crate::{ast::Rule, expressions::Expression, types::ArrayDimensions}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/expressions/array_inline_expression.rs b/input/src/expressions/array_inline_expression.rs index b961aa94ab..573085bc79 100644 --- a/input/src/expressions/array_inline_expression.rs +++ b/input/src/expressions/array_inline_expression.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; +use crate::{ast::Rule, expressions::Expression}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/expressions/expression.rs b/input/src/expressions/expression.rs index ed2f5f8fec..4694307b58 100644 --- a/input/src/expressions/expression.rs +++ b/input/src/expressions/expression.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::*; -use crate::values::Value; +use crate::{ast::Rule, expressions::*, values::Value}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/expressions/tuple_expression.rs b/input/src/expressions/tuple_expression.rs index 4b831a6175..5cbb95dffb 100644 --- a/input/src/expressions/tuple_expression.rs +++ b/input/src/expressions/tuple_expression.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::expressions::Expression; +use crate::{ast::Rule, expressions::Expression}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/files/file.rs b/input/src/files/file.rs index 3caf037aeb..61142390b8 100644 --- a/input/src/files/file.rs +++ b/input/src/files/file.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::EOI; -use crate::files::TableOrSection; +use crate::{ast::Rule, common::EOI, files::TableOrSection}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/files/table_or_section.rs b/input/src/files/table_or_section.rs index 11fe801ac4..93dd31dfc9 100644 --- a/input/src/files/table_or_section.rs +++ b/input/src/files/table_or_section.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::sections::Section; -use crate::tables::Table; +use crate::{ast::Rule, sections::Section, tables::Table}; use pest_ast::FromPest; diff --git a/input/src/lib.rs b/input/src/lib.rs index 9bdb8ead9f..e2537eeeb1 100644 --- a/input/src/lib.rs +++ b/input/src/lib.rs @@ -34,8 +34,7 @@ pub mod types; pub mod values; use from_pest::FromPest; -use std::fs; -use std::path::Path; +use std::{fs, path::Path}; pub struct LeoInputParser; diff --git a/input/src/parameters/parameter.rs b/input/src/parameters/parameter.rs index 10f76536e0..410ef775a9 100644 --- a/input/src/parameters/parameter.rs +++ b/input/src/parameters/parameter.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::types::Type; +use crate::{ast::Rule, common::Identifier, types::Type}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/sections/header.rs b/input/src/sections/header.rs index bae10df0e3..ca437c0a45 100644 --- a/input/src/sections/header.rs +++ b/input/src/sections/header.rs @@ -14,13 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::common::Identifier; -use crate::sections::Main; -use crate::sections::Record; -use crate::sections::Registers; -use crate::sections::State; -use crate::sections::StateLeaf; +use crate::{ + ast::Rule, + common::Identifier, + sections::{Main, Record, Registers, State, StateLeaf}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/sections/section.rs b/input/src/sections/section.rs index a35ece07a5..e53a6331cd 100644 --- a/input/src/sections/section.rs +++ b/input/src/sections/section.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::definitions::Definition; -use crate::sections::Header; +use crate::{ast::Rule, definitions::Definition, sections::Header}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/tables/table.rs b/input/src/tables/table.rs index beb272c62f..9ea777cbda 100644 --- a/input/src/tables/table.rs +++ b/input/src/tables/table.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::sections::Section; -use crate::tables::Visibility; +use crate::{ast::Rule, sections::Section, tables::Visibility}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/tables/visibility.rs b/input/src/tables/visibility.rs index c3bd9586b8..0abe3828ee 100644 --- a/input/src/tables/visibility.rs +++ b/input/src/tables/visibility.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::tables::Private; -use crate::tables::Public; +use crate::{ + ast::Rule, + tables::{Private, Public}, +}; use pest_ast::FromPest; use std::fmt; diff --git a/input/src/types/array_dimensions.rs b/input/src/types/array_dimensions.rs index b89ce0269d..776ca0d899 100644 --- a/input/src/types/array_dimensions.rs +++ b/input/src/types/array_dimensions.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::PositiveNumber; +use crate::{ast::Rule, values::PositiveNumber}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/types/array_type.rs b/input/src/types/array_type.rs index 3b5700a960..0132228e0d 100644 --- a/input/src/types/array_type.rs +++ b/input/src/types/array_type.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::ArrayDimensions; -use crate::types::Type; +use crate::{ + ast::Rule, + types::{ArrayDimensions, Type}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/types/data_type.rs b/input/src/types/data_type.rs index 5f948718a2..ecb82e3bda 100644 --- a/input/src/types/data_type.rs +++ b/input/src/types/data_type.rs @@ -14,11 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::BooleanType; -use crate::types::FieldType; -use crate::types::GroupType; -use crate::types::IntegerType; +use crate::{ + ast::Rule, + types::{BooleanType, FieldType, GroupType, IntegerType}, +}; use crate::types::AddressType; use pest_ast::FromPest; diff --git a/input/src/types/integer_type.rs b/input/src/types/integer_type.rs index d6a636c94f..a66e28d079 100644 --- a/input/src/types/integer_type.rs +++ b/input/src/types/integer_type.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::SignedIntegerType; -use crate::types::UnsignedIntegerType; +use crate::{ + ast::Rule, + types::{SignedIntegerType, UnsignedIntegerType}, +}; use pest_ast::FromPest; use std::fmt; diff --git a/input/src/types/tuple_type.rs b/input/src/types/tuple_type.rs index c5a6aaa3e7..c5086c077a 100644 --- a/input/src/types/tuple_type.rs +++ b/input/src/types/tuple_type.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::Type; +use crate::{ast::Rule, types::Type}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/types/type_.rs b/input/src/types/type_.rs index 23b2fb63f7..605f919f1d 100644 --- a/input/src/types/type_.rs +++ b/input/src/types/type_.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::*; +use crate::{ast::Rule, types::*}; use pest_ast::FromPest; use std::fmt; diff --git a/input/src/values/address.rs b/input/src/values/address.rs index e3adbea7a8..becdf5f31f 100644 --- a/input/src/values/address.rs +++ b/input/src/values/address.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; +use crate::ast::{span_into_string, Rule}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/address_typed.rs b/input/src/values/address_typed.rs index a353c51027..17e678e86c 100644 --- a/input/src/values/address_typed.rs +++ b/input/src/values/address_typed.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::AddressType; -use crate::values::address::Address; +use crate::{ast::Rule, types::AddressType, values::address::Address}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/address_value.rs b/input/src/values/address_value.rs index 9de8bfa0d8..6134c41278 100644 --- a/input/src/values/address_value.rs +++ b/input/src/values/address_value.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::Address; -use crate::values::AddressTyped; +use crate::{ + ast::Rule, + values::{Address, AddressTyped}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/boolean_value.rs b/input/src/values/boolean_value.rs index fb7f026964..769cddd049 100644 --- a/input/src/values/boolean_value.rs +++ b/input/src/values/boolean_value.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; +use crate::ast::{span_into_string, Rule}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/field_value.rs b/input/src/values/field_value.rs index 49a4b95cee..f3bc21ebb4 100644 --- a/input/src/values/field_value.rs +++ b/input/src/values/field_value.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::FieldType; -use crate::values::NumberValue; +use crate::{ast::Rule, types::FieldType, values::NumberValue}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/group_coordinate.rs b/input/src/values/group_coordinate.rs index a5ed031861..8a4882c39c 100644 --- a/input/src/values/group_coordinate.rs +++ b/input/src/values/group_coordinate.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::NumberValue; +use crate::{ast::Rule, values::NumberValue}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/group_value.rs b/input/src/values/group_value.rs index c9b17d90e0..bc4c72eb17 100644 --- a/input/src/values/group_value.rs +++ b/input/src/values/group_value.rs @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::GroupType; -use crate::values::GroupCoordinate; -use crate::values::NumberValue; +use crate::{ + ast::Rule, + types::GroupType, + values::{GroupCoordinate, NumberValue}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/integer_value.rs b/input/src/values/integer_value.rs index f866879ef4..9e1004a929 100644 --- a/input/src/values/integer_value.rs +++ b/input/src/values/integer_value.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::SignedIntegerValue; -use crate::values::UnsignedIntegerValue; +use crate::{ + ast::Rule, + values::{SignedIntegerValue, UnsignedIntegerValue}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/negative_number.rs b/input/src/values/negative_number.rs index bd24cfff6b..704580fb9e 100644 --- a/input/src/values/negative_number.rs +++ b/input/src/values/negative_number.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; +use crate::ast::{span_into_string, Rule}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/number_value.rs b/input/src/values/number_value.rs index 6014c2488b..2071dca1a3 100644 --- a/input/src/values/number_value.rs +++ b/input/src/values/number_value.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::NegativeNumber; -use crate::values::PositiveNumber; +use crate::{ + ast::Rule, + values::{NegativeNumber, PositiveNumber}, +}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/positive_number.rs b/input/src/values/positive_number.rs index 6270e3614e..9ccf38cff2 100644 --- a/input/src/values/positive_number.rs +++ b/input/src/values/positive_number.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::span_into_string; -use crate::ast::Rule; +use crate::ast::{span_into_string, Rule}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/signed_integer_value.rs b/input/src/values/signed_integer_value.rs index 153b6a95d4..acd4301c0e 100644 --- a/input/src/values/signed_integer_value.rs +++ b/input/src/values/signed_integer_value.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::SignedIntegerType; -use crate::values::NumberValue; +use crate::{ast::Rule, types::SignedIntegerType, values::NumberValue}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/unsigned_integer_value.rs b/input/src/values/unsigned_integer_value.rs index 22046a9a92..7b0193069c 100644 --- a/input/src/values/unsigned_integer_value.rs +++ b/input/src/values/unsigned_integer_value.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::types::UnsignedIntegerType; -use crate::values::PositiveNumber; +use crate::{ast::Rule, types::UnsignedIntegerType, values::PositiveNumber}; use pest::Span; use pest_ast::FromPest; diff --git a/input/src/values/value.rs b/input/src/values/value.rs index 760dcee4fe..214b705bb0 100644 --- a/input/src/values/value.rs +++ b/input/src/values/value.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::ast::Rule; -use crate::values::BooleanValue; -use crate::values::FieldValue; -use crate::values::GroupValue; -use crate::values::IntegerValue; -use crate::values::NumberValue; +use crate::{ + ast::Rule, + values::{BooleanValue, FieldValue, GroupValue, IntegerValue, NumberValue}, +}; use crate::values::AddressValue; use pest::Span; diff --git a/leo/api.rs b/leo/api.rs index 244dd0aa05..23e12b3578 100644 --- a/leo/api.rs +++ b/leo/api.rs @@ -14,13 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use anyhow::anyhow; -use anyhow::Error; -use anyhow::Result; -use reqwest::blocking::Client; -use reqwest::blocking::Response; -use reqwest::Method; -use reqwest::StatusCode; +use anyhow::{anyhow, Error, Result}; +use reqwest::{ + blocking::{Client, Response}, + Method, + StatusCode, +}; use serde::Serialize; /// Trait describes API Routes and Request bodies, struct which implements diff --git a/leo/commands/build.rs b/leo/commands/build.rs index 31124d1b58..5f47cd1a6b 100644 --- a/leo/commands/build.rs +++ b/leo/commands/build.rs @@ -14,27 +14,20 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; -use leo_compiler::compiler::thread_leaked_context; -use leo_compiler::compiler::Compiler; -use leo_compiler::group::targets::edwards_bls12::EdwardsGroupType; -use leo_package::inputs::*; -use leo_package::outputs::ChecksumFile; -use leo_package::outputs::CircuitFile; -use leo_package::outputs::OutputsDirectory; -use leo_package::outputs::OUTPUTS_DIRECTORY_NAME; -use leo_package::source::LibraryFile; -use leo_package::source::MainFile; -use leo_package::source::LIBRARY_FILENAME; -use leo_package::source::MAIN_FILENAME; -use leo_package::source::SOURCE_DIRECTORY_NAME; -use leo_synthesizer::CircuitSynthesizer; -use leo_synthesizer::SerializedCircuit; +use crate::{commands::Command, context::Context}; +use leo_compiler::{ + compiler::{thread_leaked_context, Compiler}, + group::targets::edwards_bls12::EdwardsGroupType, +}; +use leo_package::{ + inputs::*, + outputs::{ChecksumFile, CircuitFile, OutputsDirectory, OUTPUTS_DIRECTORY_NAME}, + source::{LibraryFile, MainFile, LIBRARY_FILENAME, MAIN_FILENAME, SOURCE_DIRECTORY_NAME}, +}; +use leo_synthesizer::{CircuitSynthesizer, SerializedCircuit}; use anyhow::Result; -use snarkvm_curves::bls12_377::Bls12_377; -use snarkvm_curves::edwards_bls12::Fq; +use snarkvm_curves::{bls12_377::Bls12_377, edwards_bls12::Fq}; use snarkvm_r1cs::ConstraintSystem; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/commands/clean.rs b/leo/commands/clean.rs index 47bc2e1d1a..0b39661f07 100644 --- a/leo/commands/clean.rs +++ b/leo/commands/clean.rs @@ -14,14 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; use leo_compiler::OutputFile; -use leo_package::outputs::ChecksumFile; -use leo_package::outputs::CircuitFile; -use leo_package::outputs::ProofFile; -use leo_package::outputs::ProvingKeyFile; -use leo_package::outputs::VerificationKeyFile; +use leo_package::outputs::{ChecksumFile, CircuitFile, ProofFile, ProvingKeyFile, VerificationKeyFile}; use anyhow::Result; use structopt::StructOpt; diff --git a/leo/commands/deploy.rs b/leo/commands/deploy.rs index d3024ec902..06eff0c2e6 100644 --- a/leo/commands/deploy.rs +++ b/leo/commands/deploy.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; use anyhow::Result; use structopt::StructOpt; diff --git a/leo/commands/init.rs b/leo/commands/init.rs index a80d194965..7c6b3e7745 100644 --- a/leo/commands/init.rs +++ b/leo/commands/init.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; use leo_package::LeoPackage; -use anyhow::anyhow; -use anyhow::Result; +use anyhow::{anyhow, Result}; use std::env::current_dir; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/commands/lint.rs b/leo/commands/lint.rs index 9449d6f658..3e60d7ec6e 100644 --- a/leo/commands/lint.rs +++ b/leo/commands/lint.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; use anyhow::Result; use structopt::StructOpt; diff --git a/leo/commands/mod.rs b/leo/commands/mod.rs index bbaf2cbb60..47d5994575 100644 --- a/leo/commands/mod.rs +++ b/leo/commands/mod.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::context::get_context; -use crate::context::Context; +use crate::context::{get_context, Context}; use anyhow::Result; use std::time::Instant; @@ -53,8 +52,7 @@ pub mod test; pub use test::Test; pub mod update; -pub use update::Automatic as UpdateAutomatic; -pub use update::Update; +pub use update::{Automatic as UpdateAutomatic, Update}; pub mod watch; pub use watch::Watch; diff --git a/leo/commands/new.rs b/leo/commands/new.rs index b311445070..a4da67c309 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.rs @@ -14,14 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; use leo_package::LeoPackage; -use anyhow::anyhow; -use anyhow::Result; -use std::env::current_dir; -use std::fs; +use anyhow::{anyhow, Result}; +use std::{env::current_dir, fs}; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/commands/package/add.rs b/leo/commands/package/add.rs index 9543e7809a..ef1491f2f9 100644 --- a/leo/commands/package/add.rs +++ b/leo/commands/package/add.rs @@ -14,18 +14,14 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::api::Fetch; -use crate::commands::Command; -use crate::context::Context; -use leo_package::imports::ImportsDirectory; -use leo_package::imports::IMPORTS_DIRECTORY_NAME; +use crate::{api::Fetch, commands::Command, context::Context}; +use leo_package::imports::{ImportsDirectory, IMPORTS_DIRECTORY_NAME}; -use anyhow::anyhow; -use anyhow::Result; -use std::fs::create_dir_all; -use std::fs::File; -use std::io::Read; -use std::io::Write; +use anyhow::{anyhow, Result}; +use std::{ + fs::{create_dir_all, File}, + io::{Read, Write}, +}; use structopt::StructOpt; use tracing::Span; diff --git a/leo/commands/package/clone.rs b/leo/commands/package/clone.rs index f4dfaf846a..5b5e6acdcf 100644 --- a/leo/commands/package/clone.rs +++ b/leo/commands/package/clone.rs @@ -14,18 +14,18 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::api::Fetch; -use crate::commands::Command; -use crate::context::Context; +use crate::{api::Fetch, commands::Command, context::Context}; -use anyhow::anyhow; -use anyhow::Result; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Read; -use std::io::Write; -use std::path::Path; +use anyhow::{anyhow, Result}; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::{Read, Write}, + path::Path, +}; use structopt::StructOpt; use tracing::Span; diff --git a/leo/commands/package/login.rs b/leo/commands/package/login.rs index 83d81ac6c6..25425fccb0 100644 --- a/leo/commands/package/login.rs +++ b/leo/commands/package/login.rs @@ -14,14 +14,14 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::api::Login as LoginRoute; -use crate::api::Profile as ProfileRoute; -use crate::commands::Command; -use crate::config::*; -use crate::context::Context; +use crate::{ + api::{Login as LoginRoute, Profile as ProfileRoute}, + commands::Command, + config::*, + context::Context, +}; -use anyhow::anyhow; -use anyhow::Result; +use anyhow::{anyhow, Result}; use std::collections::HashMap; use structopt::StructOpt; use tracing::Span; diff --git a/leo/commands/package/logout.rs b/leo/commands/package/logout.rs index 4bc38b8cad..6bd76a2575 100644 --- a/leo/commands/package/logout.rs +++ b/leo/commands/package/logout.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::config::remove_token; -use crate::context::Context; +use crate::{commands::Command, config::remove_token, context::Context}; use anyhow::Result; use std::io::ErrorKind; diff --git a/leo/commands/package/publish.rs b/leo/commands/package/publish.rs index 382e9ad6c5..7b86763c67 100644 --- a/leo/commands/package/publish.rs +++ b/leo/commands/package/publish.rs @@ -15,18 +15,17 @@ // along with the Leo library. If not, see . use super::build::Build; -use crate::commands::Command; -use crate::context::Context; -use crate::context::PACKAGE_MANAGER_URL; -use leo_package::outputs::OutputsDirectory; -use leo_package::root::ZipFile; +use crate::{ + commands::Command, + context::{Context, PACKAGE_MANAGER_URL}, +}; +use leo_package::{outputs::OutputsDirectory, root::ZipFile}; -use anyhow::anyhow; -use anyhow::Result; -use reqwest::blocking::multipart::Form; -use reqwest::blocking::Client; -use reqwest::header::HeaderMap; -use reqwest::header::HeaderValue; +use anyhow::{anyhow, Result}; +use reqwest::{ + blocking::{multipart::Form, Client}, + header::{HeaderMap, HeaderValue}, +}; use serde::Deserialize; use structopt::StructOpt; diff --git a/leo/commands/package/remove.rs b/leo/commands/package/remove.rs index 5d88725cc9..f0df722146 100644 --- a/leo/commands/package/remove.rs +++ b/leo/commands/package/remove.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; use leo_package::LeoPackage; use anyhow::Result; diff --git a/leo/commands/prove.rs b/leo/commands/prove.rs index 3072841b99..da99c84aed 100644 --- a/leo/commands/prove.rs +++ b/leo/commands/prove.rs @@ -15,15 +15,13 @@ // along with the Leo library. If not, see . use super::setup::Setup; -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; use leo_package::outputs::ProofFile; -use snarkvm_algorithms::snark::groth16::Groth16; -use snarkvm_algorithms::snark::groth16::PreparedVerifyingKey; -use snarkvm_algorithms::snark::groth16::Proof; -use snarkvm_algorithms::traits::SNARK; -use snarkvm_curves::bls12_377::Bls12_377; -use snarkvm_curves::bls12_377::Fr; +use snarkvm_algorithms::{ + snark::groth16::{Groth16, PreparedVerifyingKey, Proof}, + traits::SNARK, +}; +use snarkvm_curves::bls12_377::{Bls12_377, Fr}; use snarkvm_utilities::bytes::ToBytes; use anyhow::Result; diff --git a/leo/commands/run.rs b/leo/commands/run.rs index 16e3f7f433..eeec6fc02d 100644 --- a/leo/commands/run.rs +++ b/leo/commands/run.rs @@ -15,16 +15,12 @@ // along with the Leo library. If not, see . use super::prove::Prove; -use crate::commands::Command; -use crate::context::Context; -use leo_compiler::compiler::Compiler; -use leo_compiler::group::targets::edwards_bls12::EdwardsGroupType; +use crate::{commands::Command, context::Context}; +use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType}; use anyhow::Result; -use snarkvm_algorithms::snark::groth16::Groth16; -use snarkvm_algorithms::traits::SNARK; -use snarkvm_curves::bls12_377::Bls12_377; -use snarkvm_curves::bls12_377::Fr; +use snarkvm_algorithms::{snark::groth16::Groth16, traits::SNARK}; +use snarkvm_curves::bls12_377::{Bls12_377, Fr}; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/commands/setup.rs b/leo/commands/setup.rs index c152033b43..5f76d88dd0 100644 --- a/leo/commands/setup.rs +++ b/leo/commands/setup.rs @@ -15,25 +15,20 @@ // along with the Leo library. If not, see . use super::build::Build; -use crate::commands::Command; -use crate::context::Context; -use leo_compiler::compiler::Compiler; -use leo_compiler::group::targets::edwards_bls12::EdwardsGroupType; -use leo_package::outputs::ProvingKeyFile; -use leo_package::outputs::VerificationKeyFile; -use leo_package::source::MAIN_FILENAME; -use leo_package::source::SOURCE_DIRECTORY_NAME; +use crate::{commands::Command, context::Context}; +use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType}; +use leo_package::{ + outputs::{ProvingKeyFile, VerificationKeyFile}, + source::{MAIN_FILENAME, SOURCE_DIRECTORY_NAME}, +}; -use anyhow::anyhow; -use anyhow::Result; +use anyhow::{anyhow, Result}; use rand::thread_rng; -use snarkvm_algorithms::snark::groth16::Groth16; -use snarkvm_algorithms::snark::groth16::Parameters; -use snarkvm_algorithms::snark::groth16::PreparedVerifyingKey; -use snarkvm_algorithms::snark::groth16::VerifyingKey; -use snarkvm_algorithms::traits::snark::SNARK; -use snarkvm_curves::bls12_377::Bls12_377; -use snarkvm_curves::bls12_377::Fr; +use snarkvm_algorithms::{ + snark::groth16::{Groth16, Parameters, PreparedVerifyingKey, VerifyingKey}, + traits::snark::SNARK, +}; +use snarkvm_curves::bls12_377::{Bls12_377, Fr}; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/commands/test.rs b/leo/commands/test.rs index a167af6e94..f5de8672f2 100644 --- a/leo/commands/test.rs +++ b/leo/commands/test.rs @@ -14,24 +14,20 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::context::Context; -use leo_compiler::compiler::thread_leaked_context; -use leo_compiler::compiler::Compiler; -use leo_compiler::group::targets::edwards_bls12::EdwardsGroupType; -use leo_package::inputs::*; -use leo_package::outputs::OutputsDirectory; -use leo_package::outputs::OUTPUTS_DIRECTORY_NAME; -use leo_package::source::MainFile; -use leo_package::source::MAIN_FILENAME; -use leo_package::source::SOURCE_DIRECTORY_NAME; +use crate::{commands::Command, context::Context}; +use leo_compiler::{ + compiler::{thread_leaked_context, Compiler}, + group::targets::edwards_bls12::EdwardsGroupType, +}; +use leo_package::{ + inputs::*, + outputs::{OutputsDirectory, OUTPUTS_DIRECTORY_NAME}, + source::{MainFile, MAIN_FILENAME, SOURCE_DIRECTORY_NAME}, +}; -use anyhow::anyhow; -use anyhow::Result; +use anyhow::{anyhow, Result}; use snarkvm_curves::edwards_bls12::Fq; -use std::convert::TryFrom; -use std::path::PathBuf; -use std::time::Instant; +use std::{convert::TryFrom, path::PathBuf, time::Instant}; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/commands/update.rs b/leo/commands/update.rs index c643ec2b49..f3027e5907 100644 --- a/leo/commands/update.rs +++ b/leo/commands/update.rs @@ -14,13 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::commands::Command; -use crate::config::Config; -use crate::context::Context; -use crate::updater::Updater; +use crate::{commands::Command, config::Config, context::Context, updater::Updater}; -use anyhow::anyhow; -use anyhow::Result; +use anyhow::{anyhow, Result}; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/commands/watch.rs b/leo/commands/watch.rs index ef4f4bf80a..7a98b9604f 100644 --- a/leo/commands/watch.rs +++ b/leo/commands/watch.rs @@ -15,18 +15,12 @@ // along with the Leo library. If not, see . use super::build::Build; -use crate::commands::Command; -use crate::context::Context; +use crate::{commands::Command, context::Context}; -use std::sync::mpsc::channel; -use std::time::Duration; +use std::{sync::mpsc::channel, time::Duration}; -use anyhow::anyhow; -use anyhow::Result; -use notify::watcher; -use notify::DebouncedEvent; -use notify::RecursiveMode; -use notify::Watcher; +use anyhow::{anyhow, Result}; +use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use structopt::StructOpt; use tracing::span::Span; diff --git a/leo/config.rs b/leo/config.rs index 3b9373896a..11de847b70 100644 --- a/leo/config.rs +++ b/leo/config.rs @@ -14,19 +14,21 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::fs::create_dir_all; -use std::fs::File; -use std::fs::{self}; -use std::io; -use std::io::prelude::*; -use std::path::Path; -use std::path::PathBuf; +use std::{ + fs::{ + create_dir_all, + File, + {self}, + }, + io, + io::prelude::*, + path::{Path, PathBuf}, +}; use anyhow::Error; use dirs::home_dir; use lazy_static::lazy_static; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; pub const LEO_CREDENTIALS_FILE: &str = "credentials"; pub const LEO_CONFIG_FILE: &str = "config.toml"; diff --git a/leo/context.rs b/leo/context.rs index 04404fc2e5..bddd54e5f2 100644 --- a/leo/context.rs +++ b/leo/context.rs @@ -14,14 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::api::Api; -use crate::config; +use crate::{api::Api, config}; use leo_package::root::Manifest; use anyhow::Result; -use std::convert::TryFrom; -use std::env::current_dir; -use std::path::PathBuf; +use std::{convert::TryFrom, env::current_dir, path::PathBuf}; pub const PACKAGE_MANAGER_URL: &str = "https://api.aleo.pm/"; diff --git a/leo/logger.rs b/leo/logger.rs index 69df6295b6..a2f81bc4c1 100644 --- a/leo/logger.rs +++ b/leo/logger.rs @@ -17,14 +17,12 @@ use std::fmt; use colored::Colorize; -use tracing::event::Event; -use tracing::subscriber::Subscriber; -use tracing_subscriber::fmt::format::*; -use tracing_subscriber::fmt::time::*; -use tracing_subscriber::fmt::FmtContext; -use tracing_subscriber::fmt::FormattedFields; -use tracing_subscriber::registry::LookupSpan; -use tracing_subscriber::FmtSubscriber; +use tracing::{event::Event, subscriber::Subscriber}; +use tracing_subscriber::{ + fmt::{format::*, time::*, FmtContext, FormattedFields}, + registry::LookupSpan, + FmtSubscriber, +}; #[derive(Debug, Clone)] pub struct Format { diff --git a/leo/main.rs b/leo/main.rs index bf48db7525..a0d256230c 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -21,30 +21,26 @@ pub mod context; pub mod logger; pub mod updater; -use commands::package::Add; -use commands::package::Clone; -use commands::package::Login; -use commands::package::Logout; -use commands::package::Publish; -use commands::package::Remove; -use commands::Build; -use commands::Clean; -use commands::Command; -use commands::Deploy; -use commands::Init; -use commands::Lint; -use commands::New; -use commands::Prove; -use commands::Run; -use commands::Setup; -use commands::Test; -use commands::Update; -use commands::Watch; +use commands::{ + package::{Add, Clone, Login, Logout, Publish, Remove}, + Build, + Clean, + Command, + Deploy, + Init, + Lint, + New, + Prove, + Run, + Setup, + Test, + Update, + Watch, +}; use anyhow::Error; use std::process::exit; -use structopt::clap::AppSettings; -use structopt::StructOpt; +use structopt::{clap::AppSettings, StructOpt}; /// CLI Arguments entry point - includes global parameters and subcommands #[derive(StructOpt, Debug)] diff --git a/leo/tests/mod.rs b/leo/tests/mod.rs index 90a44aa441..7bc611f49d 100644 --- a/leo/tests/mod.rs +++ b/leo/tests/mod.rs @@ -18,18 +18,20 @@ use std::path::PathBuf; use anyhow::Result; -use crate::commands::package::Login; -use crate::commands::package::Logout; -use crate::commands::Build; -use crate::commands::Command; -use crate::commands::Prove; -use crate::commands::Run; -use crate::commands::Setup; -use crate::commands::Test; -use crate::commands::Update; -use crate::commands::UpdateAutomatic; -use crate::context::create_context; -use crate::context::Context; +use crate::{ + commands::{ + package::{Login, Logout}, + Build, + Command, + Prove, + Run, + Setup, + Test, + Update, + UpdateAutomatic, + }, + context::{create_context, Context}, +}; /// Path to the only complex Leo program that we have /// - relative to source dir - where Cargo.toml is located diff --git a/leo/updater.rs b/leo/updater.rs index d9aa6cc58a..cc5c8972da 100644 --- a/leo/updater.rs +++ b/leo/updater.rs @@ -16,12 +16,9 @@ use crate::config::Config; -use anyhow::anyhow; -use anyhow::Result; +use anyhow::{anyhow, Result}; use colored::Colorize; -use self_update::backends::github; -use self_update::version::bump_is_greater; -use self_update::Status; +use self_update::{backends::github, version::bump_is_greater, Status}; pub struct Updater; diff --git a/package/src/errors/imports/directory.rs b/package/src/errors/imports/directory.rs index a3faddac08..05e6cfadf2 100644 --- a/package/src/errors/imports/directory.rs +++ b/package/src/errors/imports/directory.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::ffi::OsString; -use std::fs::FileType; -use std::io; +use std::{ffi::OsString, fs::FileType, io}; #[derive(Debug, Error)] pub enum ImportsDirectoryError { diff --git a/package/src/errors/inputs/directory.rs b/package/src/errors/inputs/directory.rs index efae1910d9..ee93d8c6d6 100644 --- a/package/src/errors/inputs/directory.rs +++ b/package/src/errors/inputs/directory.rs @@ -14,12 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::InputFileError; -use crate::StateFileError; +use crate::{InputFileError, StateFileError}; -use std::ffi::OsString; -use std::fs::FileType; -use std::io; +use std::{ffi::OsString, fs::FileType, io}; #[derive(Debug, Error)] pub enum InputsDirectoryError { diff --git a/package/src/errors/inputs/input.rs b/package/src/errors/inputs/input.rs index 1d83a076ec..659fcf32a3 100644 --- a/package/src/errors/inputs/input.rs +++ b/package/src/errors/inputs/input.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum InputFileError { diff --git a/package/src/errors/inputs/state.rs b/package/src/errors/inputs/state.rs index 44e89e242e..8d56253b46 100644 --- a/package/src/errors/inputs/state.rs +++ b/package/src/errors/inputs/state.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum StateFileError { diff --git a/package/src/errors/outputs/checksum.rs b/package/src/errors/outputs/checksum.rs index cc1e6b5ed7..e2a6bd4375 100644 --- a/package/src/errors/outputs/checksum.rs +++ b/package/src/errors/outputs/checksum.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum ChecksumFileError { diff --git a/package/src/errors/outputs/circuit.rs b/package/src/errors/outputs/circuit.rs index dee36386f3..ce006c88f2 100644 --- a/package/src/errors/outputs/circuit.rs +++ b/package/src/errors/outputs/circuit.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum CircuitFileError { diff --git a/package/src/errors/outputs/directory.rs b/package/src/errors/outputs/directory.rs index 0c079335a6..2e16be7e39 100644 --- a/package/src/errors/outputs/directory.rs +++ b/package/src/errors/outputs/directory.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::ffi::OsString; -use std::fs::FileType; -use std::io; +use std::{ffi::OsString, fs::FileType, io}; #[derive(Debug, Error)] pub enum OutputsDirectoryError { diff --git a/package/src/errors/outputs/proof.rs b/package/src/errors/outputs/proof.rs index e0080bc7dd..461a3ab259 100644 --- a/package/src/errors/outputs/proof.rs +++ b/package/src/errors/outputs/proof.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum ProofFileError { diff --git a/package/src/errors/outputs/proving_key.rs b/package/src/errors/outputs/proving_key.rs index 1d76fa4ce5..d78e62aec4 100644 --- a/package/src/errors/outputs/proving_key.rs +++ b/package/src/errors/outputs/proving_key.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum ProvingKeyFileError { diff --git a/package/src/errors/outputs/verification_key.rs b/package/src/errors/outputs/verification_key.rs index 6765946767..51398e630c 100644 --- a/package/src/errors/outputs/verification_key.rs +++ b/package/src/errors/outputs/verification_key.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; #[derive(Debug, Error)] pub enum VerificationKeyFileError { diff --git a/package/src/errors/package.rs b/package/src/errors/package.rs index ddb1f707cb..f0a07ea1ee 100644 --- a/package/src/errors/package.rs +++ b/package/src/errors/package.rs @@ -13,8 +13,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::ffi::OsString; -use std::io; +use std::{ffi::OsString, io}; #[derive(Debug, Error)] pub enum PackageError { diff --git a/package/src/errors/root/zip.rs b/package/src/errors/root/zip.rs index c89a3ac5bd..e9a9c15b82 100644 --- a/package/src/errors/root/zip.rs +++ b/package/src/errors/root/zip.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::io; -use std::path::PathBuf; +use std::{io, path::PathBuf}; use walkdir::Error as WalkDirError; use zip::result::ZipError; diff --git a/package/src/errors/source/directory.rs b/package/src/errors/source/directory.rs index 22ed510d24..00d0629ec2 100644 --- a/package/src/errors/source/directory.rs +++ b/package/src/errors/source/directory.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::ffi::OsString; -use std::fs::FileType; -use std::io; +use std::{ffi::OsString, fs::FileType, io}; #[derive(Debug, Error)] pub enum SourceDirectoryError { diff --git a/package/src/imports/directory.rs b/package/src/imports/directory.rs index c14194e9c3..a1d7e850ea 100644 --- a/package/src/imports/directory.rs +++ b/package/src/imports/directory.rs @@ -16,9 +16,7 @@ use crate::errors::ImportsDirectoryError; -use std::borrow::Cow; -use std::fs; -use std::path::Path; +use std::{borrow::Cow, fs, path::Path}; pub static IMPORTS_DIRECTORY_NAME: &str = "imports/"; diff --git a/package/src/inputs/directory.rs b/package/src/inputs/directory.rs index 3d3e4988fd..77b4701501 100644 --- a/package/src/inputs/directory.rs +++ b/package/src/inputs/directory.rs @@ -16,11 +16,12 @@ use crate::errors::InputsDirectoryError; -use std::borrow::Cow; -use std::fs; -use std::fs::ReadDir; -use std::path::Path; -use std::path::PathBuf; +use std::{ + borrow::Cow, + fs, + fs::ReadDir, + path::{Path, PathBuf}, +}; pub static INPUTS_DIRECTORY_NAME: &str = "inputs/"; diff --git a/package/src/inputs/input.rs b/package/src/inputs/input.rs index a48ba3cbba..3e01cbbe5d 100644 --- a/package/src/inputs/input.rs +++ b/package/src/inputs/input.rs @@ -16,15 +16,18 @@ //! The `program.in` file. -use crate::errors::InputFileError; -use crate::inputs::INPUTS_DIRECTORY_NAME; +use crate::{errors::InputFileError, inputs::INPUTS_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static INPUT_FILE_EXTENSION: &str = ".in"; diff --git a/package/src/inputs/pairs.rs b/package/src/inputs/pairs.rs index 9533481c61..0d21e7c7f4 100644 --- a/package/src/inputs/pairs.rs +++ b/package/src/inputs/pairs.rs @@ -14,16 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::inputs::InputFile; -use crate::inputs::InputsDirectory; -use crate::inputs::StateFile; -use crate::inputs::INPUT_FILE_EXTENSION; -use crate::inputs::STATE_FILE_EXTENSION; -use crate::InputsDirectoryError; +use crate::{ + inputs::{InputFile, InputsDirectory, StateFile, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION}, + InputsDirectoryError, +}; -use std::collections::HashMap; -use std::convert::TryFrom; -use std::path::Path; +use std::{collections::HashMap, convert::TryFrom, path::Path}; #[derive(Default)] pub struct InputPairs { diff --git a/package/src/inputs/state.rs b/package/src/inputs/state.rs index 4dbfbbedf4..7bda80ceb7 100644 --- a/package/src/inputs/state.rs +++ b/package/src/inputs/state.rs @@ -16,15 +16,18 @@ //! The `program.state` file. -use crate::errors::StateFileError; -use crate::inputs::INPUTS_DIRECTORY_NAME; +use crate::{errors::StateFileError, inputs::INPUTS_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static STATE_FILE_EXTENSION: &str = ".state"; diff --git a/package/src/outputs/checksum.rs b/package/src/outputs/checksum.rs index d789cb5ce9..9352429973 100644 --- a/package/src/outputs/checksum.rs +++ b/package/src/outputs/checksum.rs @@ -16,15 +16,18 @@ //! The build checksum file. -use crate::errors::ChecksumFileError; -use crate::outputs::OUTPUTS_DIRECTORY_NAME; +use crate::{errors::ChecksumFileError, outputs::OUTPUTS_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static CHECKSUM_FILE_EXTENSION: &str = ".sum"; diff --git a/package/src/outputs/circuit.rs b/package/src/outputs/circuit.rs index 3f9ec82a99..d9d0e8cced 100644 --- a/package/src/outputs/circuit.rs +++ b/package/src/outputs/circuit.rs @@ -16,15 +16,18 @@ //! The serialized circuit output file. -use crate::errors::CircuitFileError; -use crate::outputs::OUTPUTS_DIRECTORY_NAME; +use crate::{errors::CircuitFileError, outputs::OUTPUTS_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static CIRCUIT_FILE_EXTENSION: &str = ".json"; diff --git a/package/src/outputs/directory.rs b/package/src/outputs/directory.rs index ec49dc8f9e..e2557f343c 100644 --- a/package/src/outputs/directory.rs +++ b/package/src/outputs/directory.rs @@ -16,9 +16,7 @@ use crate::errors::OutputsDirectoryError; -use std::borrow::Cow; -use std::fs; -use std::path::Path; +use std::{borrow::Cow, fs, path::Path}; pub static OUTPUTS_DIRECTORY_NAME: &str = "outputs/"; diff --git a/package/src/outputs/proof.rs b/package/src/outputs/proof.rs index 14f394af42..815d6048be 100644 --- a/package/src/outputs/proof.rs +++ b/package/src/outputs/proof.rs @@ -16,15 +16,18 @@ //! The proof file. -use crate::errors::ProofFileError; -use crate::outputs::OUTPUTS_DIRECTORY_NAME; +use crate::{errors::ProofFileError, outputs::OUTPUTS_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static PROOF_FILE_EXTENSION: &str = ".proof"; diff --git a/package/src/outputs/proving_key.rs b/package/src/outputs/proving_key.rs index cb76033eee..7e2d938bd7 100644 --- a/package/src/outputs/proving_key.rs +++ b/package/src/outputs/proving_key.rs @@ -16,15 +16,18 @@ //! The proving key file. -use crate::errors::ProvingKeyFileError; -use crate::outputs::OUTPUTS_DIRECTORY_NAME; +use crate::{errors::ProvingKeyFileError, outputs::OUTPUTS_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static PROVING_KEY_FILE_EXTENSION: &str = ".lpk"; diff --git a/package/src/outputs/verification_key.rs b/package/src/outputs/verification_key.rs index c10b4de1b8..6f7fca8797 100644 --- a/package/src/outputs/verification_key.rs +++ b/package/src/outputs/verification_key.rs @@ -16,15 +16,18 @@ //! The verification key file. -use crate::errors::VerificationKeyFileError; -use crate::outputs::OUTPUTS_DIRECTORY_NAME; +use crate::{errors::VerificationKeyFileError, outputs::OUTPUTS_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::Write, + path::Path, +}; pub static VERIFICATION_KEY_FILE_EXTENSION: &str = ".lvk"; diff --git a/package/src/package.rs b/package/src/package.rs index 4089da6d31..f5c46e2696 100644 --- a/package/src/package.rs +++ b/package/src/package.rs @@ -14,17 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::PackageError; -use crate::imports::ImportsDirectory; -use crate::inputs::InputFile; -use crate::inputs::InputsDirectory; -use crate::inputs::StateFile; -use crate::root::Gitignore; -use crate::root::Manifest; -use crate::root::README; -use crate::source::LibraryFile; -use crate::source::MainFile; -use crate::source::SourceDirectory; +use crate::{ + errors::PackageError, + imports::ImportsDirectory, + inputs::{InputFile, InputsDirectory, StateFile}, + root::{Gitignore, Manifest, README}, + source::{LibraryFile, MainFile, SourceDirectory}, +}; use serde::Deserialize; use std::path::Path; diff --git a/package/src/root/gitignore.rs b/package/src/root/gitignore.rs index 3cdba044d5..756c51be05 100644 --- a/package/src/root/gitignore.rs +++ b/package/src/root/gitignore.rs @@ -19,10 +19,7 @@ use crate::errors::GitignoreError; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::io::Write; -use std::path::Path; +use std::{borrow::Cow, fs::File, io::Write, path::Path}; pub static GITIGNORE_FILENAME: &str = ".gitignore"; diff --git a/package/src/root/manifest.rs b/package/src/root/manifest.rs index 44c9983efe..540749fcdc 100644 --- a/package/src/root/manifest.rs +++ b/package/src/root/manifest.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::errors::ManifestError; -use crate::package::Package; +use crate::{errors::ManifestError, package::Package}; use serde::Deserialize; -use std::borrow::Cow; -use std::convert::TryFrom; -use std::fs::File; -use std::io::Read; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + convert::TryFrom, + fs::File, + io::{Read, Write}, + path::Path, +}; pub const MANIFEST_FILENAME: &str = "Leo.toml"; diff --git a/package/src/root/readme.rs b/package/src/root/readme.rs index 700e068f3a..468f5e58b9 100644 --- a/package/src/root/readme.rs +++ b/package/src/root/readme.rs @@ -19,10 +19,7 @@ use crate::errors::READMEError; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::io::Write; -use std::path::Path; +use std::{borrow::Cow, fs::File, io::Write, path::Path}; pub static README_FILENAME: &str = "README.md"; diff --git a/package/src/root/zip.rs b/package/src/root/zip.rs index e02671d2c8..46426b9d3e 100644 --- a/package/src/root/zip.rs +++ b/package/src/root/zip.rs @@ -16,32 +16,34 @@ //! The program package zip file. -use crate::errors::ZipFileError; -use crate::imports::IMPORTS_DIRECTORY_NAME; -use crate::inputs::INPUTS_DIRECTORY_NAME; -use crate::inputs::INPUT_FILE_EXTENSION; -use crate::inputs::STATE_FILE_EXTENSION; -use crate::outputs::CHECKSUM_FILE_EXTENSION; -use crate::outputs::CIRCUIT_FILE_EXTENSION; -use crate::outputs::OUTPUTS_DIRECTORY_NAME; -use crate::outputs::PROOF_FILE_EXTENSION; -use crate::outputs::PROVING_KEY_FILE_EXTENSION; -use crate::outputs::VERIFICATION_KEY_FILE_EXTENSION; -use crate::root::MANIFEST_FILENAME; -use crate::root::README_FILENAME; -use crate::source::SOURCE_DIRECTORY_NAME; -use crate::source::SOURCE_FILE_EXTENSION; +use crate::{ + errors::ZipFileError, + imports::IMPORTS_DIRECTORY_NAME, + inputs::{INPUTS_DIRECTORY_NAME, INPUT_FILE_EXTENSION, STATE_FILE_EXTENSION}, + outputs::{ + CHECKSUM_FILE_EXTENSION, + CIRCUIT_FILE_EXTENSION, + OUTPUTS_DIRECTORY_NAME, + PROOF_FILE_EXTENSION, + PROVING_KEY_FILE_EXTENSION, + VERIFICATION_KEY_FILE_EXTENSION, + }, + root::{MANIFEST_FILENAME, README_FILENAME}, + source::{SOURCE_DIRECTORY_NAME, SOURCE_FILE_EXTENSION}, +}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::fs::{self}; -use std::io::Read; -use std::io::Write; -use std::path::Path; +use std::{ + borrow::Cow, + fs::{ + File, + {self}, + }, + io::{Read, Write}, + path::Path, +}; use walkdir::WalkDir; -use zip::write::FileOptions; -use zip::write::ZipWriter; +use zip::write::{FileOptions, ZipWriter}; pub static ZIP_FILE_EXTENSION: &str = ".zip"; diff --git a/package/src/source/directory.rs b/package/src/source/directory.rs index 15053337c6..5764f972df 100644 --- a/package/src/source/directory.rs +++ b/package/src/source/directory.rs @@ -16,10 +16,11 @@ use crate::errors::SourceDirectoryError; -use std::borrow::Cow; -use std::fs; -use std::path::Path; -use std::path::PathBuf; +use std::{ + borrow::Cow, + fs, + path::{Path, PathBuf}, +}; pub static SOURCE_DIRECTORY_NAME: &str = "src/"; diff --git a/package/src/source/library.rs b/package/src/source/library.rs index e33aa1b2b0..90a5193b85 100644 --- a/package/src/source/library.rs +++ b/package/src/source/library.rs @@ -16,14 +16,10 @@ //! The `lib.leo` file. -use crate::errors::LibraryFileError; -use crate::source::directory::SOURCE_DIRECTORY_NAME; +use crate::{errors::LibraryFileError, source::directory::SOURCE_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::io::Write; -use std::path::Path; +use std::{borrow::Cow, fs::File, io::Write, path::Path}; pub static LIBRARY_FILENAME: &str = "lib.leo"; diff --git a/package/src/source/main.rs b/package/src/source/main.rs index 6709be131b..7ac8c4990d 100644 --- a/package/src/source/main.rs +++ b/package/src/source/main.rs @@ -16,14 +16,10 @@ //! The `main.leo` file. -use crate::errors::MainFileError; -use crate::source::directory::SOURCE_DIRECTORY_NAME; +use crate::{errors::MainFileError, source::directory::SOURCE_DIRECTORY_NAME}; use serde::Deserialize; -use std::borrow::Cow; -use std::fs::File; -use std::io::Write; -use std::path::Path; +use std::{borrow::Cow, fs::File, io::Write, path::Path}; pub static MAIN_FILENAME: &str = "main.leo"; diff --git a/package/tests/initialize/initialize.rs b/package/tests/initialize/initialize.rs index de255bf97c..5e1b98bde8 100644 --- a/package/tests/initialize/initialize.rs +++ b/package/tests/initialize/initialize.rs @@ -15,14 +15,12 @@ // along with the Leo library. If not, see . use crate::test_dir; -use leo_package::inputs::InputFile; -use leo_package::inputs::InputsDirectory; -use leo_package::inputs::StateFile; -use leo_package::package::Package; -use leo_package::root::Manifest; -use leo_package::source::LibraryFile; -use leo_package::source::MainFile; -use leo_package::source::SourceDirectory; +use leo_package::{ + inputs::{InputFile, InputsDirectory, StateFile}, + package::Package, + root::Manifest, + source::{LibraryFile, MainFile, SourceDirectory}, +}; const TEST_PACKAGE_NAME: &str = "test-package"; diff --git a/package/tests/manifest/manifest.rs b/package/tests/manifest/manifest.rs index 070289d7c7..d58fce5150 100644 --- a/package/tests/manifest/manifest.rs +++ b/package/tests/manifest/manifest.rs @@ -17,15 +17,14 @@ // Tests for package manifest use crate::test_dir; -use leo_package::root::Manifest; -use leo_package::root::MANIFEST_FILENAME; +use leo_package::root::{Manifest, MANIFEST_FILENAME}; -use std::convert::TryFrom; -use std::fs::File; -use std::io::Read; -use std::io::Write; -use std::path::Path; -use std::path::PathBuf; +use std::{ + convert::TryFrom, + fs::File, + io::{Read, Write}, + path::{Path, PathBuf}, +}; const OLD_MANIFEST_FORMAT: &str = r#"[package] name = "test-package" diff --git a/package/tests/mod.rs b/package/tests/mod.rs index da355df338..8f72a16b3e 100644 --- a/package/tests/mod.rs +++ b/package/tests/mod.rs @@ -20,12 +20,13 @@ pub mod initialize; pub mod manifest; use lazy_static::lazy_static; -use std::cell::RefCell; -use std::env; -use std::fs; -use std::path::PathBuf; -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; +use std::{ + cell::RefCell, + env, + fs, + path::PathBuf, + sync::atomic::{AtomicUsize, Ordering}, +}; const PACKAGE_TEST_DIRECTORY: &str = "package-testing"; diff --git a/state/Cargo.toml b/state/Cargo.toml index 8e7d0573cf..72b7c71b02 100644 --- a/state/Cargo.toml +++ b/state/Cargo.toml @@ -27,7 +27,7 @@ version = "1.2.3" [dependencies.snarkvm-algorithms] version = "0.2.0" -default-features = false +#default-features = false [dependencies.snarkvm-curves] version = "0.2.0" diff --git a/state/src/errors/dpc_record_values.rs b/state/src/errors/dpc_record_values.rs index 0f97cf7f91..437666bfea 100644 --- a/state/src/errors/dpc_record_values.rs +++ b/state/src/errors/dpc_record_values.rs @@ -18,8 +18,7 @@ use crate::InputValueError; use snarkvm_dpc::AccountError; -use std::num::ParseIntError; -use std::str::ParseBoolError; +use std::{num::ParseIntError, str::ParseBoolError}; #[derive(Debug, Error)] pub enum DPCRecordValuesError { diff --git a/state/src/errors/local_data_commitment.rs b/state/src/errors/local_data_commitment.rs index d5fb0c5ee8..a0f8465983 100644 --- a/state/src/errors/local_data_commitment.rs +++ b/state/src/errors/local_data_commitment.rs @@ -14,12 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::RecordVerificationError; -use crate::StateLeafValuesError; -use crate::StateValuesError; +use crate::{RecordVerificationError, StateLeafValuesError, StateValuesError}; -use snarkvm_algorithms::CommitmentError; -use snarkvm_algorithms::MerkleError; +use snarkvm_algorithms::{CommitmentError, MerkleError}; use std::io::Error as IOError; diff --git a/state/src/errors/state_leaf_values.rs b/state/src/errors/state_leaf_values.rs index 503aff91d2..83b377178a 100644 --- a/state/src/errors/state_leaf_values.rs +++ b/state/src/errors/state_leaf_values.rs @@ -16,8 +16,7 @@ use crate::InputValueError; -use std::num::ParseIntError; -use std::str::ParseBoolError; +use std::{num::ParseIntError, str::ParseBoolError}; #[derive(Debug, Error)] pub enum StateLeafValuesError { diff --git a/state/src/errors/state_values.rs b/state/src/errors/state_values.rs index 9195833463..94af651517 100644 --- a/state/src/errors/state_values.rs +++ b/state/src/errors/state_values.rs @@ -16,8 +16,7 @@ use crate::InputValueError; -use std::num::ParseIntError; -use std::str::ParseBoolError; +use std::{num::ParseIntError, str::ParseBoolError}; #[derive(Debug, Error)] pub enum StateValuesError { diff --git a/state/src/local_data_commitment/local_data_commitment.rs b/state/src/local_data_commitment/local_data_commitment.rs index fd23158814..9576603447 100644 --- a/state/src/local_data_commitment/local_data_commitment.rs +++ b/state/src/local_data_commitment/local_data_commitment.rs @@ -14,23 +14,21 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::verify_record_commitment; -use crate::LocalDataVerificationError; -use crate::StateLeafValues; -use crate::StateValues; +use crate::{verify_record_commitment, LocalDataVerificationError, StateLeafValues, StateValues}; use leo_ast::Input as AstInput; -use snarkvm_algorithms::commitment_tree::CommitmentMerklePath; -use snarkvm_algorithms::traits::CommitmentScheme; -use snarkvm_algorithms::traits::CRH; -use snarkvm_dpc::base_dpc::instantiated::Components; -use snarkvm_dpc::base_dpc::instantiated::LocalDataCRH; -use snarkvm_dpc::base_dpc::instantiated::LocalDataCommitment; -use snarkvm_dpc::base_dpc::parameters::SystemParameters; -use snarkvm_dpc::traits::DPCComponents; -use snarkvm_utilities::bytes::ToBytes; -use snarkvm_utilities::to_bytes; -use snarkvm_utilities::FromBytes; +use snarkvm_algorithms::{ + commitment_tree::CommitmentMerklePath, + traits::{CommitmentScheme, CRH}, +}; +use snarkvm_dpc::{ + base_dpc::{ + instantiated::{Components, LocalDataCRH, LocalDataCommitment}, + parameters::SystemParameters, + }, + traits::DPCComponents, +}; +use snarkvm_utilities::{bytes::ToBytes, to_bytes, FromBytes}; use std::convert::TryFrom; diff --git a/state/src/local_data_commitment/state_leaf_values.rs b/state/src/local_data_commitment/state_leaf_values.rs index 89dc5de902..8c7148741d 100644 --- a/state/src/local_data_commitment/state_leaf_values.rs +++ b/state/src/local_data_commitment/state_leaf_values.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::find_input; -use crate::input_to_bytes; -use crate::input_to_integer_string; -use crate::StateLeafValuesError; +use crate::{find_input, input_to_bytes, input_to_integer_string, StateLeafValuesError}; use leo_ast::StateLeaf as AstStateLeaf; use std::convert::TryFrom; diff --git a/state/src/local_data_commitment/state_values.rs b/state/src/local_data_commitment/state_values.rs index 0a0777a5fb..0ba48af568 100644 --- a/state/src/local_data_commitment/state_values.rs +++ b/state/src/local_data_commitment/state_values.rs @@ -14,10 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::find_input; -use crate::input_to_bytes; -use crate::input_to_integer_string; -use crate::StateValuesError; +use crate::{find_input, input_to_bytes, input_to_integer_string, StateValuesError}; use leo_ast::State as AstState; use std::convert::TryFrom; diff --git a/state/src/record_commitment/dpc_record_values.rs b/state/src/record_commitment/dpc_record_values.rs index ca217a11b3..9c6ccc05b6 100644 --- a/state/src/record_commitment/dpc_record_values.rs +++ b/state/src/record_commitment/dpc_record_values.rs @@ -14,15 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::utilities::*; -use crate::DPCRecordValuesError; +use crate::{utilities::*, DPCRecordValuesError}; use leo_ast::Record as AstRecord; -use snarkvm_dpc::base_dpc::instantiated::Components; -use snarkvm_dpc::AccountAddress; +use snarkvm_dpc::{base_dpc::instantiated::Components, AccountAddress}; -use std::convert::TryFrom; -use std::str::FromStr; +use std::{convert::TryFrom, str::FromStr}; static SERIAL_NUMBER_PARAMETER_STRING: &str = "serial_number"; static OWNER_PARAMETER_STRING: &str = "owner"; diff --git a/state/src/record_commitment/record_commitment.rs b/state/src/record_commitment/record_commitment.rs index ecff6fd880..02ff4b977f 100644 --- a/state/src/record_commitment/record_commitment.rs +++ b/state/src/record_commitment/record_commitment.rs @@ -14,17 +14,15 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::DPCRecordValues; -use crate::RecordVerificationError; +use crate::{DPCRecordValues, RecordVerificationError}; use leo_ast::Record as AstRecord; use snarkvm_algorithms::traits::CommitmentScheme; -use snarkvm_dpc::base_dpc::instantiated::Components; -use snarkvm_dpc::base_dpc::instantiated::RecordCommitment; -use snarkvm_dpc::base_dpc::parameters::SystemParameters; -use snarkvm_utilities::bytes::ToBytes; -use snarkvm_utilities::to_bytes; -use snarkvm_utilities::FromBytes; +use snarkvm_dpc::base_dpc::{ + instantiated::{Components, RecordCommitment}, + parameters::SystemParameters, +}; +use snarkvm_utilities::{bytes::ToBytes, to_bytes, FromBytes}; use std::convert::TryFrom; diff --git a/state/src/utilities/input_value.rs b/state/src/utilities/input_value.rs index 792ff3820b..cdcf32feb1 100644 --- a/state/src/utilities/input_value.rs +++ b/state/src/utilities/input_value.rs @@ -15,8 +15,7 @@ // along with the Leo library. If not, see . use crate::InputValueError; -use leo_ast::InputValue; -use leo_ast::Parameter; +use leo_ast::{InputValue, Parameter}; use indexmap::IndexMap; diff --git a/state/tests/test_verify_local_data_commitment.rs b/state/tests/test_verify_local_data_commitment.rs index 147650ffde..f0a8e6b431 100644 --- a/state/tests/test_verify_local_data_commitment.rs +++ b/state/tests/test_verify_local_data_commitment.rs @@ -18,16 +18,14 @@ use leo_ast::Input; use leo_input::LeoInputParser; use leo_state::verify_local_data_commitment; -use snarkvm_algorithms::traits::CommitmentScheme; -use snarkvm_algorithms::traits::CRH; -use snarkvm_dpc::base_dpc::instantiated::*; -use snarkvm_dpc::base_dpc::record_payload::RecordPayload; -use snarkvm_dpc::base_dpc::DPC; -use snarkvm_dpc::Account; -use snarkvm_dpc::AccountScheme; -use snarkvm_dpc::Record; -use snarkvm_utilities::bytes::ToBytes; -use snarkvm_utilities::to_bytes; +use snarkvm_algorithms::traits::{CommitmentScheme, CRH}; +use snarkvm_dpc::{ + base_dpc::{instantiated::*, record_payload::RecordPayload, DPC}, + Account, + AccountScheme, + Record, +}; +use snarkvm_utilities::{bytes::ToBytes, to_bytes}; use rand::Rng; use rand_core::SeedableRng; @@ -74,11 +72,13 @@ fn test_generate_values_from_dpc() { let noop_program_snark_pp = InstantiatedDPC::generate_noop_program_snark_parameters(&system_parameters, &mut rng).unwrap(); - let noop_program_id = to_bytes![ProgramVerificationKeyCRH::hash( - &system_parameters.program_verification_key_crh, - &to_bytes![noop_program_snark_pp.verification_key].unwrap() - ) - .unwrap()] + let noop_program_id = to_bytes![ + ProgramVerificationKeyCRH::hash( + &system_parameters.program_verification_key_crh, + &to_bytes![noop_program_snark_pp.verification_key].unwrap() + ) + .unwrap() + ] .unwrap(); let signature_parameters = &system_parameters.account_signature; diff --git a/synthesizer/src/circuit_synthesizer.rs b/synthesizer/src/circuit_synthesizer.rs index 014a4401dd..356f97d15a 100644 --- a/synthesizer/src/circuit_synthesizer.rs +++ b/synthesizer/src/circuit_synthesizer.rs @@ -16,12 +16,7 @@ use snarkvm_curves::traits::PairingEngine; use snarkvm_fields::Field; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Index; -use snarkvm_r1cs::LinearCombination; -use snarkvm_r1cs::OptionalVec; -use snarkvm_r1cs::SynthesisError; -use snarkvm_r1cs::Variable; +use snarkvm_r1cs::{ConstraintSystem, Index, LinearCombination, OptionalVec, SynthesisError, Variable}; #[derive(Default)] pub struct Namespace { diff --git a/synthesizer/src/serialized_circuit.rs b/synthesizer/src/serialized_circuit.rs index ef09a9cce1..4f20704b2c 100644 --- a/synthesizer/src/serialized_circuit.rs +++ b/synthesizer/src/serialized_circuit.rs @@ -16,18 +16,12 @@ use std::convert::TryFrom; -use serde::Deserialize; -use serde::Serialize; -use snarkvm_curves::bls12_377::Bls12_377; -use snarkvm_curves::traits::PairingEngine; +use serde::{Deserialize, Serialize}; +use snarkvm_curves::{bls12_377::Bls12_377, traits::PairingEngine}; use snarkvm_fields::FieldError; -use snarkvm_r1cs::ConstraintSystem; -use snarkvm_r1cs::Index; -use snarkvm_r1cs::OptionalVec; +use snarkvm_r1cs::{ConstraintSystem, Index, OptionalVec}; -use crate::CircuitSynthesizer; -use crate::SerializedField; -use crate::SerializedIndex; +use crate::{CircuitSynthesizer, SerializedField, SerializedIndex}; #[derive(Serialize, Deserialize)] pub struct SerializedCircuit { diff --git a/synthesizer/src/serialized_field.rs b/synthesizer/src/serialized_field.rs index 504daa8403..acb25e0ce2 100644 --- a/synthesizer/src/serialized_field.rs +++ b/synthesizer/src/serialized_field.rs @@ -14,16 +14,11 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::convert::TryFrom; -use std::str::FromStr; +use std::{convert::TryFrom, str::FromStr}; use num_bigint::BigUint; -use serde::Deserialize; -use serde::Serialize; -use snarkvm_fields::Field; -use snarkvm_fields::FieldError; -use snarkvm_fields::Fp256; -use snarkvm_fields::Fp256Parameters; +use serde::{Deserialize, Serialize}; +use snarkvm_fields::{Field, FieldError, Fp256, Fp256Parameters}; #[derive(Serialize, Deserialize)] pub struct SerializedField(pub String); diff --git a/synthesizer/src/serialized_index.rs b/synthesizer/src/serialized_index.rs index 53fc644a1a..2d7c879881 100644 --- a/synthesizer/src/serialized_index.rs +++ b/synthesizer/src/serialized_index.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use snarkvm_r1cs::Index; #[derive(Serialize, Deserialize)]