Skip to content

Commit

Permalink
Make the formatter sort imports by default. (#6855)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbens-starkware authored Dec 24, 2024
1 parent 4a44fcf commit 9bc36f9
Show file tree
Hide file tree
Showing 129 changed files with 485 additions and 586 deletions.
14 changes: 6 additions & 8 deletions corelib/src/array.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,17 @@
//!
//! [`append`]: ArrayTrait::append

#[feature("deprecated-index-traits")]
use crate::traits::IndexView;

use crate::box::BoxTrait;
use crate::iter::Iterator;
use crate::metaprogramming::TypeEqual;
use crate::serde::Serde;
use crate::RangeCheck;
#[allow(unused_imports)]
use crate::gas::withdraw_gas;
#[allow(unused_imports)]
use crate::option::OptionTrait;
use crate::serde::Serde;
use crate::metaprogramming::TypeEqual;
use crate::iter::Iterator;
use crate::RangeCheck;

#[feature("deprecated-index-traits")]
use crate::traits::IndexView;
/// A collection of elements of the same type continuous in memory.
#[derive(Drop)]
pub extern type Array<T>;
Expand Down
10 changes: 5 additions & 5 deletions corelib/src/byte_array.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@
//! ```

use crate::array::{ArrayTrait, SpanTrait};
use crate::clone::Clone;
use crate::cmp::min;
use crate::option::OptionTrait;
use crate::traits::{Into, TryInto};
#[allow(unused_imports)]
use crate::bytes_31::{
BYTES_IN_BYTES31, Bytes31Trait, POW_2_128, POW_2_8, U128IntoBytes31, U8IntoBytes31,
one_shift_left_bytes_felt252, one_shift_left_bytes_u128, split_u128, u8_at_u256,
};
use crate::clone::Clone;
use crate::cmp::min;
#[allow(unused_imports)]
use crate::integer::{u128_safe_divmod, U32TryIntoNonZero};
use crate::option::OptionTrait;
use crate::integer::{U32TryIntoNonZero, u128_safe_divmod};
#[allow(unused_imports)]
use crate::serde::Serde;
use crate::traits::{Into, TryInto};
#[allow(unused_imports)]
use crate::zeroable::NonZeroIntoImpl;

Expand Down
6 changes: 3 additions & 3 deletions corelib/src/bytes_31.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
//! assert!(value[0] == 0xbb);
//! ```

use crate::traits::{Into, TryInto};
use crate::RangeCheck;
#[allow(unused_imports)]
use crate::integer::{u128_safe_divmod, u128_to_felt252};
#[allow(unused_imports)]
use crate::option::OptionTrait;
use crate::RangeCheck;
use crate::traits::{Into, TryInto};

pub(crate) const BYTES_IN_BYTES31: usize = 31;
const BYTES_IN_U128: usize = 16;
Expand Down Expand Up @@ -232,7 +232,7 @@ impl Bytes31PartialEq of PartialEq<bytes31> {
}

mod helpers {
use core::internal::bounded_int::{DivRemHelper, BoundedInt, div_rem};
use core::internal::bounded_int::{BoundedInt, DivRemHelper, div_rem};

impl DivRemU128By256 of DivRemHelper<u128, BoundedInt<256, 256>> {
type DivT = BoundedInt<0, 0xffffffffffffffffffffffffffffff>;
Expand Down
8 changes: 3 additions & 5 deletions corelib/src/circuit.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,9 @@ extern fn get_circuit_output<C, Output>(

/// Helper module to convert into `u384`.
mod conversions {
use crate::internal::{
bounded_int, bounded_int::{BoundedInt, AddHelper, MulHelper, DivRemHelper},
};
use crate::integer::{upcast, downcast};

use crate::integer::{downcast, upcast};
use crate::internal::bounded_int::{AddHelper, BoundedInt, DivRemHelper, MulHelper};
use crate::internal::bounded_int;
use super::{u384, u96};

type ConstValue<const VALUE: felt252> = BoundedInt<VALUE, VALUE>;
Expand Down
2 changes: 1 addition & 1 deletion corelib/src/debug.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#[allow(unused_imports)]
use crate::array::ArrayTrait;
use crate::traits::Into;
#[allow(unused_imports)]
use crate::option::Option;
use crate::traits::Into;

pub(crate) extern fn print(message: Array<felt252>) nopanic;

Expand Down
5 changes: 2 additions & 3 deletions corelib/src/dict.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//! ```

#[feature("deprecated-index-traits")]
use crate::traits::{Index, Default, Felt252DictValue};
use crate::traits::{Default, Felt252DictValue, Index};

/// A dictionary that maps `felt252` keys to a value of any type.
pub extern type Felt252Dict<T>;
Expand All @@ -62,9 +62,8 @@ pub extern type SquashedFelt252Dict<T>;
pub extern type Felt252DictEntry<T>;

impl SquashedFelt252DictDrop<T, +Drop<T>> of Drop<SquashedFelt252Dict<T>>;

use crate::{RangeCheck, SegmentArena};
use crate::gas::GasBuiltin;
use crate::{RangeCheck, SegmentArena};

pub(crate) extern fn felt252_dict_new<T>() -> Felt252Dict<T> implicits(SegmentArena) nopanic;

Expand Down
4 changes: 2 additions & 2 deletions corelib/src/ec.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
//! let _result = state.finalize();
//! ```

use crate::zeroable::IsZeroResult;
use crate::RangeCheck;
#[allow(unused_imports)]
use crate::array::ArrayTrait;
#[allow(unused_imports)]
use crate::traits::{Into, TryInto};
use crate::zeroable::IsZeroResult;
use crate::RangeCheck;

pub mod stark_curve {
/// The STARK Curve is defined by the equation y² ≡ x³ + α·x + β (mod p).
Expand Down
4 changes: 2 additions & 2 deletions corelib/src/ecdsa.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
//! * x = 0x1ef15c18599971b7beced415a40f0c7deacfd9b0d1819e03d723d8bc943cfca
//! * y = 0x5668060aa49730b7be4801df46ec62de53ecd11abe43a32873000c36e8dc1f

use crate::{ec, ec::{EcPoint, EcPointTrait, EcStateTrait}};
use crate::ec::{EcPoint, EcPointTrait, EcStateTrait};
use crate::{ec, math};
#[allow(unused_imports)]
use crate::option::OptionTrait;
use crate::math;
#[allow(unused_imports)]
use crate::traits::{Into, TryInto};
#[allow(unused_imports)]
Expand Down
12 changes: 5 additions & 7 deletions corelib/src/integer.cairo
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use crate::option::OptionTrait;
use crate::result::ResultTrait;
use crate::traits::{BitAnd, BitNot, BitOr, BitXor, Into, TryInto, Default, Felt252DictValue};
#[allow(unused_imports)]
use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable};
use crate::traits::{BitAnd, BitNot, BitOr, BitXor, Default, Felt252DictValue, Into, TryInto};
use crate::RangeCheck;
#[allow(unused_imports)]
use crate::array::ArrayTrait;
use crate::array::{ArrayTrait, SpanTrait};
#[allow(unused_imports)]
use crate::array::SpanTrait;
use crate::RangeCheck;
use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable};

// TODO(spapini): Add method for const creation from Integer.
pub trait NumericLiteral<T>;
Expand Down Expand Up @@ -2159,7 +2157,7 @@ mod signed_div_rem {
use crate::internal::bounded_int::{
BoundedInt, ConstrainHelper, DivRemHelper, NegateHelper, constrain, div_rem, is_zero,
};
use super::{upcast, downcast};
use super::{downcast, upcast};

impl DivRemImpl<
T,
Expand Down
6 changes: 3 additions & 3 deletions corelib/src/internal/bounded_int.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl MulMinusOneNegateHelper<T, impl H: MulHelper<T, MinusOne>> of NegateHelper<
}

pub use {
bounded_int_add as add, bounded_int_sub as sub, bounded_int_mul as mul,
bounded_int_div_rem as div_rem, bounded_int_constrain as constrain,
bounded_int_is_zero as is_zero, bounded_int_trim as trim,
bounded_int_add as add, bounded_int_constrain as constrain, bounded_int_div_rem as div_rem,
bounded_int_is_zero as is_zero, bounded_int_mul as mul, bounded_int_sub as sub,
bounded_int_trim as trim,
};
2 changes: 1 addition & 1 deletion corelib/src/iter.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod traits;
pub use traits::iterator::IntoIterator;

pub use traits::iterator::Iterator;
pub use traits::iterator::IntoIterator;
4 changes: 2 additions & 2 deletions corelib/src/keccak.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
//! 0x85c9aab73219c1e95c5b5966a4ecc8db4418c3500072a830cfb5a2d13d2c2249);
//! ```

use crate::array::{Span, ArrayTrait, SpanTrait};
use crate::traits::TryInto;
use crate::array::{ArrayTrait, Span, SpanTrait};
use crate::option::OptionTrait;
use crate::starknet::SyscallResultTrait;
use crate::traits::TryInto;

const KECCAK_FULL_RATE_IN_BYTES: usize = 136;
const KECCAK_FULL_RATE_IN_U64S: usize = 17;
Expand Down
70 changes: 35 additions & 35 deletions corelib/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub mod traits;
use serde::Serde;
#[feature("deprecated-index-traits")]
#[feature("deprecated-op-assign-traits")]
#[allow(unused_imports)]
use traits::{
Add, AddEq, BitAnd, BitNot, BitOr, BitXor, Copy, Div, DivEq, DivRem, Drop, Mul, MulEq,
PartialEq, PartialOrd, Rem, RemEq, Sub, SubEq, TupleSize0Copy, TupleSize0Drop, Not, Neg, Into,
TryInto, Index, IndexView, Destruct, Default, Felt252DictValue, PanicDestruct,
Add, AddEq, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivEq, DivRem, Drop,
Felt252DictValue, Index, IndexView, Into, Mul, MulEq, Neg, Not, PanicDestruct, PartialEq,
PartialOrd, Rem, RemEq, Sub, SubEq, TryInto, TupleSize0Copy, TupleSize0Drop,
};
use serde::Serde;

pub type usize = u32;

Expand Down Expand Up @@ -250,7 +250,7 @@ use array::{Span, SpanTrait};
pub mod dict;
#[allow(unused_imports)]
use dict::{
Felt252Dict, SquashedFelt252Dict, felt252_dict_new, felt252_dict_squash, Felt252DictTrait,
Felt252Dict, Felt252DictTrait, SquashedFelt252Dict, felt252_dict_new, felt252_dict_squash,
};

/// Result.
Expand Down Expand Up @@ -280,17 +280,23 @@ pub mod ecdsa;
pub mod integer;
#[allow(unused_imports)]
use integer::{
i8, I8IntoFelt252, i16, I16IntoFelt252, i32, I32IntoFelt252, i64, I64IntoFelt252, i128,
I128IntoFelt252, NumericLiteral, u128, u128_is_zero, u8, u16, u32, u64, u256, Felt252TryIntoU8,
U8IntoFelt252, Felt252TryIntoU16, U16IntoFelt252, Felt252TryIntoU32, U32IntoFelt252,
Felt252TryIntoU64, U64IntoFelt252, Felt252TryIntoU128, U128IntoFelt252, Felt252IntoU256,
Bitwise,
Bitwise, Felt252IntoU256, Felt252TryIntoU128, Felt252TryIntoU16, Felt252TryIntoU32,
Felt252TryIntoU64, Felt252TryIntoU8, I128IntoFelt252, I16IntoFelt252, I32IntoFelt252,
I64IntoFelt252, I8IntoFelt252, NumericLiteral, U128IntoFelt252, U16IntoFelt252, U32IntoFelt252,
U64IntoFelt252, U8IntoFelt252, i128, i16, i32, i64, i8, u128, u128_is_zero, u16, u256, u32, u64,
u8,
};
#[feature("corelib-internal-use")]
#[deprecated(feature: "corelib-internal-use", note: "Use `core::num::traits::Sqrt` instead")]
#[allow(unused_imports)]
use integer::{u128_sqrt, u256_sqrt};

/// Module for comparison operations.
pub mod cmp;

/// Module for handling gas operations.
pub mod gas;

/// Math.
#[feature("corelib-internal-use")]
pub mod math;
Expand All @@ -300,20 +306,14 @@ pub mod num;

/// Module containing the operations that can be performed on the different types.
pub mod ops;

/// Module for comparison operations.
pub mod cmp;

/// Module for handling gas operations.
pub mod gas;
#[allow(unused_imports)]
use gas::{BuiltinCosts, GasBuiltin, get_builtin_costs};


/// Panics.
pub mod panics;
#[allow(unused_imports)]
use panics::{panic, Panic, PanicResult};
use panics::{Panic, PanicResult, panic};

pub enum never {}

Expand All @@ -329,18 +329,18 @@ pub fn assert(cond: bool, err_code: felt252) {
}
}

/// Serialization and Deserialization.
pub mod serde;

/// Hash functions.
pub mod hash;

pub mod keccak;

pub mod sha256;

/// Pedersen
pub mod pedersen;

/// Serialization and Deserialization.
pub mod serde;

pub mod sha256;
#[allow(unused_imports)]
use pedersen::Pedersen;

Expand All @@ -366,14 +366,14 @@ pub mod internal;
/// Zeroable.
pub mod zeroable;
#[allow(unused_imports)]
use zeroable::{Zeroable, NonZero};
use zeroable::{NonZero, Zeroable};

/// bytes31.
pub mod bytes_31;
#[allow(unused_imports)]
use bytes_31::{
bytes31, bytes31_const, Bytes31IndexView, Bytes31IntoFelt252, Bytes31Trait,
Felt252TryIntoBytes31,
Bytes31IndexView, Bytes31IntoFelt252, Bytes31Trait, Felt252TryIntoBytes31, bytes31,
bytes31_const,
};

/// BytesArray.
Expand All @@ -386,14 +386,8 @@ pub mod string;
#[allow(unused_imports)]
use string::StringLiteral;

/// to_byte_array.
pub mod to_byte_array;

#[cfg(test)]
mod test;

/// Module for testing only.
pub mod testing;
/// Iterators.
pub mod iter;

/// Metaprogramming.
pub mod metaprogramming;
Expand All @@ -402,5 +396,11 @@ pub mod metaprogramming;
#[allow(unused_imports)]
mod prelude;

/// Iterators.
pub mod iter;
#[cfg(test)]
mod test;

/// Module for testing only.
pub mod testing;

/// to_byte_array.
pub mod to_byte_array;
8 changes: 4 additions & 4 deletions corelib/src/math.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
//!
//! Provides extended GCD, modular inverse, and modular arithmetic operations.

use crate::integer::{U128MulGuarantee, u256_wide_mul, u512_safe_div_rem_by_u256};
use crate::RangeCheck;
#[allow(unused_imports)]
use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable};
use crate::option::OptionTrait;
#[allow(unused_imports)]
use crate::traits::{Into, TryInto};
#[allow(unused_imports)]
use crate::option::OptionTrait;
use crate::integer::{u256_wide_mul, u512_safe_div_rem_by_u256, U128MulGuarantee};
use crate::RangeCheck;
use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable};

// TODO(yuval): use signed integers once supported.
// TODO(yuval): use a single impl of a trait with associated impls, once associated impls are
Expand Down
3 changes: 1 addition & 2 deletions corelib/src/nullable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
//! ```

use crate::box::BoxTrait;
use crate::traits::Default;
use crate::traits::Felt252DictValue;
use crate::traits::{Default, Felt252DictValue};

/// A type that can either be null or contain a boxed value.
#[derive(Copy, Drop)]
Expand Down
Loading

0 comments on commit 9bc36f9

Please sign in to comment.