diff --git a/noir_stdlib/src/array/check_shuffle.nr b/noir_stdlib/src/array/check_shuffle.nr index 82028d487c7..2e8c227feee 100644 --- a/noir_stdlib/src/array/check_shuffle.nr +++ b/noir_stdlib/src/array/check_shuffle.nr @@ -59,8 +59,8 @@ where } mod test { - use super::check_shuffle; use crate::cmp::Eq; + use super::check_shuffle; struct CompoundStruct { a: bool, diff --git a/noir_stdlib/src/array/mod.nr b/noir_stdlib/src/array/mod.nr index 8bb425854f2..16a27757c63 100644 --- a/noir_stdlib/src/array/mod.nr +++ b/noir_stdlib/src/array/mod.nr @@ -1,6 +1,4 @@ -use crate::cmp::{Eq, Ord}; -use crate::convert::From; -use crate::runtime::is_unconstrained; +use crate::{cmp::{Eq, Ord}, convert::From, runtime::is_unconstrained}; mod check_shuffle; mod quicksort; diff --git a/noir_stdlib/src/bigint.nr b/noir_stdlib/src/bigint.nr index 203ff90d444..63fca63a515 100644 --- a/noir_stdlib/src/bigint.nr +++ b/noir_stdlib/src/bigint.nr @@ -1,5 +1,4 @@ -use crate::ops::{Add, Sub, Mul, Div}; -use crate::cmp::Eq; +use crate::{cmp::Eq, ops::{Add, Div, Mul, Sub}}; global bn254_fq = &[ 0x47, 0xFD, 0x7C, 0xD8, 0x16, 0x8C, 0x20, 0x3C, 0x8d, 0xca, 0x71, 0x68, 0x91, 0x6a, 0x81, 0x97, diff --git a/noir_stdlib/src/cmp.nr b/noir_stdlib/src/cmp.nr index 10be6e7b867..ae515150a4d 100644 --- a/noir_stdlib/src/cmp.nr +++ b/noir_stdlib/src/cmp.nr @@ -537,7 +537,7 @@ where } mod cmp_tests { - use crate::cmp::{min, max}; + use crate::cmp::{max, min}; #[test] fn sanity_check_min() { diff --git a/noir_stdlib/src/collections/map.nr b/noir_stdlib/src/collections/map.nr index cd203c43ad3..a83557c41ca 100644 --- a/noir_stdlib/src/collections/map.nr +++ b/noir_stdlib/src/collections/map.nr @@ -1,8 +1,10 @@ -use crate::cmp::Eq; -use crate::option::Option; -use crate::default::Default; -use crate::hash::{Hash, Hasher, BuildHasher}; -use crate::collections::bounded_vec::BoundedVec; +use crate::{ + cmp::Eq, + collections::bounded_vec::BoundedVec, + default::Default, + hash::{BuildHasher, Hash, Hasher}, + option::Option, +}; // We use load factor alpha_max = 0.75. // Upon exceeding it, assert will fail in order to inform the user diff --git a/noir_stdlib/src/collections/umap.nr b/noir_stdlib/src/collections/umap.nr index 9b72b6173ca..bdcbc7c7094 100644 --- a/noir_stdlib/src/collections/umap.nr +++ b/noir_stdlib/src/collections/umap.nr @@ -1,7 +1,4 @@ -use crate::cmp::Eq; -use crate::option::Option; -use crate::default::Default; -use crate::hash::{Hash, Hasher, BuildHasher}; +use crate::{cmp::Eq, default::Default, hash::{BuildHasher, Hash, Hasher}, option::Option}; // An unconstrained hash table with open addressing and quadratic probing. // Note that "unconstrained" here means that almost all operations on this diff --git a/noir_stdlib/src/ec/consts/te.nr b/noir_stdlib/src/ec/consts/te.nr index 561c16e846a..9bc2626acdf 100644 --- a/noir_stdlib/src/ec/consts/te.nr +++ b/noir_stdlib/src/ec/consts/te.nr @@ -1,5 +1,4 @@ -use crate::ec::tecurve::affine::Point as TEPoint; -use crate::ec::tecurve::affine::Curve as TECurve; +use crate::ec::tecurve::affine::{Curve as TECurve, Point as TEPoint}; pub struct BabyJubjub { pub curve: TECurve, diff --git a/noir_stdlib/src/ec/montcurve.nr b/noir_stdlib/src/ec/montcurve.nr index 6c83feb1607..cc854ef7cbe 100644 --- a/noir_stdlib/src/ec/montcurve.nr +++ b/noir_stdlib/src/ec/montcurve.nr @@ -3,16 +3,18 @@ pub mod affine { // Points are represented by two-dimensional Cartesian coordinates. // All group operations are induced by those of the corresponding Twisted Edwards curve. // See e.g. for details on the correspondences. - use crate::ec::montcurve::curvegroup; - use crate::ec::swcurve::affine::Curve as SWCurve; - use crate::ec::swcurve::affine::Point as SWPoint; - use crate::ec::tecurve::affine::Curve as TECurve; - use crate::ec::tecurve::affine::Point as TEPoint; - use crate::ec::is_square; - use crate::ec::safe_inverse; - use crate::ec::sqrt; - use crate::ec::ZETA; - use crate::cmp::Eq; + use crate::{ + cmp::Eq, + ec::{ + is_square, + montcurve::curvegroup, + safe_inverse, + sqrt, + swcurve::affine::{Curve as SWCurve, Point as SWPoint}, + tecurve::affine::{Curve as TECurve, Point as TEPoint}, + ZETA, + }, + }; // Curve specification pub struct Curve { // Montgomery Curve configuration (ky^2 = x^3 + j*x^2 + x) @@ -222,12 +224,14 @@ pub mod curvegroup { // Points are represented by three-dimensional projective (homogeneous) coordinates. // All group operations are induced by those of the corresponding Twisted Edwards curve. // See e.g. for details on the correspondences. - use crate::ec::montcurve::affine; - use crate::ec::swcurve::curvegroup::Curve as SWCurve; - use crate::ec::swcurve::curvegroup::Point as SWPoint; - use crate::ec::tecurve::curvegroup::Curve as TECurve; - use crate::ec::tecurve::curvegroup::Point as TEPoint; - use crate::cmp::Eq; + use crate::{ + cmp::Eq, + ec::{ + montcurve::affine, + swcurve::curvegroup::{Curve as SWCurve, Point as SWPoint}, + tecurve::curvegroup::{Curve as TECurve, Point as TEPoint}, + }, + }; pub struct Curve { // Montgomery Curve configuration (ky^2 z = x*(x^2 + j*x*z + z*z)) pub j: Field, diff --git a/noir_stdlib/src/ec/swcurve.nr b/noir_stdlib/src/ec/swcurve.nr index 145b2506f73..1e43285b8b1 100644 --- a/noir_stdlib/src/ec/swcurve.nr +++ b/noir_stdlib/src/ec/swcurve.nr @@ -3,11 +3,7 @@ pub mod affine { // Points are represented by two-dimensional Cartesian coordinates. // Group operations are implemented in terms of those in CurveGroup (in this case, extended Twisted Edwards) coordinates // for reasons of efficiency, cf. . - use crate::ec::swcurve::curvegroup; - use crate::ec::safe_inverse; - use crate::ec::is_square; - use crate::ec::sqrt; - use crate::cmp::Eq; + use crate::{cmp::Eq, ec::{is_square, safe_inverse, sqrt, swcurve::curvegroup}}; // Curve specification pub struct Curve { // Short Weierstrass curve @@ -190,8 +186,7 @@ pub mod curvegroup { // CurveGroup representation of Weierstrass curves // Points are represented by three-dimensional Jacobian coordinates. // See for details. - use crate::ec::swcurve::affine; - use crate::cmp::Eq; + use crate::{cmp::Eq, ec::swcurve::affine}; // Curve specification pub struct Curve { // Short Weierstrass curve diff --git a/noir_stdlib/src/ec/tecurve.nr b/noir_stdlib/src/ec/tecurve.nr index 0088896015d..5a4a9b4149c 100644 --- a/noir_stdlib/src/ec/tecurve.nr +++ b/noir_stdlib/src/ec/tecurve.nr @@ -4,12 +4,14 @@ pub mod affine { // Group operations are implemented in terms of those in CurveGroup (in this case, extended Twisted Edwards) coordinates // for reasons of efficiency. // See for details. - use crate::ec::tecurve::curvegroup; - use crate::ec::montcurve::affine::Curve as MCurve; - use crate::ec::montcurve::affine::Point as MPoint; - use crate::ec::swcurve::affine::Curve as SWCurve; - use crate::ec::swcurve::affine::Point as SWPoint; - use crate::cmp::Eq; + use crate::{ + cmp::Eq, + ec::{ + montcurve::affine::{Curve as MCurve, Point as MPoint}, + swcurve::affine::{Curve as SWCurve, Point as SWPoint}, + tecurve::curvegroup, + }, + }; // Curve specification pub struct Curve { // Twisted Edwards curve @@ -197,12 +199,14 @@ pub mod curvegroup { // CurveGroup coordinate representation of Twisted Edwards curves // Points are represented by four-dimensional projective coordinates, viz. extended Twisted Edwards coordinates. // See section 3 of for details. - use crate::ec::tecurve::affine; - use crate::ec::montcurve::curvegroup::Curve as MCurve; - use crate::ec::montcurve::curvegroup::Point as MPoint; - use crate::ec::swcurve::curvegroup::Curve as SWCurve; - use crate::ec::swcurve::curvegroup::Point as SWPoint; - use crate::cmp::Eq; + use crate::{ + cmp::Eq, + ec::{ + montcurve::curvegroup::{Curve as MCurve, Point as MPoint}, + swcurve::curvegroup::{Curve as SWCurve, Point as SWPoint}, + tecurve::affine, + }, + }; // Curve specification pub struct Curve { // Twisted Edwards curve diff --git a/noir_stdlib/src/eddsa.nr b/noir_stdlib/src/eddsa.nr index 89a0b05b072..c9df59def8e 100644 --- a/noir_stdlib/src/eddsa.nr +++ b/noir_stdlib/src/eddsa.nr @@ -1,8 +1,8 @@ -use crate::ec::consts::te::baby_jubjub; -use crate::ec::tecurve::affine::Point as TEPoint; -use crate::hash::Hasher; -use crate::hash::poseidon::PoseidonHasher; -use crate::default::Default; +use crate::{ + default::Default, + ec::{consts::te::baby_jubjub, tecurve::affine::Point as TEPoint}, + hash::{Hasher, poseidon::PoseidonHasher}, +}; // Returns true if signature is valid pub fn eddsa_poseidon_verify( diff --git a/noir_stdlib/src/embedded_curve_ops.nr b/noir_stdlib/src/embedded_curve_ops.nr index dd5e4285c00..edabcf7ad36 100644 --- a/noir_stdlib/src/embedded_curve_ops.nr +++ b/noir_stdlib/src/embedded_curve_ops.nr @@ -1,5 +1,4 @@ -use crate::ops::arith::{Add, Sub, Neg}; -use crate::cmp::Eq; +use crate::{cmp::Eq, ops::arith::{Add, Neg, Sub}}; /// A point on the embedded elliptic curve /// By definition, the base field of the embedded curve is the scalar field of the proof system curve, i.e the Noir Field. diff --git a/noir_stdlib/src/field/bn254.nr b/noir_stdlib/src/field/bn254.nr index 356b47e63cf..9642c2aa1b8 100644 --- a/noir_stdlib/src/field/bn254.nr +++ b/noir_stdlib/src/field/bn254.nr @@ -141,7 +141,7 @@ pub fn lt(a: Field, b: Field) -> bool { mod tests { // TODO: Allow imports from "super" use crate::field::bn254::{ - decompose, compute_lt, assert_gt, gt, TWO_POW_128, compute_lte, PLO, PHI, + assert_gt, compute_lt, compute_lte, decompose, gt, PHI, PLO, TWO_POW_128, }; #[test] diff --git a/noir_stdlib/src/field/mod.nr b/noir_stdlib/src/field/mod.nr index 915ea8f939e..b632cf1f7a2 100644 --- a/noir_stdlib/src/field/mod.nr +++ b/noir_stdlib/src/field/mod.nr @@ -1,6 +1,6 @@ pub mod bn254; -use bn254::lt as bn254_lt; use crate::runtime::is_unconstrained; +use bn254::lt as bn254_lt; impl Field { /// Asserts that `self` can be represented in `bit_size` bits. diff --git a/noir_stdlib/src/hash/keccak.nr b/noir_stdlib/src/hash/keccak.nr index 50fbab8a416..a539086331e 100644 --- a/noir_stdlib/src/hash/keccak.nr +++ b/noir_stdlib/src/hash/keccak.nr @@ -1,5 +1,4 @@ -use crate::collections::vec::Vec; -use crate::runtime::is_unconstrained; +use crate::{collections::vec::Vec, runtime::is_unconstrained}; global BLOCK_SIZE_IN_BYTES: u32 = 136; //(1600 - BITS * 2) / WORD_SIZE; global WORD_SIZE: u32 = 8; // Limbs are made up of u64s so 8 bytes each. diff --git a/noir_stdlib/src/hash/mimc.nr b/noir_stdlib/src/hash/mimc.nr index 6045ae3dbdb..73e62d95a03 100644 --- a/noir_stdlib/src/hash/mimc.nr +++ b/noir_stdlib/src/hash/mimc.nr @@ -1,5 +1,4 @@ -use crate::hash::Hasher; -use crate::default::Default; +use crate::{default::Default, hash::Hasher}; // mimc-p/p implementation // constants are (publicly generated) random numbers, for instance using keccak as a ROM. diff --git a/noir_stdlib/src/hash/mod.nr b/noir_stdlib/src/hash/mod.nr index 609017d70aa..550ee0412f8 100644 --- a/noir_stdlib/src/hash/mod.nr +++ b/noir_stdlib/src/hash/mod.nr @@ -5,12 +5,14 @@ pub mod keccak; pub mod sha256; pub mod sha512; -use crate::default::Default; -use crate::uint128::U128; -use crate::embedded_curve_ops::{ - EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul, multi_scalar_mul_array_return, +use crate::{ + default::Default, + embedded_curve_ops::{ + EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul, multi_scalar_mul_array_return, + }, + meta::derive_via, + uint128::U128, }; -use crate::meta::derive_via; // Kept for backwards compatibility pub use sha256::{digest, sha256, sha256_compression, sha256_var}; diff --git a/noir_stdlib/src/hash/poseidon/bn254/consts.nr b/noir_stdlib/src/hash/poseidon/bn254/consts.nr index 835ed3ea476..4c27dfc6ad5 100644 --- a/noir_stdlib/src/hash/poseidon/bn254/consts.nr +++ b/noir_stdlib/src/hash/poseidon/bn254/consts.nr @@ -2,8 +2,7 @@ // Used like so: sage generate_parameters_grain.sage 1 0 254 2 8 56 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 // Constants for various Poseidon instances in the case of the prime field of the same order as BN254. // Consistent with https://github.com/iden3/circomlib/blob/master/circuits/poseidon.circom and https://github.com/iden3/circomlib/blob/master/circuits/poseidon_constants.circom -use crate::hash::poseidon::PoseidonConfig; -use crate::hash::poseidon::config; +use crate::hash::poseidon::{config, PoseidonConfig}; // S-box power fn alpha() -> Field { 5 diff --git a/noir_stdlib/src/hash/poseidon/bn254/perm.nr b/noir_stdlib/src/hash/poseidon/bn254/perm.nr index 3a12f59fe77..61e629e4db1 100644 --- a/noir_stdlib/src/hash/poseidon/bn254/perm.nr +++ b/noir_stdlib/src/hash/poseidon/bn254/perm.nr @@ -1,6 +1,5 @@ // Instantiations of Poseidon permutation for the prime field of the same order as BN254 -use crate::hash::poseidon::bn254::consts; -use crate::hash::poseidon::permute; +use crate::hash::poseidon::{bn254::consts, permute}; #[field(bn254)] pub fn x5_2(mut state: [Field; 2]) -> [Field; 2] { diff --git a/noir_stdlib/src/hash/poseidon/mod.nr b/noir_stdlib/src/hash/poseidon/mod.nr index 0af7951b8dc..8c75b9a3662 100644 --- a/noir_stdlib/src/hash/poseidon/mod.nr +++ b/noir_stdlib/src/hash/poseidon/mod.nr @@ -1,6 +1,5 @@ pub mod bn254; // Instantiations of Poseidon for prime field of the same order as BN254 -use crate::hash::Hasher; -use crate::default::Default; +use crate::{default::Default, hash::Hasher}; // A config struct defining the parameters of the Poseidon instance to use. // diff --git a/noir_stdlib/src/hash/poseidon2.nr b/noir_stdlib/src/hash/poseidon2.nr index 517c2cd8f5f..2fd2f09e65c 100644 --- a/noir_stdlib/src/hash/poseidon2.nr +++ b/noir_stdlib/src/hash/poseidon2.nr @@ -1,5 +1,4 @@ -use crate::hash::Hasher; -use crate::default::Default; +use crate::{default::Default, hash::Hasher}; comptime global RATE: u32 = 3; diff --git a/noir_stdlib/src/meta/expr.nr b/noir_stdlib/src/meta/expr.nr index 1b04a97ab15..46c65638527 100644 --- a/noir_stdlib/src/meta/expr.nr +++ b/noir_stdlib/src/meta/expr.nr @@ -1,8 +1,6 @@ //! Contains methods on the built-in `Expr` type for quoted, syntactically valid expressions. -use crate::option::Option; -use crate::meta::op::UnaryOp; -use crate::meta::op::BinaryOp; +use crate::{meta::op::{BinaryOp, UnaryOp}, option::Option}; impl Expr { /// If this expression is an array literal `[elem1, ..., elemN]`, this returns a slice of each element in the array. diff --git a/noir_stdlib/src/meta/mod.nr b/noir_stdlib/src/meta/mod.nr index ff662b878ec..eb7a59634bc 100644 --- a/noir_stdlib/src/meta/mod.nr +++ b/noir_stdlib/src/meta/mod.nr @@ -30,9 +30,7 @@ pub comptime fn type_of(x: T) -> Type {} // docs:start:derive_example // These are needed for the unconstrained hashmap we're using to store derive functions -use crate::collections::umap::UHashMap; -use crate::hash::BuildHasherDefault; -use crate::hash::poseidon2::Poseidon2Hasher; +use crate::{collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}}; // A derive function is one that given a struct definition can // create us a quoted trait impl from it. diff --git a/noir_stdlib/src/meta/quoted.nr b/noir_stdlib/src/meta/quoted.nr index d67174d7829..c4f2b095766 100644 --- a/noir_stdlib/src/meta/quoted.nr +++ b/noir_stdlib/src/meta/quoted.nr @@ -1,5 +1,4 @@ -use crate::cmp::Eq; -use crate::option::Option; +use crate::{cmp::Eq, option::Option}; impl Quoted { #[builtin(quoted_as_expr)] diff --git a/noir_stdlib/src/meta/trait_constraint.nr b/noir_stdlib/src/meta/trait_constraint.nr index bf22f454448..91dd1168116 100644 --- a/noir_stdlib/src/meta/trait_constraint.nr +++ b/noir_stdlib/src/meta/trait_constraint.nr @@ -1,5 +1,4 @@ -use crate::hash::{Hash, Hasher}; -use crate::cmp::Eq; +use crate::{cmp::Eq, hash::{Hash, Hasher}}; impl Eq for TraitConstraint { comptime fn eq(self, other: Self) -> bool { diff --git a/noir_stdlib/src/meta/trait_def.nr b/noir_stdlib/src/meta/trait_def.nr index cc448b2eae5..d889fdd1591 100644 --- a/noir_stdlib/src/meta/trait_def.nr +++ b/noir_stdlib/src/meta/trait_def.nr @@ -1,5 +1,4 @@ -use crate::hash::{Hash, Hasher}; -use crate::cmp::Eq; +use crate::{cmp::Eq, hash::{Hash, Hasher}}; impl TraitDefinition { #[builtin(trait_def_as_trait_constraint)] diff --git a/noir_stdlib/src/meta/typ.nr b/noir_stdlib/src/meta/typ.nr index 8076c692ca5..f722c3d0a5c 100644 --- a/noir_stdlib/src/meta/typ.nr +++ b/noir_stdlib/src/meta/typ.nr @@ -1,7 +1,6 @@ //! Contains methods on the built-in `Type` type used for representing a type in the source program. -use crate::cmp::Eq; -use crate::option::Option; +use crate::{cmp::Eq, option::Option}; /// Creates and returns an unbound type variable. This is a special kind of type internal /// to type checking which will type check with any other type. When it is type checked diff --git a/noir_stdlib/src/ops/mod.nr b/noir_stdlib/src/ops/mod.nr index bf908ea4b27..0e3a2467c60 100644 --- a/noir_stdlib/src/ops/mod.nr +++ b/noir_stdlib/src/ops/mod.nr @@ -1,5 +1,5 @@ pub(crate) mod arith; pub(crate) mod bit; -pub use arith::{Add, Sub, Mul, Div, Rem, Neg}; -pub use bit::{Not, BitOr, BitAnd, BitXor, Shl, Shr}; +pub use arith::{Add, Div, Mul, Neg, Rem, Sub}; +pub use bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; diff --git a/noir_stdlib/src/option.nr b/noir_stdlib/src/option.nr index 5db2ce84efd..b045a3d7612 100644 --- a/noir_stdlib/src/option.nr +++ b/noir_stdlib/src/option.nr @@ -1,6 +1,4 @@ -use crate::hash::{Hash, Hasher}; -use crate::cmp::{Ordering, Ord, Eq}; -use crate::default::Default; +use crate::{cmp::{Eq, Ord, Ordering}, default::Default, hash::{Hash, Hasher}}; pub struct Option { _is_some: bool, diff --git a/noir_stdlib/src/prelude.nr b/noir_stdlib/src/prelude.nr index b6e54eaae60..f56fd888f76 100644 --- a/noir_stdlib/src/prelude.nr +++ b/noir_stdlib/src/prelude.nr @@ -1,10 +1,13 @@ -pub use crate::collections::vec::Vec; -pub use crate::collections::bounded_vec::BoundedVec; -pub use crate::option::Option; -pub use crate::{print, println, assert_constant}; -pub use crate::uint128::U128; -pub use crate::cmp::{Eq, Ord}; -pub use crate::default::Default; -pub use crate::convert::{From, Into}; -pub use crate::meta::{derive, derive_via}; -pub use crate::panic::panic; +pub use crate::{ + assert_constant, + cmp::{Eq, Ord}, + collections::{bounded_vec::BoundedVec, vec::Vec}, + convert::{From, Into}, + default::Default, + meta::{derive, derive_via}, + option::Option, + panic::panic, + print, + println, + uint128::U128, +}; diff --git a/noir_stdlib/src/string.nr b/noir_stdlib/src/string.nr index 18fb449626a..017b4ff649b 100644 --- a/noir_stdlib/src/string.nr +++ b/noir_stdlib/src/string.nr @@ -1,5 +1,4 @@ -use crate::collections::vec::Vec; -use crate::convert::From; +use crate::{collections::vec::Vec, convert::From}; impl str { /// Converts the given string into a byte array diff --git a/noir_stdlib/src/uint128.nr b/noir_stdlib/src/uint128.nr index a4e20859604..95ae3362385 100644 --- a/noir_stdlib/src/uint128.nr +++ b/noir_stdlib/src/uint128.nr @@ -1,5 +1,7 @@ -use crate::ops::{Add, Sub, Mul, Div, Rem, Not, BitOr, BitAnd, BitXor, Shl, Shr}; -use crate::cmp::{Eq, Ord, Ordering}; +use crate::{ + cmp::{Eq, Ord, Ordering}, + ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Not, Rem, Shl, Shr, Sub}, +}; global pow64: Field = 18446744073709551616; //2^64; global pow63: Field = 9223372036854775808; // 2^63; @@ -313,7 +315,7 @@ impl Shr for U128 { } mod tests { - use crate::uint128::{U128, pow64, pow63}; + use crate::uint128::{pow63, pow64, U128}; #[test] fn test_not(lo: u64, hi: u64) { diff --git a/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr b/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr index 935b1c613ad..3f46eb10034 100644 --- a/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr +++ b/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr @@ -1,14 +1,9 @@ // Tests may be checked against https://github.com/cfrg/draft-irtf-cfrg-hash-to-curve/tree/main/poc -use std::ec::tecurve::affine::Curve as AffineCurve; -use std::ec::tecurve::affine::Point as Gaffine; -use std::ec::tecurve::curvegroup::Point as G; +use std::ec::tecurve::{affine::{Curve as AffineCurve, Point as Gaffine}, curvegroup::Point as G}; -use std::ec::swcurve::affine::Point as SWGaffine; -use std::ec::swcurve::curvegroup::Point as SWG; +use std::ec::swcurve::{affine::Point as SWGaffine, curvegroup::Point as SWG}; -use std::ec::montcurve::affine::Point as MGaffine; -use std::ec::montcurve::curvegroup::Point as MG; -use std::compat; +use std::{compat, ec::montcurve::{affine::Point as MGaffine, curvegroup::Point as MG}}; fn main() { // This test only makes sense if Field is the right prime field. diff --git a/test_programs/compile_success_empty/macros_in_comptime/src/main.nr b/test_programs/compile_success_empty/macros_in_comptime/src/main.nr index 799091fca09..1764f28ae6f 100644 --- a/test_programs/compile_success_empty/macros_in_comptime/src/main.nr +++ b/test_programs/compile_success_empty/macros_in_comptime/src/main.nr @@ -1,5 +1,4 @@ -use std::field::modulus_num_bits; -use std::meta::unquote; +use std::{field::modulus_num_bits, meta::unquote}; // Numeric generics default to u32 global three_field: Field = 3; @@ -38,8 +37,7 @@ comptime fn foo(x: Field) { } mod submodule { - use std::field::modulus_be_bytes; - use std::meta::unquote; + use std::{field::modulus_be_bytes, meta::unquote}; pub comptime fn bar() { // Use a function only in scope in this module diff --git a/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr b/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr index 620fd99f6ec..7fa8b1426ab 100644 --- a/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr +++ b/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr @@ -1,6 +1,4 @@ -use crate::foo::in_foo_mod; -use crate::foo::bar::in_bar_mod; -use crate::baz::in_baz_mod; +use crate::{baz::in_baz_mod, foo::{bar::in_bar_mod, in_foo_mod}}; mod foo; mod baz; diff --git a/test_programs/compile_success_empty/reexports/src/main.nr b/test_programs/compile_success_empty/reexports/src/main.nr index 0fd65a33564..6b568bea682 100644 --- a/test_programs/compile_success_empty/reexports/src/main.nr +++ b/test_programs/compile_success_empty/reexports/src/main.nr @@ -1,4 +1,4 @@ -use reexporting_lib::{FooStruct, MyStruct, lib}; +use reexporting_lib::{FooStruct, lib, MyStruct}; fn main() { let x: FooStruct = MyStruct { inner: 0 }; diff --git a/test_programs/compile_success_empty/regression_2099/src/main.nr b/test_programs/compile_success_empty/regression_2099/src/main.nr index 3fe3cdaf39a..2ca8b4ccc9e 100644 --- a/test_programs/compile_success_empty/regression_2099/src/main.nr +++ b/test_programs/compile_success_empty/regression_2099/src/main.nr @@ -1,5 +1,4 @@ -use std::ec::tecurve::affine::Curve as AffineCurve; -use std::ec::tecurve::affine::Point as Gaffine; +use std::ec::tecurve::affine::{Curve as AffineCurve, Point as Gaffine}; fn main() { // Define Baby Jubjub (ERC-2494) parameters in affine representation diff --git a/test_programs/compile_success_empty/trait_call_full_path/src/main.nr b/test_programs/compile_success_empty/trait_call_full_path/src/main.nr index aea0f436dce..29cf1b2e167 100644 --- a/test_programs/compile_success_empty/trait_call_full_path/src/main.nr +++ b/test_programs/compile_success_empty/trait_call_full_path/src/main.nr @@ -10,8 +10,7 @@ mod foo { } } -use foo::Trait; -use foo::Trait::me; +use foo::Trait::{me, self}; fn main(x: Field) { let _ = foo::Trait::me(x); diff --git a/test_programs/compile_success_empty/trait_method_mut_self/src/main.nr b/test_programs/compile_success_empty/trait_method_mut_self/src/main.nr index aa0baab7f89..cd67ec48f8d 100644 --- a/test_programs/compile_success_empty/trait_method_mut_self/src/main.nr +++ b/test_programs/compile_success_empty/trait_method_mut_self/src/main.nr @@ -1,5 +1,4 @@ -use std::hash::Hasher; -use std::hash::poseidon2::Poseidon2Hasher; +use std::hash::{Hasher, poseidon2::Poseidon2Hasher}; fn main(x: Field, y: pub Field) { let mut a_mut_ref = AType { x }; diff --git a/test_programs/compile_success_empty/trait_multi_module_test/src/module3.nr b/test_programs/compile_success_empty/trait_multi_module_test/src/module3.nr index 2485a2ba7a1..d9df949a465 100644 --- a/test_programs/compile_success_empty/trait_multi_module_test/src/module3.nr +++ b/test_programs/compile_success_empty/trait_multi_module_test/src/module3.nr @@ -1,4 +1,3 @@ -use crate::module1::MyTrait; -use crate::module2::MyStruct; +use crate::{module1::MyTrait, module2::MyStruct}; // ensure we can implement traits that are imported with the `use` syntax impl MyTrait for MyStruct {} diff --git a/test_programs/compile_success_empty/trait_where_clause/src/main.nr b/test_programs/compile_success_empty/trait_where_clause/src/main.nr index 8dc00be622d..88f2cafffde 100644 --- a/test_programs/compile_success_empty/trait_where_clause/src/main.nr +++ b/test_programs/compile_success_empty/trait_where_clause/src/main.nr @@ -4,8 +4,7 @@ // - structs (struct Foo where T: ...) // import the traits from another module to ensure the where clauses are ok with that mod the_trait; -use crate::the_trait::Asd; -use crate::the_trait::StaticTrait; +use crate::the_trait::{Asd, StaticTrait}; struct Add10 { x: Field, diff --git a/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr b/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr index 535d7b18137..a755e492a81 100644 --- a/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr +++ b/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr @@ -1,6 +1,4 @@ -use std::hash::Hasher; -use std::hash::poseidon2::Poseidon2Hasher; -use std::hash::poseidon::PoseidonHasher; +use std::hash::{Hasher, poseidon2::Poseidon2Hasher, poseidon::PoseidonHasher}; fn main(x: Field, y: pub Field) { let mut hasher = PoseidonHasher::default(); diff --git a/test_programs/execution_success/bigint/src/main.nr b/test_programs/execution_success/bigint/src/main.nr index 5a8b9fb67ef..5514b44e7e9 100644 --- a/test_programs/execution_success/bigint/src/main.nr +++ b/test_programs/execution_success/bigint/src/main.nr @@ -1,5 +1,4 @@ -use std::bigint; -use std::{bigint::Secpk1Fq, println}; +use std::{bigint::{Secpk1Fq, self}, println}; fn main(mut x: [u8; 5], y: [u8; 5]) { let a = bigint::Secpk1Fq::from_le_bytes(&[x[0], x[1], x[2], x[3], x[4]]); diff --git a/test_programs/execution_success/binary_operator_overloading/src/main.nr b/test_programs/execution_success/binary_operator_overloading/src/main.nr index a5e12fd5da9..e6739e6f4d6 100644 --- a/test_programs/execution_success/binary_operator_overloading/src/main.nr +++ b/test_programs/execution_success/binary_operator_overloading/src/main.nr @@ -1,5 +1,4 @@ -use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, Shl, Shr}; -use std::cmp::Ordering; +use std::{cmp::Ordering, ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Rem, Shl, Shr, Sub}}; // x = 3, y = 9 fn main(x: u32, y: u32) { diff --git a/test_programs/execution_success/brillig_oracle/src/main.nr b/test_programs/execution_success/brillig_oracle/src/main.nr index 8f5b2fa7566..0f10749c485 100644 --- a/test_programs/execution_success/brillig_oracle/src/main.nr +++ b/test_programs/execution_success/brillig_oracle/src/main.nr @@ -1,5 +1,4 @@ -use std::slice; -use std::test::OracleMock; +use std::{slice, test::OracleMock}; // Tests oracle usage in brillig/unconstrained functions fn main(_x: Field) { diff --git a/test_programs/execution_success/diamond_deps_0/src/main.nr b/test_programs/execution_success/diamond_deps_0/src/main.nr index 690d6fc9fc8..1fff8a5f583 100644 --- a/test_programs/execution_success/diamond_deps_0/src/main.nr +++ b/test_programs/execution_success/diamond_deps_0/src/main.nr @@ -1,6 +1,5 @@ use dep1::call_dep1_then_dep2; -use dep2::call_dep2; -use dep2::RESOLVE_THIS; +use dep2::{call_dep2, RESOLVE_THIS}; fn main(x: Field, y: pub Field) -> pub Field { call_dep1_then_dep2(x, y) + call_dep2(x, y) + RESOLVE_THIS diff --git a/test_programs/execution_success/eddsa/src/main.nr b/test_programs/execution_success/eddsa/src/main.nr index d0ce8e70053..028dd8bd950 100644 --- a/test_programs/execution_success/eddsa/src/main.nr +++ b/test_programs/execution_success/eddsa/src/main.nr @@ -1,9 +1,9 @@ -use std::compat; -use std::ec::consts::te::baby_jubjub; -use std::ec::tecurve::affine::Point as TEPoint; -use std::hash; -use std::eddsa::{eddsa_to_pub, eddsa_poseidon_verify, eddsa_verify}; -use std::hash::poseidon2::Poseidon2Hasher; +use std::{ + compat, + ec::{consts::te::baby_jubjub, tecurve::affine::Point as TEPoint}, + eddsa::{eddsa_poseidon_verify, eddsa_to_pub, eddsa_verify}, + hash::{poseidon2::Poseidon2Hasher, self}, +}; fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { // Skip this test for non-bn254 backends diff --git a/test_programs/execution_success/hashmap/src/main.nr b/test_programs/execution_success/hashmap/src/main.nr index 964b900dce5..6e71d3fb010 100644 --- a/test_programs/execution_success/hashmap/src/main.nr +++ b/test_programs/execution_success/hashmap/src/main.nr @@ -1,8 +1,6 @@ mod utils; -use std::collections::map::HashMap; -use std::hash::BuildHasherDefault; -use std::hash::poseidon2::Poseidon2Hasher; +use std::{collections::map::HashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}}; use utils::cut; diff --git a/test_programs/execution_success/prelude/src/main.nr b/test_programs/execution_success/prelude/src/main.nr index 4fe6080222e..cc0180ff1fe 100644 --- a/test_programs/execution_success/prelude/src/main.nr +++ b/test_programs/execution_success/prelude/src/main.nr @@ -8,8 +8,7 @@ fn main() { mod a { // We don't want to give an error due to re-importing elements that are already in the prelude. - use std::collections::vec::Vec; - use std::option::Option; + use std::{collections::vec::Vec, option::Option}; fn main() { let _xs = Vec::new(); diff --git a/test_programs/execution_success/regression_3889/src/main.nr b/test_programs/execution_success/regression_3889/src/main.nr index 2b54ae54418..ed7aefa5c80 100644 --- a/test_programs/execution_success/regression_3889/src/main.nr +++ b/test_programs/execution_success/regression_3889/src/main.nr @@ -5,16 +5,14 @@ mod Foo { } mod Bar { - use crate::Foo::NewType as BarStruct; - use crate::Foo::NewType; + use crate::Foo::{NewType, NewType as BarStruct}; } mod Baz { struct Works { a: Field, } - use crate::Bar::BarStruct; - use crate::Bar::NewType; + use crate::Bar::{BarStruct, NewType}; } fn main(works: Baz::Works, fails: Baz::BarStruct, also_fails: Bar::NewType) -> pub Field { diff --git a/test_programs/execution_success/regression_5045/src/main.nr b/test_programs/execution_success/regression_5045/src/main.nr index 545694368fd..aa9a45f7c11 100644 --- a/test_programs/execution_success/regression_5045/src/main.nr +++ b/test_programs/execution_success/regression_5045/src/main.nr @@ -1,5 +1,4 @@ -use std::embedded_curve_ops::EmbeddedCurvePoint; -use std::embedded_curve_ops::EmbeddedCurveScalar; +use std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar}; fn main(is_active: bool) { let a = EmbeddedCurvePoint { diff --git a/test_programs/execution_success/regression_5615/src/main.nr b/test_programs/execution_success/regression_5615/src/main.nr index 1d8e0a045cd..186d8362009 100644 --- a/test_programs/execution_success/regression_5615/src/main.nr +++ b/test_programs/execution_success/regression_5615/src/main.nr @@ -1,6 +1,4 @@ -use std::collections::umap::UHashMap; -use std::hash::BuildHasherDefault; -use std::hash::poseidon2::Poseidon2Hasher; +use std::{collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}}; unconstrained fn main() { comptime { diff --git a/test_programs/execution_success/uhashmap/src/main.nr b/test_programs/execution_success/uhashmap/src/main.nr index e917a83c5fd..7fc2efa95e5 100644 --- a/test_programs/execution_success/uhashmap/src/main.nr +++ b/test_programs/execution_success/uhashmap/src/main.nr @@ -1,6 +1,4 @@ -use std::collections::umap::UHashMap; -use std::hash::BuildHasherDefault; -use std::hash::poseidon2::Poseidon2Hasher; +use std::{collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}}; type K = Field; type V = Field;