From 7ee7ac2c5caf7edc884244871fc2cc77ddff623d Mon Sep 17 00:00:00 2001 From: Ori Ziv Date: Mon, 26 Aug 2024 15:57:34 +0300 Subject: [PATCH] Added support for `crate` keyword. Closes #3178 commit-id:0d402d27 --- corelib/src/array.cairo | 24 +- corelib/src/box.cairo | 6 +- corelib/src/byte_array.cairo | 24 +- corelib/src/bytes_31.cairo | 26 +- corelib/src/circuit.cairo | 26 +- corelib/src/clone.cairo | 10 +- corelib/src/debug.cairo | 10 +- corelib/src/dict.cairo | 6 +- corelib/src/ec.cairo | 12 +- corelib/src/ecdsa.cairo | 10 +- corelib/src/felt_252.cairo | 4 +- corelib/src/fmt.cairo | 38 +- corelib/src/gas.cairo | 2 +- corelib/src/hash.cairo | 8 +- corelib/src/integer.cairo | 430 +++++++++--------- corelib/src/internal/bounded_int.cairo | 10 +- corelib/src/keccak.cairo | 22 +- corelib/src/lib.cairo | 2 +- corelib/src/math.cairo | 12 +- corelib/src/nullable.cairo | 14 +- corelib/src/num/traits/ops/checked.cairo | 12 +- corelib/src/num/traits/ops/saturating.cairo | 18 +- corelib/src/num/traits/ops/sqrt.cairo | 12 +- corelib/src/num/traits/ops/widemul.cairo | 24 +- corelib/src/num/traits/ops/widesquare.cairo | 10 +- corelib/src/num/traits/ops/wrapping.cairo | 12 +- corelib/src/ops/arith.cairo | 2 +- corelib/src/ops/index.cairo | 8 +- corelib/src/option.cairo | 2 +- corelib/src/panics.cairo | 8 +- corelib/src/pedersen.cairo | 2 +- corelib/src/poseidon.cairo | 14 +- corelib/src/prelude/v2023_01.cairo | 80 ++-- corelib/src/prelude/v2023_10.cairo | 60 +-- corelib/src/prelude/v2024_07.cairo | 34 +- corelib/src/result.cairo | 10 +- corelib/src/serde.cairo | 12 +- corelib/src/sha256.cairo | 4 +- corelib/src/test/array_test.cairo | 4 +- corelib/src/test/bool_test.cairo | 2 +- corelib/src/test/box_test.cairo | 2 +- corelib/src/test/byte_array_test.cairo | 4 +- corelib/src/test/bytes31_test.cairo | 2 +- corelib/src/test/circuit_test.cairo | 10 +- corelib/src/test/cmp_test.cairo | 4 +- corelib/src/test/coupon_test.cairo | 8 +- corelib/src/test/deref_test.cairo | 14 +- corelib/src/test/dict_test.cairo | 6 +- corelib/src/test/ec_test.cairo | 10 +- corelib/src/test/felt_test.cairo | 2 +- corelib/src/test/fmt_test.cairo | 6 +- corelib/src/test/hash_test.cairo | 14 +- corelib/src/test/integer_test.cairo | 10 +- corelib/src/test/keccak_test.cairo | 2 +- .../const_folding_test.cairo | 4 +- .../test/language_features/const_test.cairo | 2 +- .../src/test/language_features/for_test.cairo | 2 +- .../test/language_features/panics_test.cairo | 4 +- corelib/src/test/math_test.cairo | 4 +- corelib/src/test/nullable_test.cairo | 4 +- corelib/src/test/num_test.cairo | 6 +- corelib/src/test/plugins_test.cairo | 2 +- corelib/src/test/print_test.cairo | 4 +- corelib/src/test/result_test.cairo | 2 +- corelib/src/test/secp256k1_test.cairo | 2 +- corelib/src/test/secp256r1_test.cairo | 4 +- corelib/src/test/sha256_test.cairo | 2 +- corelib/src/test/testing_test.cairo | 10 +- corelib/src/test/to_byte_array_test.cairo | 4 +- corelib/src/testing.cairo | 2 +- corelib/src/to_byte_array.cairo | 8 +- corelib/src/traits.cairo | 18 +- corelib/src/zeroable.cairo | 2 +- .../ide/semantic_highlighting/token_kind.rs | 4 +- crates/cairo-lang-semantic/src/resolve/mod.rs | 23 +- .../src/statement_location_test_data/simple | 228 +++++----- 76 files changed, 738 insertions(+), 723 deletions(-) diff --git a/corelib/src/array.cairo b/corelib/src/array.cairo index e73005ae00c..b80bb6e456b 100644 --- a/corelib/src/array.cairo +++ b/corelib/src/array.cairo @@ -1,15 +1,15 @@ #[feature("deprecated-index-traits")] -use core::traits::IndexView; +use crate::traits::IndexView; -use core::box::BoxTrait; +use crate::box::BoxTrait; #[allow(unused_imports)] -use core::gas::withdraw_gas; +use crate::gas::withdraw_gas; #[allow(unused_imports)] -use core::option::OptionTrait; -use core::serde::Serde; -use core::metaprogramming::TypeEqual; -use core::iter::Iterator; -use core::RangeCheck; +use crate::option::OptionTrait; +use crate::serde::Serde; +use crate::metaprogramming::TypeEqual; +use crate::iter::Iterator; +use crate::RangeCheck; /// A collection of elements of the same type continuous in memory. #[derive(Drop)] @@ -543,7 +543,7 @@ impl SpanIterator of Iterator> { } } -impl SpanIntoIterator of core::iter::IntoIterator> { +impl SpanIntoIterator of crate::iter::IntoIterator> { type IntoIter = SpanIter; fn into_iter(self: Span) -> SpanIter { SpanIter { span: self } @@ -556,9 +556,9 @@ pub struct ArrayIter { array: Array, } -impl ArrayIterClone, +Drop> of core::clone::Clone> { +impl ArrayIterClone, +Drop> of crate::clone::Clone> { fn clone(self: @ArrayIter) -> ArrayIter { - ArrayIter { array: core::clone::Clone::clone(self.array), } + ArrayIter { array: crate::clone::Clone::clone(self.array), } } } @@ -569,7 +569,7 @@ impl ArrayIterator of Iterator> { } } -impl ArrayIntoIterator of core::iter::IntoIterator> { +impl ArrayIntoIterator of crate::iter::IntoIterator> { type IntoIter = ArrayIter; fn into_iter(self: Array) -> ArrayIter { ArrayIter { array: self } diff --git a/corelib/src/box.cairo b/corelib/src/box.cairo index 46091efd4c2..0d78692a558 100644 --- a/corelib/src/box.cairo +++ b/corelib/src/box.cairo @@ -53,15 +53,15 @@ pub impl BoxImpl of BoxTrait { } } -impl BoxDeref of core::ops::Deref> { +impl BoxDeref of crate::ops::Deref> { type Target = T; fn deref(self: Box) -> T { self.unbox() } } -impl BoxDebug> of core::fmt::Debug> { - fn fmt(self: @Box, ref f: core::fmt::Formatter) -> Result<(), core::fmt::Error> { +impl BoxDebug> of crate::fmt::Debug> { + fn fmt(self: @Box, ref f: crate::fmt::Formatter) -> Result<(), crate::fmt::Error> { write!(f, "&")?; TDebug::fmt(self.as_snapshot().unbox(), ref f) } diff --git a/corelib/src/byte_array.cairo b/corelib/src/byte_array.cairo index d5dae1cfcb2..7fbdb6d52d2 100644 --- a/corelib/src/byte_array.cairo +++ b/corelib/src/byte_array.cairo @@ -1,19 +1,19 @@ -use core::array::{ArrayTrait, SpanTrait}; +use crate::array::{ArrayTrait, SpanTrait}; #[allow(unused_imports)] -use core::bytes_31::{ +use crate::bytes_31::{ BYTES_IN_BYTES31, Bytes31Trait, one_shift_left_bytes_felt252, one_shift_left_bytes_u128, POW_2_128, POW_2_8, U128IntoBytes31, U8IntoBytes31 }; -use core::clone::Clone; -use core::cmp::min; +use crate::clone::Clone; +use crate::cmp::min; #[allow(unused_imports)] -use core::integer::{u128_safe_divmod, U32TryIntoNonZero}; -use core::option::OptionTrait; -use core::traits::{Into, TryInto}; +use crate::integer::{u128_safe_divmod, U32TryIntoNonZero}; +use crate::option::OptionTrait; +use crate::traits::{Into, TryInto}; #[allow(unused_imports)] -use core::serde::Serde; +use crate::serde::Serde; #[allow(unused_imports)] -use core::zeroable::NonZeroIntoImpl; +use crate::zeroable::NonZeroIntoImpl; /// A magic constant for identifying serialization of ByteArrays. An array of felt252s with this /// magic as one of the felt252s indicates that right after it you should expect a serialized @@ -38,7 +38,7 @@ pub struct ByteArray { pub(crate) pending_word_len: usize, } -pub(crate) impl ByteArrayStringLiteral of core::string::StringLiteral; +pub(crate) impl ByteArrayStringLiteral of crate::string::StringLiteral; #[generate_trait] pub impl ByteArrayImpl of ByteArrayTrait { @@ -353,7 +353,7 @@ impl ByteArrayAdd of Add { } } #[feature("deprecated-op-assign-traits")] -impl ByteArrayAddEq of core::traits::AddEq { +impl ByteArrayAddEq of crate::traits::AddEq { #[inline] fn add_eq(ref self: ByteArray, other: ByteArray) { self.append(@other); @@ -361,7 +361,7 @@ impl ByteArrayAddEq of core::traits::AddEq { } #[feature("deprecated-index-traits")] -pub(crate) impl ByteArrayIndexView of core::traits::IndexView { +pub(crate) impl ByteArrayIndexView of crate::traits::IndexView { fn index(self: @ByteArray, index: usize) -> u8 { self.at(index).expect('Index out of bounds') } diff --git a/corelib/src/bytes_31.cairo b/corelib/src/bytes_31.cairo index 2a3dd66bd1e..c03b1e2e598 100644 --- a/corelib/src/bytes_31.cairo +++ b/corelib/src/bytes_31.cairo @@ -1,8 +1,8 @@ -use core::traits::{Into, TryInto}; -use core::option::OptionTrait; +use crate::traits::{Into, TryInto}; +use crate::option::OptionTrait; #[allow(unused_imports)] -use core::integer::{u128_safe_divmod, u128_to_felt252}; -use core::RangeCheck; +use crate::integer::{u128_safe_divmod, u128_to_felt252}; +use crate::RangeCheck; pub(crate) const BYTES_IN_BYTES31: usize = 31; const BYTES_IN_U128: usize = 16; @@ -32,13 +32,13 @@ pub impl Bytes31Impl of Bytes31Trait { } #[feature("deprecated-index-traits")] -pub(crate) impl Bytes31IndexView of core::traits::IndexView { +pub(crate) impl Bytes31IndexView of crate::traits::IndexView { fn index(self: @bytes31, index: usize) -> u8 { self.at(index) } } -impl Bytes31BitSize of core::num::traits::BitSize { +impl Bytes31BitSize of crate::num::traits::BitSize { fn bits() -> usize { 248 } @@ -63,31 +63,31 @@ pub(crate) impl Felt252TryIntoBytes31 of TryInto { } } -impl Bytes31Serde = core::serde::into_felt252_based::SerdeImpl; +impl Bytes31Serde = crate::serde::into_felt252_based::SerdeImpl; pub(crate) impl U8IntoBytes31 of Into { fn into(self: u8) -> bytes31 { - core::integer::upcast(self) + crate::integer::upcast(self) } } impl U16IntoBytes31 of Into { fn into(self: u16) -> bytes31 { - core::integer::upcast(self) + crate::integer::upcast(self) } } impl U32IntoBytes31 of Into { fn into(self: u32) -> bytes31 { - core::integer::upcast(self) + crate::integer::upcast(self) } } impl U64IntoBytes31 of Into { fn into(self: u64) -> bytes31 { - core::integer::upcast(self) + crate::integer::upcast(self) } } pub(crate) impl U128IntoBytes31 of Into { fn into(self: u128) -> bytes31 { - core::integer::upcast(self) + crate::integer::upcast(self) } } @@ -173,7 +173,7 @@ pub(crate) fn one_shift_left_bytes_u128(n_bytes: usize) -> u128 { 13 => 0x100000000000000000000000000, 14 => 0x10000000000000000000000000000, 15 => 0x1000000000000000000000000000000, - _ => core::panic_with_felt252('n_bytes too big'), + _ => crate::panic_with_felt252('n_bytes too big'), } } diff --git a/corelib/src/circuit.cairo b/corelib/src/circuit.cairo index b50af6b2091..d7d44a711ff 100644 --- a/corelib/src/circuit.cairo +++ b/corelib/src/circuit.cairo @@ -40,7 +40,7 @@ pub struct u384 { pub limb3: u96, } -pub type u96 = core::internal::bounded_int::BoundedInt<0, 79228162514264337593543950335>; +pub type u96 = crate::internal::bounded_int::BoundedInt<0, 79228162514264337593543950335>; pub extern type RangeCheck96; pub extern type AddMod; pub extern type MulMod; @@ -73,8 +73,8 @@ impl DestructU96Guarantee of Destruct { extern type U96Guarantee; /// Expose the const required by the libfunc to allow the compiler const reusage. -pub type ConstZero = core::internal::bounded_int::BoundedInt<0, 0>; -pub type ConstOne = core::internal::bounded_int::BoundedInt<1, 1>; +pub type ConstZero = crate::internal::bounded_int::BoundedInt<0, 0>; +pub type ConstOne = crate::internal::bounded_int::BoundedInt<1, 1>; /// A type that creates a circuit from a tuple of outputs. pub extern type Circuit; @@ -129,7 +129,7 @@ pub enum AddInputResult { } mod internal { - use core::traits::PanicDestructForDestruct; + use crate::traits::PanicDestructForDestruct; impl AddInputResultDrop of Drop>; impl CircuitDataDrop of Drop>; impl CircuitInputAccumulatorDrop of Drop>; @@ -195,7 +195,7 @@ trait CircuitDefinition { type CircuitType; } impl CircuitDefinitionImpl< - T, impl Unwrap: UnwrapCircuitElement, +core::metaprogramming::IsTuple + T, impl Unwrap: UnwrapCircuitElement, +crate::metaprogramming::IsTuple > of CircuitDefinition { type CircuitType = Circuit; } @@ -218,10 +218,12 @@ impl UnwrapCircuitElementBase< /// Implementation for unwrapping a tuple of `CircuitElement`s. impl UnwrapCircuitElementNext< T, - impl TS: core::metaprogramming::TupleSplit, + impl TS: crate::metaprogramming::TupleSplit, impl UnwrapHead: UnwrapCircuitElement, impl UnwrapRest: UnwrapCircuitElement, - impl TEF: core::metaprogramming::TupleExtendFront, + impl TEF: crate::metaprogramming::TupleExtendFront< + UnwrapRest::Unwrapped, UnwrapHead::Unwrapped + >, > of UnwrapCircuitElement { type Unwrapped = TEF::Result; } @@ -310,14 +312,14 @@ impl U384IntoCircuitInputValue of IntoCircuitInputValue { pub impl EvalCircuitImpl of EvalCircuitTrait { // Inlining to make sure possibly huge `C` won't be in a user function name. #[inline(always)] - fn eval(self: CircuitData, modulus: CircuitModulus) -> core::circuit::EvalCircuitResult { + fn eval(self: CircuitData, modulus: CircuitModulus) -> crate::circuit::EvalCircuitResult { self.eval_ex(get_circuit_descriptor::(), modulus) } // Inlining to make sure possibly huge `C` won't be in a user function name. #[inline(always)] fn eval_ex( self: CircuitData, descriptor: CircuitDescriptor, modulus: CircuitModulus - ) -> core::circuit::EvalCircuitResult { + ) -> crate::circuit::EvalCircuitResult { eval_circuit::(descriptor, self, modulus, 0, 1) } } @@ -426,7 +428,7 @@ extern fn get_circuit_output( /// Helper module to convert into `u384`. mod conversions { - use core::internal::{ + use crate::internal::{ bounded_int, bounded_int::{BoundedInt, AddHelper, MulHelper, DivRemHelper} }; @@ -460,14 +462,14 @@ mod conversions { pub fn from_u128(value: u128) -> super::u384 { let (limb1, limb0) = bounded_int::div_rem(value, NZ_POW96_TYPED); - core::circuit::u384 { limb0, limb1: core::integer::upcast(limb1), limb2: 0, limb3: 0 } + crate::circuit::u384 { limb0, limb1: crate::integer::upcast(limb1), limb2: 0, limb3: 0 } } pub fn from_u256(value: u256) -> super::u384 { let (limb1_low32, limb0) = bounded_int::div_rem(value.low, NZ_POW96_TYPED); let (limb2, limb1_high64) = bounded_int::div_rem(value.high, NZ_POW64_TYPED); let limb1 = bounded_int::add(bounded_int::mul(limb1_high64, POW32_TYPED), limb1_low32); - core::circuit::u384 { limb0, limb1, limb2: core::integer::upcast(limb2), limb3: 0 } + crate::circuit::u384 { limb0, limb1, limb2: crate::integer::upcast(limb2), limb3: 0 } } } diff --git a/corelib/src/clone.cairo b/corelib/src/clone.cairo index a303526c9df..436a782e722 100644 --- a/corelib/src/clone.cairo +++ b/corelib/src/clone.cairo @@ -12,7 +12,7 @@ impl TCopyClone> of Clone { /// Tuple `Clone` implementation. impl TupleClone< T, - impl TSF: core::metaprogramming::TupleSnapForward, + impl TSF: crate::metaprogramming::TupleSnapForward, impl CH: CloneHelper, -Copy, > of Clone { @@ -53,12 +53,12 @@ impl FixedSizedArrayCloneHelper of CloneHelper<[@T; 0], [T; 0]> { /// Recursive implementation of `CloneHelper` for tuple style structs. impl TupleNextCloneHelper< T, - impl TH: core::metaprogramming::TupleSplit, - impl HeadNoSnap: core::metaprogramming::SnapRemove, - impl RestNoSnap: core::metaprogramming::SnapRemove, + impl TH: crate::metaprogramming::TupleSplit, + impl HeadNoSnap: crate::metaprogramming::SnapRemove, + impl RestNoSnap: crate::metaprogramming::SnapRemove, impl HeadHelper: CloneHelper, impl RestHelper: CloneHelper, - impl TEF: core::metaprogramming::TupleExtendFront, + impl TEF: crate::metaprogramming::TupleExtendFront, +Destruct, +Drop, > of CloneHelper { diff --git a/corelib/src/debug.cairo b/corelib/src/debug.cairo index 4eb84ae63c6..f6744d82dd7 100644 --- a/corelib/src/debug.cairo +++ b/corelib/src/debug.cairo @@ -1,12 +1,12 @@ #[allow(unused_imports)] -use core::array::ArrayTrait; -use core::traits::Into; +use crate::array::ArrayTrait; +use crate::traits::Into; #[allow(unused_imports)] -use core::option::Option; +use crate::option::Option; /// Usage: /// ``` -/// use core::debug::PrintTrait; +/// use crate::debug::PrintTrait; /// /// 1.print(); /// @@ -127,7 +127,7 @@ pub(crate) impl ArrayGenericPrintImpl of PrintTrait> { /// Prints a byte array as a string. pub fn print_byte_array_as_string(self: @ByteArray) { - let mut serialized = array![core::byte_array::BYTE_ARRAY_MAGIC]; + let mut serialized = array![crate::byte_array::BYTE_ARRAY_MAGIC]; self.serialize(ref serialized); print(serialized) } diff --git a/corelib/src/dict.cairo b/corelib/src/dict.cairo index d1cb799729c..0d5de2cf031 100644 --- a/corelib/src/dict.cairo +++ b/corelib/src/dict.cairo @@ -1,12 +1,12 @@ #[feature("deprecated-index-traits")] -use core::traits::{Index, Default, Felt252DictValue}; +use crate::traits::{Index, Default, Felt252DictValue}; pub extern type Felt252Dict; pub extern type SquashedFelt252Dict; pub extern type Felt252DictEntry; impl SquashedFelt252DictDrop> of Drop>; -use core::{RangeCheck, SegmentArena}; -use core::gas::GasBuiltin; +use crate::{RangeCheck, SegmentArena}; +use crate::gas::GasBuiltin; pub(crate) extern fn felt252_dict_new() -> Felt252Dict implicits(SegmentArena) nopanic; diff --git a/corelib/src/ec.cairo b/corelib/src/ec.cairo index f2f605f4ae5..a3ba5fa62f0 100644 --- a/corelib/src/ec.cairo +++ b/corelib/src/ec.cairo @@ -2,11 +2,11 @@ //! curve. #[allow(unused_imports)] -use core::array::ArrayTrait; +use crate::array::ArrayTrait; #[allow(unused_imports)] -use core::traits::{Into, TryInto}; -use core::zeroable::IsZeroResult; -use core::RangeCheck; +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^2 = x^3 + ALPHA*x + BETA`. @@ -197,7 +197,7 @@ impl EcPointAdd of Add { } #[feature("deprecated-op-assign-traits")] -impl EcPointAddEq of core::traits::AddEq { +impl EcPointAddEq of crate::traits::AddEq { #[inline(always)] fn add_eq(ref self: EcPoint, other: EcPoint) { self = Add::add(self, other); @@ -218,7 +218,7 @@ impl EcPointSub of Sub { } #[feature("deprecated-op-assign-traits")] -impl EcPointSubEq of core::traits::SubEq { +impl EcPointSubEq of crate::traits::SubEq { #[inline(always)] fn sub_eq(ref self: EcPoint, other: EcPoint) { self = Sub::sub(self, other); diff --git a/corelib/src/ecdsa.cairo b/corelib/src/ecdsa.cairo index 0d56358ee1c..e9969289a7a 100644 --- a/corelib/src/ecdsa.cairo +++ b/corelib/src/ecdsa.cairo @@ -1,11 +1,11 @@ -use core::{ec, ec::{EcPoint, EcPointTrait, EcStateTrait}}; +use crate::{ec, ec::{EcPoint, EcPointTrait, EcStateTrait}}; #[allow(unused_imports)] -use core::option::OptionTrait; -use core::math; +use crate::option::OptionTrait; +use crate::math; #[allow(unused_imports)] -use core::traits::{Into, TryInto}; +use crate::traits::{Into, TryInto}; #[allow(unused_imports)] -use core::zeroable::IsZeroResult; +use crate::zeroable::IsZeroResult; /// Checks if (`signature_r`, `signature_s`) is a valid ECDSA signature for the given `public_key` /// on the given `message`. diff --git a/corelib/src/felt_252.cairo b/corelib/src/felt_252.cairo index 2a32a86ac4f..0d3313bb7d9 100644 --- a/corelib/src/felt_252.cairo +++ b/corelib/src/felt_252.cairo @@ -1,4 +1,4 @@ -pub(crate) impl Felt252Zero of core::num::traits::Zero { +pub(crate) impl Felt252Zero of crate::num::traits::Zero { fn zero() -> felt252 { 0 } @@ -14,7 +14,7 @@ pub(crate) impl Felt252Zero of core::num::traits::Zero { } } -pub(crate) impl Felt252One of core::num::traits::One { +pub(crate) impl Felt252One of crate::num::traits::One { fn one() -> felt252 { 1 } diff --git a/corelib/src/fmt.cairo b/corelib/src/fmt.cairo index 3c4aee73110..d8da972f7c0 100644 --- a/corelib/src/fmt.cairo +++ b/corelib/src/fmt.cairo @@ -21,7 +21,7 @@ impl DisplayByteArray of Display { } impl DisplayInteger< - T, +core::to_byte_array::AppendFormattedToByteArray, +Into, +TryInto> + T, +crate::to_byte_array::AppendFormattedToByteArray, +Into, +TryInto> > of Display { fn fmt(self: @T, ref f: Formatter) -> Result<(), Error> { // TODO(yuval): determine base according to Formatter parameters. @@ -34,7 +34,7 @@ impl DisplayInteger< impl DisplaySignedInteger< Signed, Unsigned, - +core::integer::AbsAndSign, + +crate::integer::AbsAndSign, +Display, +Copy, +Drop, @@ -85,7 +85,7 @@ impl DebugByteArray of Debug { } impl DebugInteger< - T, +core::to_byte_array::AppendFormattedToByteArray, +Into, +TryInto> + T, +crate::to_byte_array::AppendFormattedToByteArray, +Into, +TryInto> > of Debug { fn fmt(self: @T, ref f: Formatter) -> Result<(), Error> { Display::fmt(self, ref f) @@ -95,7 +95,7 @@ impl DebugInteger< impl DebugSignedInteger< Signed, Unsigned, - +core::integer::AbsAndSign, + +crate::integer::AbsAndSign, +Display, +Copy, +Drop, @@ -128,9 +128,9 @@ impl DebugSnapshot> of Debug<@T> { /// Tuple `Debug` implementation. impl TupleDebug< T, - impl TSF: core::metaprogramming::TupleSnapForward, + impl TSF: crate::metaprogramming::TupleSnapForward, +TupleDebugHelper, - +core::metaprogramming::IsTuple, + +crate::metaprogramming::IsTuple, > of Debug { fn fmt(self: @T, ref f: Formatter) -> Result<(), Error> { write!(f, "(")?; @@ -142,9 +142,9 @@ impl TupleDebug< /// Fixed sized array `Debug` implementation. impl FixedSizedArrayDebug< T, - impl TSF: core::metaprogramming::TupleSnapForward, + impl TSF: crate::metaprogramming::TupleSnapForward, +TupleDebugHelper, - -core::metaprogramming::IsTuple, + -crate::metaprogramming::IsTuple, > of Debug { fn fmt(self: @T, ref f: Formatter) -> Result<(), Error> { write!(f, "[")?; @@ -197,14 +197,14 @@ impl TupleDebugHelperTuple2< /// Not starting from size 1 since we have special cases for 0 and 1. impl TupleDebugHelperTupleNext< T, - impl TS: core::metaprogramming::TupleSplit, - +core::metaprogramming::IsTuple, + impl TS: crate::metaprogramming::TupleSplit, + +crate::metaprogramming::IsTuple, +TupleDebugHelper, +TupleDebugHelper, +Drop, // Making sure the size it at least 3. - impl NTS: core::metaprogramming::TupleSplit, - +core::metaprogramming::TupleSplit, + impl NTS: crate::metaprogramming::TupleSplit, + +crate::metaprogramming::TupleSplit, > of TupleDebugHelper { fn fmt(value: T, ref f: Formatter) -> Result<(), Error> { fmt_head_and_rest(value, ref f) @@ -231,12 +231,12 @@ impl TupleDebugHelperFixedSizedArray1> of TupleDebugHel impl TupleDebugHelperFixedSizedArrayNext< T, const N: usize, - impl TS: core::metaprogramming::TupleSplit<[@T; N]>, + impl TS: crate::metaprogramming::TupleSplit<[@T; N]>, +TupleDebugHelper, +TupleDebugHelper, +Drop, // Making sure the size it at least 2. - +core::metaprogramming::TupleSplit, + +crate::metaprogramming::TupleSplit, > of TupleDebugHelper<[@T; N]> { fn fmt(value: [@T; N], ref f: Formatter) -> Result<(), Error> { fmt_head_and_rest(value, ref f) @@ -246,7 +246,7 @@ impl TupleDebugHelperFixedSizedArrayNext< /// A helper function for formatting the head and tail of a tuple style struct. fn fmt_head_and_rest< T, - impl TS: core::metaprogramming::TupleSplit, + impl TS: crate::metaprogramming::TupleSplit, +TupleDebugHelper, +TupleDebugHelper, +Drop, @@ -292,12 +292,12 @@ impl SpanTDebug> of Debug> { /// Impls for `Debug` for types that can be converted into `felt252` using the `Into` trait. /// Usage example: /// ```ignore -/// impl MyTypeDebug = core::fmt::into_felt252_based::DebugImpl;` +/// impl MyTypeDebug = crate::fmt::into_felt252_based::DebugImpl;` /// ``` pub mod into_felt252_based { - pub impl DebugImpl, +Copy> of core::fmt::Debug { - fn fmt(self: @T, ref f: core::fmt::Formatter) -> Result<(), core::fmt::Error> { - core::fmt::DebugInteger::::fmt(@(*self).into(), ref f) + pub impl DebugImpl, +Copy> of crate::fmt::Debug { + fn fmt(self: @T, ref f: crate::fmt::Formatter) -> Result<(), crate::fmt::Error> { + crate::fmt::DebugInteger::::fmt(@(*self).into(), ref f) } } } diff --git a/corelib/src/gas.cairo b/corelib/src/gas.cairo index 2e2b254fdf2..f720204e08c 100644 --- a/corelib/src/gas.cairo +++ b/corelib/src/gas.cairo @@ -1,4 +1,4 @@ -use core::RangeCheck; +use crate::RangeCheck; /// Type representing the table of the costs of the different builtin usages. #[derive(Copy, Drop)] diff --git a/corelib/src/hash.cairo b/corelib/src/hash.cairo index 8917304e29e..2b1f242c18b 100644 --- a/corelib/src/hash.cairo +++ b/corelib/src/hash.cairo @@ -1,5 +1,5 @@ #[allow(unused_imports)] -use core::traits::Into; +use crate::traits::Into; /// A trait for hash state accumulators. pub trait HashStateTrait { @@ -25,10 +25,10 @@ pub trait LegacyHash { } /// Implementation of `LegacyHash` for types that have `Hash` for backwards compatibility. -impl LegacyHashForHash> of LegacyHash { +impl LegacyHashForHash> of LegacyHash { #[inline(always)] fn hash(state: felt252, value: T) -> felt252 { - core::pedersen::HashState { state }.update_with(value).state + crate::pedersen::HashState { state }.update_with(value).state } } @@ -100,7 +100,7 @@ impl TupleNextHash< T, S, +HashStateTrait, - impl TH: core::metaprogramming::TupleSplit, + impl TH: crate::metaprogramming::TupleSplit, +Hash, +Hash, +Drop, diff --git a/corelib/src/integer.cairo b/corelib/src/integer.cairo index 630fc8dbe5f..0b7c3164548 100644 --- a/corelib/src/integer.cairo +++ b/corelib/src/integer.cairo @@ -1,13 +1,13 @@ -use core::option::OptionTrait; -use core::result::ResultTrait; -use core::traits::{BitAnd, BitNot, BitOr, BitXor, Into, TryInto, Default, Felt252DictValue}; +use crate::option::OptionTrait; +use crate::result::ResultTrait; +use crate::traits::{BitAnd, BitNot, BitOr, BitXor, Into, TryInto, Default, Felt252DictValue}; #[allow(unused_imports)] -use core::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable}; +use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable}; #[allow(unused_imports)] -use core::array::ArrayTrait; +use crate::array::ArrayTrait; #[allow(unused_imports)] -use core::array::SpanTrait; -use core::RangeCheck; +use crate::array::SpanTrait; +use crate::RangeCheck; // TODO(spapini): Add method for const creation from Integer. pub trait NumericLiteral; @@ -19,7 +19,7 @@ impl NumericLiteralNonZero> of NumericLiteral>; pub extern type u128; impl NumericLiteralu128 of NumericLiteral; -impl U128Serde = core::serde::into_felt252_based::SerdeImpl; +impl U128Serde = crate::serde::into_felt252_based::SerdeImpl; enum U128sFromFelt252Result { Narrow: u128, @@ -195,34 +195,34 @@ impl U128PartialOrd of PartialOrd { pub extern type Bitwise; /// Returns the bitwise operations (AND, XOR, OR) between `lhs` and `rhs`. extern fn bitwise(lhs: u128, rhs: u128) -> (u128, u128, u128) implicits(Bitwise) nopanic; -impl U128BitAnd of core::traits::BitAnd { +impl U128BitAnd of crate::traits::BitAnd { #[inline(always)] fn bitand(lhs: u128, rhs: u128) -> u128 { let (v, _, _) = bitwise(lhs, rhs); v } } -impl U128BitXor of core::traits::BitXor { +impl U128BitXor of crate::traits::BitXor { #[inline(always)] fn bitxor(lhs: u128, rhs: u128) -> u128 { let (_, v, _) = bitwise(lhs, rhs); v } } -impl U128BitOr of core::traits::BitOr { +impl U128BitOr of crate::traits::BitOr { #[inline(always)] fn bitor(lhs: u128, rhs: u128) -> u128 { let (_, _, v) = bitwise(lhs, rhs); v } } -impl U128BitNot of core::traits::BitNot { +impl U128BitNot of crate::traits::BitNot { fn bitnot(a: u128) -> u128 { - core::num::traits::Bounded::MAX - a + crate::num::traits::Bounded::MAX - a } } -impl U128BitSize of core::num::traits::BitSize { +impl U128BitSize of crate::num::traits::BitSize { fn bits() -> usize { 128 } @@ -242,7 +242,7 @@ extern fn u8_try_from_felt252(a: felt252) -> Option implicits(RangeCheck) no extern fn u8_eq(lhs: u8, rhs: u8) -> bool implicits() nopanic; -impl U8Serde = core::serde::into_felt252_based::SerdeImpl; +impl U8Serde = crate::serde::into_felt252_based::SerdeImpl; impl U8PartialEq of PartialEq { #[inline(always)] @@ -349,7 +349,7 @@ impl U8DivRem of DivRem { impl U8BitNot of BitNot { fn bitnot(a: u8) -> u8 { - core::num::traits::Bounded::MAX - a + crate::num::traits::Bounded::MAX - a } } extern fn u8_bitwise(lhs: u8, rhs: u8) -> (u8, u8, u8) implicits(Bitwise) nopanic; @@ -375,7 +375,7 @@ impl U8BitOr of BitOr { } } -impl U8BitSize of core::num::traits::BitSize { +impl U8BitSize of crate::num::traits::BitSize { fn bits() -> usize { 8 } @@ -391,7 +391,7 @@ extern fn u16_try_from_felt252(a: felt252) -> Option implicits(RangeCheck) extern fn u16_eq(lhs: u16, rhs: u16) -> bool implicits() nopanic; -impl U16Serde = core::serde::into_felt252_based::SerdeImpl; +impl U16Serde = crate::serde::into_felt252_based::SerdeImpl; impl U16PartialEq of PartialEq { #[inline(always)] @@ -504,7 +504,7 @@ impl U16DivRem of DivRem { impl U16BitNot of BitNot { fn bitnot(a: u16) -> u16 { - core::num::traits::Bounded::MAX - a + crate::num::traits::Bounded::MAX - a } } extern fn u16_bitwise(lhs: u16, rhs: u16) -> (u16, u16, u16) implicits(Bitwise) nopanic; @@ -530,7 +530,7 @@ impl U16BitOr of BitOr { } } -impl U16BitSize of core::num::traits::BitSize { +impl U16BitSize of crate::num::traits::BitSize { fn bits() -> usize { 16 } @@ -546,7 +546,7 @@ extern fn u32_try_from_felt252(a: felt252) -> Option implicits(RangeCheck) extern fn u32_eq(lhs: u32, rhs: u32) -> bool implicits() nopanic; -impl U32Serde = core::serde::into_felt252_based::SerdeImpl; +impl U32Serde = crate::serde::into_felt252_based::SerdeImpl; impl U32PartialEq of PartialEq { #[inline(always)] @@ -659,7 +659,7 @@ impl U32DivRem of DivRem { impl U32BitNot of BitNot { fn bitnot(a: u32) -> u32 { - core::num::traits::Bounded::MAX - a + crate::num::traits::Bounded::MAX - a } } extern fn u32_bitwise(lhs: u32, rhs: u32) -> (u32, u32, u32) implicits(Bitwise) nopanic; @@ -685,7 +685,7 @@ impl U32BitOr of BitOr { } } -impl U32BitSize of core::num::traits::BitSize { +impl U32BitSize of crate::num::traits::BitSize { fn bits() -> usize { 32 } @@ -701,7 +701,7 @@ extern fn u64_try_from_felt252(a: felt252) -> Option implicits(RangeCheck) extern fn u64_eq(lhs: u64, rhs: u64) -> bool implicits() nopanic; -impl U64Serde = core::serde::into_felt252_based::SerdeImpl; +impl U64Serde = crate::serde::into_felt252_based::SerdeImpl; impl U64PartialEq of PartialEq { #[inline(always)] @@ -814,7 +814,7 @@ impl U64DivRem of DivRem { impl U64BitNot of BitNot { fn bitnot(a: u64) -> u64 { - core::num::traits::Bounded::MAX - a + crate::num::traits::Bounded::MAX - a } } extern fn u64_bitwise(lhs: u64, rhs: u64) -> (u64, u64, u64) implicits(Bitwise) nopanic; @@ -840,7 +840,7 @@ impl U64BitOr of BitOr { } } -impl U64BitSize of core::num::traits::BitSize { +impl U64BitSize of crate::num::traits::BitSize { fn bits() -> usize { 64 } @@ -1057,7 +1057,7 @@ impl U256BitNot of BitNot { } } -impl U256BitSize of core::num::traits::BitSize { +impl U256BitSize of crate::num::traits::BitSize { fn bits() -> usize { 256 } @@ -1090,11 +1090,11 @@ pub fn u256_wide_mul(a: u256, b: u256) -> u512 nopanic { let (limb3, limb2_part) = u128_wide_mul(a.high, b.high); let (limb2, limb2_overflow1) = u128_add_with_bounded_int_carry(limb2, limb2_part); // Packing together the overflow bits, making a cheaper addition into limb2. - let limb1_overflow = core::internal::bounded_int::add(limb1_overflow0, limb1_overflow1); + let limb1_overflow = crate::internal::bounded_int::add(limb1_overflow0, limb1_overflow1); let (limb2, limb2_overflow2) = u128_add_with_bounded_int_carry(limb2, upcast(limb1_overflow)); // Packing together the overflow bits, making a cheaper addition into limb3. - let limb2_overflow = core::internal::bounded_int::add(limb2_overflow0, limb2_overflow1); - let limb2_overflow = core::internal::bounded_int::add(limb2_overflow, limb2_overflow2); + let limb2_overflow = crate::internal::bounded_int::add(limb2_overflow0, limb2_overflow1); + let limb2_overflow = crate::internal::bounded_int::add(limb2_overflow, limb2_overflow2); // No overflow since no limb4. let limb3 = u128_wrapping_add(limb3, upcast(limb2_overflow)); u512 { limb0, limb1, limb2, limb3 } @@ -1104,7 +1104,7 @@ pub fn u256_wide_mul(a: u256, b: u256) -> u512 nopanic { /// Used for adding two u128s and receiving a BoundedInt for the carry result. pub(crate) fn u128_add_with_bounded_int_carry( a: u128, b: u128 -) -> (u128, core::internal::bounded_int::BoundedInt<0, 1>) nopanic { +) -> (u128, crate::internal::bounded_int::BoundedInt<0, 1>) nopanic { match u128_overflowing_add(a, b) { Result::Ok(v) => (v, 0), Result::Err(v) => (v, 1), @@ -1160,7 +1160,7 @@ pub trait BoundedInt { mod bounded_int_impls { #[feature("deprecated-bounded-int-trait")] - pub impl ByBounded> of super::BoundedInt { + pub impl ByBounded> of super::BoundedInt { #[inline(always)] fn min() -> T nopanic { Bounded::MIN @@ -1600,7 +1600,7 @@ extern fn i8_to_felt252(a: i8) -> felt252 nopanic; extern fn i8_is_zero(a: i8) -> IsZeroResult implicits() nopanic; extern fn i8_eq(lhs: i8, rhs: i8) -> bool implicits() nopanic; -impl I8Serde = core::serde::into_felt252_based::SerdeImpl; +impl I8Serde = crate::serde::into_felt252_based::SerdeImpl; impl I8PartialEq of PartialEq { #[inline(always)] @@ -1619,8 +1619,8 @@ impl I8Add of Add { fn add(lhs: i8, rhs: i8) -> i8 { match i8_overflowing_add_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i8_add Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i8_add Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i8_add Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i8_add Overflow'), } } } @@ -1628,8 +1628,8 @@ impl I8Sub of Sub { fn sub(lhs: i8, rhs: i8) -> i8 { match i8_overflowing_sub_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i8_sub Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i8_sub Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i8_sub Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i8_sub Overflow'), } } } @@ -1641,7 +1641,7 @@ impl I8Neg of Neg { } } -#[deprecated(feature: "corelib-internal-use", note: "Use `core::num::traits::WideMul` instead")] +#[deprecated(feature: "corelib-internal-use", note: "Use `crate::num::traits::WideMul` instead")] pub extern fn i8_wide_mul(lhs: i8, rhs: i8) -> i16 implicits() nopanic; impl I8Mul of Mul { fn mul(lhs: i8, rhs: i8) -> i8 { @@ -1662,7 +1662,7 @@ impl I8PartialOrd of PartialOrd { } } -impl I8BitSize of core::num::traits::BitSize { +impl I8BitSize of crate::num::traits::BitSize { fn bits() -> usize { 8 } @@ -1677,7 +1677,7 @@ extern fn i16_to_felt252(a: i16) -> felt252 nopanic; extern fn i16_is_zero(a: i16) -> IsZeroResult implicits() nopanic; extern fn i16_eq(lhs: i16, rhs: i16) -> bool implicits() nopanic; -impl I16Serde = core::serde::into_felt252_based::SerdeImpl; +impl I16Serde = crate::serde::into_felt252_based::SerdeImpl; impl I16PartialEq of PartialEq { #[inline(always)] @@ -1696,8 +1696,8 @@ impl I16Add of Add { fn add(lhs: i16, rhs: i16) -> i16 { match i16_overflowing_add_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i16_add Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i16_add Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i16_add Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i16_add Overflow'), } } } @@ -1705,8 +1705,8 @@ impl I16Sub of Sub { fn sub(lhs: i16, rhs: i16) -> i16 { match i16_overflowing_sub_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i16_sub Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i16_sub Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i16_sub Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i16_sub Overflow'), } } } @@ -1718,7 +1718,7 @@ impl I16Neg of Neg { } } -#[deprecated(feature: "corelib-internal-use", note: "Use `core::num::traits::WideMul` instead")] +#[deprecated(feature: "corelib-internal-use", note: "Use `crate::num::traits::WideMul` instead")] pub extern fn i16_wide_mul(lhs: i16, rhs: i16) -> i32 implicits() nopanic; impl I16Mul of Mul { fn mul(lhs: i16, rhs: i16) -> i16 { @@ -1739,7 +1739,7 @@ impl I16PartialOrd of PartialOrd { } } -impl I16BitSize of core::num::traits::BitSize { +impl I16BitSize of crate::num::traits::BitSize { fn bits() -> usize { 16 } @@ -1754,7 +1754,7 @@ extern fn i32_to_felt252(a: i32) -> felt252 nopanic; extern fn i32_is_zero(a: i32) -> IsZeroResult implicits() nopanic; extern fn i32_eq(lhs: i32, rhs: i32) -> bool implicits() nopanic; -impl I32Serde = core::serde::into_felt252_based::SerdeImpl; +impl I32Serde = crate::serde::into_felt252_based::SerdeImpl; impl I32PartialEq of PartialEq { #[inline(always)] @@ -1773,8 +1773,8 @@ impl I32Add of Add { fn add(lhs: i32, rhs: i32) -> i32 { match i32_overflowing_add_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i32_add Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i32_add Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i32_add Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i32_add Overflow'), } } } @@ -1782,8 +1782,8 @@ impl I32Sub of Sub { fn sub(lhs: i32, rhs: i32) -> i32 { match i32_overflowing_sub_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i32_sub Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i32_sub Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i32_sub Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i32_sub Overflow'), } } } @@ -1816,7 +1816,7 @@ impl I32PartialOrd of PartialOrd { } } -impl I32BitSize of core::num::traits::BitSize { +impl I32BitSize of crate::num::traits::BitSize { fn bits() -> usize { 32 } @@ -1831,7 +1831,7 @@ extern fn i64_to_felt252(a: i64) -> felt252 nopanic; extern fn i64_is_zero(a: i64) -> IsZeroResult implicits() nopanic; extern fn i64_eq(lhs: i64, rhs: i64) -> bool implicits() nopanic; -impl I64Serde = core::serde::into_felt252_based::SerdeImpl; +impl I64Serde = crate::serde::into_felt252_based::SerdeImpl; impl I64PartialEq of PartialEq { #[inline(always)] @@ -1850,8 +1850,8 @@ impl I64Add of Add { fn add(lhs: i64, rhs: i64) -> i64 { match i64_overflowing_add_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i64_add Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i64_add Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i64_add Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i64_add Overflow'), } } } @@ -1859,8 +1859,8 @@ impl I64Sub of Sub { fn sub(lhs: i64, rhs: i64) -> i64 { match i64_overflowing_sub_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i64_sub Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i64_sub Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i64_sub Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i64_sub Overflow'), } } } @@ -1893,7 +1893,7 @@ impl I64PartialOrd of PartialOrd { } } -impl I64BitSize of core::num::traits::BitSize { +impl I64BitSize of crate::num::traits::BitSize { fn bits() -> usize { 64 } @@ -1908,7 +1908,7 @@ extern fn i128_to_felt252(a: i128) -> felt252 nopanic; extern fn i128_is_zero(a: i128) -> IsZeroResult implicits() nopanic; extern fn i128_eq(lhs: i128, rhs: i128) -> bool implicits() nopanic; -impl I128Serde = core::serde::into_felt252_based::SerdeImpl; +impl I128Serde = crate::serde::into_felt252_based::SerdeImpl; impl I128PartialEq of PartialEq { #[inline(always)] @@ -1931,8 +1931,8 @@ impl I128Add of Add { fn add(lhs: i128, rhs: i128) -> i128 { match i128_overflowing_add_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i128_add Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i128_add Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i128_add Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i128_add Overflow'), } } } @@ -1940,8 +1940,8 @@ impl I128Sub of Sub { fn sub(lhs: i128, rhs: i128) -> i128 { match i128_overflowing_sub_impl(lhs, rhs) { SignedIntegerResult::InRange(result) => result, - SignedIntegerResult::Underflow(_) => core::panic_with_felt252('i128_sub Underflow'), - SignedIntegerResult::Overflow(_) => core::panic_with_felt252('i128_sub Overflow'), + SignedIntegerResult::Underflow(_) => crate::panic_with_felt252('i128_sub Underflow'), + SignedIntegerResult::Overflow(_) => crate::panic_with_felt252('i128_sub Overflow'), } } } @@ -1984,7 +1984,7 @@ impl I128PartialOrd of PartialOrd { } mod signed_div_rem { - use core::internal::{ + use crate::internal::{ bounded_int, bounded_int::{BoundedInt, MulHelper, DivRemHelper, ConstrainHelper} }; @@ -2287,27 +2287,27 @@ impl I128Rem = by_div_rem::RemImpl; // Implementations for `*Eq` operations. #[feature("deprecated-op-assign-traits")] mod op_eq_by_op { - pub impl AddEqImpl> of core::traits::AddEq { + pub impl AddEqImpl> of crate::traits::AddEq { fn add_eq(ref self: T, other: T) { self = Add::add(self, other); } } - pub impl SubEqImpl> of core::traits::SubEq { + pub impl SubEqImpl> of crate::traits::SubEq { fn sub_eq(ref self: T, other: T) { self = Sub::sub(self, other); } } - pub impl MulEqImpl> of core::traits::MulEq { + pub impl MulEqImpl> of crate::traits::MulEq { fn mul_eq(ref self: T, other: T) { self = Mul::mul(self, other); } } - pub impl DivEqImpl> of core::traits::DivEq { + pub impl DivEqImpl> of crate::traits::DivEq { fn div_eq(ref self: T, other: T) { self = Div::div(self, other); } } - pub impl RemEqImpl> of core::traits::RemEq { + pub impl RemEqImpl> of crate::traits::RemEq { fn rem_eq(ref self: T, other: T) { self = Rem::rem(self, other); } @@ -2364,21 +2364,21 @@ impl U256DivEq = op_eq_by_op::DivEqImpl; impl U256RemEq = op_eq_by_op::RemEqImpl; // Zeroable impls -pub(crate) impl U8Zeroable = core::zeroable::zero_based::ZeroableImpl; -pub(crate) impl U16Zeroable = core::zeroable::zero_based::ZeroableImpl; -pub(crate) impl U32Zeroable = core::zeroable::zero_based::ZeroableImpl; -pub(crate) impl U64Zeroable = core::zeroable::zero_based::ZeroableImpl; -pub(crate) impl U128Zeroable = core::zeroable::zero_based::ZeroableImpl; -pub(crate) impl U256Zeroable = core::zeroable::zero_based::ZeroableImpl; - -impl I128BitSize of core::num::traits::BitSize { +pub(crate) impl U8Zeroable = crate::zeroable::zero_based::ZeroableImpl; +pub(crate) impl U16Zeroable = crate::zeroable::zero_based::ZeroableImpl; +pub(crate) impl U32Zeroable = crate::zeroable::zero_based::ZeroableImpl; +pub(crate) impl U64Zeroable = crate::zeroable::zero_based::ZeroableImpl; +pub(crate) impl U128Zeroable = crate::zeroable::zero_based::ZeroableImpl; +pub(crate) impl U256Zeroable = crate::zeroable::zero_based::ZeroableImpl; + +impl I128BitSize of crate::num::traits::BitSize { fn bits() -> usize { 128 } } // Zero trait implementations -impl U8Zero of core::num::traits::Zero { +impl U8Zero of crate::num::traits::Zero { fn zero() -> u8 { 0 } @@ -2392,7 +2392,7 @@ impl U8Zero of core::num::traits::Zero { } } -impl U16Zero of core::num::traits::Zero { +impl U16Zero of crate::num::traits::Zero { fn zero() -> u16 { 0 } @@ -2406,7 +2406,7 @@ impl U16Zero of core::num::traits::Zero { } } -impl U32Zero of core::num::traits::Zero { +impl U32Zero of crate::num::traits::Zero { fn zero() -> u32 { 0 } @@ -2420,7 +2420,7 @@ impl U32Zero of core::num::traits::Zero { } } -impl U64Zero of core::num::traits::Zero { +impl U64Zero of crate::num::traits::Zero { fn zero() -> u64 { 0 } @@ -2434,7 +2434,7 @@ impl U64Zero of core::num::traits::Zero { } } -impl U128Zero of core::num::traits::Zero { +impl U128Zero of crate::num::traits::Zero { fn zero() -> u128 { 0 } @@ -2448,7 +2448,7 @@ impl U128Zero of core::num::traits::Zero { } } -impl U256Zero of core::num::traits::Zero { +impl U256Zero of crate::num::traits::Zero { fn zero() -> u256 { 0 } @@ -2462,7 +2462,7 @@ impl U256Zero of core::num::traits::Zero { } } -impl I8Zero of core::num::traits::Zero { +impl I8Zero of crate::num::traits::Zero { fn zero() -> i8 { 0 } @@ -2476,7 +2476,7 @@ impl I8Zero of core::num::traits::Zero { } } -impl I16Zero of core::num::traits::Zero { +impl I16Zero of crate::num::traits::Zero { fn zero() -> i16 { 0 } @@ -2490,7 +2490,7 @@ impl I16Zero of core::num::traits::Zero { } } -impl I32Zero of core::num::traits::Zero { +impl I32Zero of crate::num::traits::Zero { fn zero() -> i32 { 0 } @@ -2504,7 +2504,7 @@ impl I32Zero of core::num::traits::Zero { } } -impl I64Zero of core::num::traits::Zero { +impl I64Zero of crate::num::traits::Zero { fn zero() -> i64 { 0 } @@ -2518,7 +2518,7 @@ impl I64Zero of core::num::traits::Zero { } } -impl I128Zero of core::num::traits::Zero { +impl I128Zero of crate::num::traits::Zero { fn zero() -> i128 { 0 } @@ -2534,7 +2534,7 @@ impl I128Zero of core::num::traits::Zero { // One trait implementations -impl U8One of core::num::traits::One { +impl U8One of crate::num::traits::One { fn one() -> u8 { 1 } @@ -2548,7 +2548,7 @@ impl U8One of core::num::traits::One { } } -impl U16One of core::num::traits::One { +impl U16One of crate::num::traits::One { fn one() -> u16 { 1 } @@ -2562,7 +2562,7 @@ impl U16One of core::num::traits::One { } } -impl U32One of core::num::traits::One { +impl U32One of crate::num::traits::One { fn one() -> u32 { 1 } @@ -2576,7 +2576,7 @@ impl U32One of core::num::traits::One { } } -impl U64One of core::num::traits::One { +impl U64One of crate::num::traits::One { fn one() -> u64 { 1 } @@ -2590,7 +2590,7 @@ impl U64One of core::num::traits::One { } } -impl U128One of core::num::traits::One { +impl U128One of crate::num::traits::One { fn one() -> u128 { 1 } @@ -2604,7 +2604,7 @@ impl U128One of core::num::traits::One { } } -impl U256One of core::num::traits::One { +impl U256One of crate::num::traits::One { fn one() -> u256 { 1 } @@ -2618,7 +2618,7 @@ impl U256One of core::num::traits::One { } } -impl I8One of core::num::traits::One { +impl I8One of crate::num::traits::One { fn one() -> i8 { 1 } @@ -2634,7 +2634,7 @@ impl I8One of core::num::traits::One { } } -impl I16One of core::num::traits::One { +impl I16One of crate::num::traits::One { fn one() -> i16 { 1 } @@ -2650,7 +2650,7 @@ impl I16One of core::num::traits::One { } } -impl I32One of core::num::traits::One { +impl I32One of crate::num::traits::One { fn one() -> i32 { 1 } @@ -2666,7 +2666,7 @@ impl I32One of core::num::traits::One { } } -impl I64One of core::num::traits::One { +impl I64One of crate::num::traits::One { fn one() -> i64 { 1 } @@ -2682,7 +2682,7 @@ impl I64One of core::num::traits::One { } } -impl I128One of core::num::traits::One { +impl I128One of crate::num::traits::One { fn one() -> i128 { 1 } @@ -2699,7 +2699,7 @@ impl I128One of core::num::traits::One { } // OverflowingAdd implementations -impl U8OverflowingAdd of core::num::traits::OverflowingAdd { +impl U8OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: u8, v: u8) -> (u8, bool) { match u8_overflowing_add(self, v) { Result::Ok(x) => (x, false), @@ -2708,7 +2708,7 @@ impl U8OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl U16OverflowingAdd of core::num::traits::OverflowingAdd { +impl U16OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: u16, v: u16) -> (u16, bool) { match u16_overflowing_add(self, v) { Result::Ok(x) => (x, false), @@ -2717,7 +2717,7 @@ impl U16OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl U32OverflowingAdd of core::num::traits::OverflowingAdd { +impl U32OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: u32, v: u32) -> (u32, bool) { match u32_overflowing_add(self, v) { Result::Ok(x) => (x, false), @@ -2726,7 +2726,7 @@ impl U32OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl U64OverflowingAdd of core::num::traits::OverflowingAdd { +impl U64OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: u64, v: u64) -> (u64, bool) { match u64_overflowing_add(self, v) { Result::Ok(x) => (x, false), @@ -2735,7 +2735,7 @@ impl U64OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl U128OverflowingAdd of core::num::traits::OverflowingAdd { +impl U128OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: u128, v: u128) -> (u128, bool) { match u128_overflowing_add(self, v) { Result::Ok(x) => (x, false), @@ -2744,13 +2744,13 @@ impl U128OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl U256OverflowingAdd of core::num::traits::OverflowingAdd { +impl U256OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: u256, v: u256) -> (u256, bool) { u256_overflowing_add(self, v) } } -impl I8OverflowingAdd of core::num::traits::OverflowingAdd { +impl I8OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: i8, v: i8) -> (i8, bool) { match i8_overflowing_add_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2760,7 +2760,7 @@ impl I8OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl I16OverflowingAdd of core::num::traits::OverflowingAdd { +impl I16OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: i16, v: i16) -> (i16, bool) { match i16_overflowing_add_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2770,7 +2770,7 @@ impl I16OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl I32OverflowingAdd of core::num::traits::OverflowingAdd { +impl I32OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: i32, v: i32) -> (i32, bool) { match i32_overflowing_add_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2780,7 +2780,7 @@ impl I32OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl I64OverflowingAdd of core::num::traits::OverflowingAdd { +impl I64OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: i64, v: i64) -> (i64, bool) { match i64_overflowing_add_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2790,7 +2790,7 @@ impl I64OverflowingAdd of core::num::traits::OverflowingAdd { } } -impl I128OverflowingAdd of core::num::traits::OverflowingAdd { +impl I128OverflowingAdd of crate::num::traits::OverflowingAdd { fn overflowing_add(self: i128, v: i128) -> (i128, bool) { match i128_overflowing_add_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2801,7 +2801,7 @@ impl I128OverflowingAdd of core::num::traits::OverflowingAdd { } // OverflowingSub implementations -impl U8OverflowingSub of core::num::traits::OverflowingSub { +impl U8OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: u8, v: u8) -> (u8, bool) { match u8_overflowing_sub(self, v) { Result::Ok(x) => (x, false), @@ -2810,7 +2810,7 @@ impl U8OverflowingSub of core::num::traits::OverflowingSub { } } -impl U16OverflowingSub of core::num::traits::OverflowingSub { +impl U16OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: u16, v: u16) -> (u16, bool) { match u16_overflowing_sub(self, v) { Result::Ok(x) => (x, false), @@ -2819,7 +2819,7 @@ impl U16OverflowingSub of core::num::traits::OverflowingSub { } } -impl U32OverflowingSub of core::num::traits::OverflowingSub { +impl U32OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: u32, v: u32) -> (u32, bool) { match u32_overflowing_sub(self, v) { Result::Ok(x) => (x, false), @@ -2828,7 +2828,7 @@ impl U32OverflowingSub of core::num::traits::OverflowingSub { } } -impl U64OverflowingSub of core::num::traits::OverflowingSub { +impl U64OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: u64, v: u64) -> (u64, bool) { match u64_overflowing_sub(self, v) { Result::Ok(x) => (x, false), @@ -2837,7 +2837,7 @@ impl U64OverflowingSub of core::num::traits::OverflowingSub { } } -impl U128OverflowingSub of core::num::traits::OverflowingSub { +impl U128OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: u128, v: u128) -> (u128, bool) { match u128_overflowing_sub(self, v) { Result::Ok(x) => (x, false), @@ -2846,13 +2846,13 @@ impl U128OverflowingSub of core::num::traits::OverflowingSub { } } -impl U256OverflowingSub of core::num::traits::OverflowingSub { +impl U256OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: u256, v: u256) -> (u256, bool) { u256_overflowing_sub(self, v) } } -impl I8OverflowingSub of core::num::traits::OverflowingSub { +impl I8OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: i8, v: i8) -> (i8, bool) { match i8_overflowing_sub_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2862,7 +2862,7 @@ impl I8OverflowingSub of core::num::traits::OverflowingSub { } } -impl I16OverflowingSub of core::num::traits::OverflowingSub { +impl I16OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: i16, v: i16) -> (i16, bool) { match i16_overflowing_sub_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2872,7 +2872,7 @@ impl I16OverflowingSub of core::num::traits::OverflowingSub { } } -impl I32OverflowingSub of core::num::traits::OverflowingSub { +impl I32OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: i32, v: i32) -> (i32, bool) { match i32_overflowing_sub_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2882,7 +2882,7 @@ impl I32OverflowingSub of core::num::traits::OverflowingSub { } } -impl I64OverflowingSub of core::num::traits::OverflowingSub { +impl I64OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: i64, v: i64) -> (i64, bool) { match i64_overflowing_sub_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2892,7 +2892,7 @@ impl I64OverflowingSub of core::num::traits::OverflowingSub { } } -impl I128OverflowingSub of core::num::traits::OverflowingSub { +impl I128OverflowingSub of crate::num::traits::OverflowingSub { fn overflowing_sub(self: i128, v: i128) -> (i128, bool) { match i128_overflowing_sub_impl(self, v) { SignedIntegerResult::InRange(x) => (x, false), @@ -2903,216 +2903,216 @@ impl I128OverflowingSub of core::num::traits::OverflowingSub { } // OverflowingMul implementations -impl U8OverflowingMul of core::num::traits::OverflowingMul { +impl U8OverflowingMul of crate::num::traits::OverflowingMul { fn overflowing_mul(self: u8, v: u8) -> (u8, bool) { let wide_result = u8_wide_mul(self, v); - let MASK: u16 = core::num::traits::Bounded::::MAX.into(); + let MASK: u16 = crate::num::traits::Bounded::::MAX.into(); let (v_low, _, v_with_low_masked) = u16_bitwise(wide_result, MASK); (v_low.try_into().unwrap(), v_with_low_masked != MASK) } } -impl U16OverflowingMul of core::num::traits::OverflowingMul { +impl U16OverflowingMul of crate::num::traits::OverflowingMul { fn overflowing_mul(self: u16, v: u16) -> (u16, bool) { let wide_result = u16_wide_mul(self, v); - let MASK: u32 = core::num::traits::Bounded::::MAX.into(); + let MASK: u32 = crate::num::traits::Bounded::::MAX.into(); let (v_low, _, v_with_low_masked) = u32_bitwise(wide_result, MASK); (v_low.try_into().unwrap(), v_with_low_masked != MASK) } } -impl U32OverflowingMul of core::num::traits::OverflowingMul { +impl U32OverflowingMul of crate::num::traits::OverflowingMul { fn overflowing_mul(self: u32, v: u32) -> (u32, bool) { let wide_result = u32_wide_mul(self, v); - let MASK: u64 = core::num::traits::Bounded::::MAX.into(); + let MASK: u64 = crate::num::traits::Bounded::::MAX.into(); let (v_low, _, v_with_low_masked) = u64_bitwise(wide_result, MASK); (v_low.try_into().unwrap(), v_with_low_masked != MASK) } } -impl U64OverflowingMul of core::num::traits::OverflowingMul { +impl U64OverflowingMul of crate::num::traits::OverflowingMul { fn overflowing_mul(self: u64, v: u64) -> (u64, bool) { let wide_result = u64_wide_mul(self, v); - let MASK: u128 = core::num::traits::Bounded::::MAX.into(); + let MASK: u128 = crate::num::traits::Bounded::::MAX.into(); let (v_low, _, v_with_low_masked) = bitwise(wide_result, MASK); (v_low.try_into().unwrap(), v_with_low_masked != MASK) } } -impl U128OverflowingMul of core::num::traits::OverflowingMul { +impl U128OverflowingMul of crate::num::traits::OverflowingMul { fn overflowing_mul(self: u128, v: u128) -> (u128, bool) { u128_overflowing_mul(self, v) } } -impl U256OverflowingMul of core::num::traits::OverflowingMul { +impl U256OverflowingMul of crate::num::traits::OverflowingMul { fn overflowing_mul(self: u256, v: u256) -> (u256, bool) { u256_overflowing_mul(self, v) } } /// WrappingAdd implementations -impl U8WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl U16WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl U32WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl U64WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl U128WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl U256WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl I8WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl I16WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl I32WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl I64WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; -impl I128WrappingAdd = core::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U8WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U16WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U32WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U64WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U128WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl U256WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I8WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I16WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I32WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I64WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; +impl I128WrappingAdd = crate::num::traits::ops::wrapping::overflow_based::TWrappingAdd; /// WrappingSub implementations -impl U8WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl U16WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl U32WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl U64WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl U128WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl U256WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl I8WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl I16WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl I32WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl I64WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; -impl I128WrappingSub = core::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U8WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U16WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U32WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U64WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U128WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl U256WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I8WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I16WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I32WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I64WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; +impl I128WrappingSub = crate::num::traits::ops::wrapping::overflow_based::TWrappingSub; /// WrappingMul implementations -impl U8WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; -impl U16WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; -impl U32WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; -impl U64WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; -impl U128WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; -impl U256WrappingMul = core::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U8WrappingMul = crate::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U16WrappingMul = crate::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U32WrappingMul = crate::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U64WrappingMul = crate::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U128WrappingMul = crate::num::traits::ops::wrapping::overflow_based::TWrappingMul; +impl U256WrappingMul = crate::num::traits::ops::wrapping::overflow_based::TWrappingMul; // CheckedAdd implementations -impl U8CheckedAdd of core::num::traits::CheckedAdd { +impl U8CheckedAdd of crate::num::traits::CheckedAdd { fn checked_add(self: u8, v: u8) -> Option { u8_checked_add(self, v) } } -impl U16CheckedAdd of core::num::traits::CheckedAdd { +impl U16CheckedAdd of crate::num::traits::CheckedAdd { fn checked_add(self: u16, v: u16) -> Option { u16_checked_add(self, v) } } -impl U32CheckedAdd of core::num::traits::CheckedAdd { +impl U32CheckedAdd of crate::num::traits::CheckedAdd { fn checked_add(self: u32, v: u32) -> Option { u32_checked_add(self, v) } } -impl U64CheckedAdd of core::num::traits::CheckedAdd { +impl U64CheckedAdd of crate::num::traits::CheckedAdd { fn checked_add(self: u64, v: u64) -> Option { u64_checked_add(self, v) } } -impl U128CheckedAdd of core::num::traits::CheckedAdd { +impl U128CheckedAdd of crate::num::traits::CheckedAdd { fn checked_add(self: u128, v: u128) -> Option { u128_checked_add(self, v) } } -impl U256CheckedAdd of core::num::traits::CheckedAdd { +impl U256CheckedAdd of crate::num::traits::CheckedAdd { fn checked_add(self: u256, v: u256) -> Option { u256_checked_add(self, v) } } -impl I8CheckedAdd = core::num::traits::ops::checked::overflow_based::TCheckedAdd; -impl I16CheckedAdd = core::num::traits::ops::checked::overflow_based::TCheckedAdd; -impl I32CheckedAdd = core::num::traits::ops::checked::overflow_based::TCheckedAdd; -impl I64CheckedAdd = core::num::traits::ops::checked::overflow_based::TCheckedAdd; -impl I128CheckedAdd = core::num::traits::ops::checked::overflow_based::TCheckedAdd; +impl I8CheckedAdd = crate::num::traits::ops::checked::overflow_based::TCheckedAdd; +impl I16CheckedAdd = crate::num::traits::ops::checked::overflow_based::TCheckedAdd; +impl I32CheckedAdd = crate::num::traits::ops::checked::overflow_based::TCheckedAdd; +impl I64CheckedAdd = crate::num::traits::ops::checked::overflow_based::TCheckedAdd; +impl I128CheckedAdd = crate::num::traits::ops::checked::overflow_based::TCheckedAdd; // CheckedSub implementations -impl U8CheckedSub of core::num::traits::CheckedSub { +impl U8CheckedSub of crate::num::traits::CheckedSub { fn checked_sub(self: u8, v: u8) -> Option { u8_checked_sub(self, v) } } -impl U16CheckedSub of core::num::traits::CheckedSub { +impl U16CheckedSub of crate::num::traits::CheckedSub { fn checked_sub(self: u16, v: u16) -> Option { u16_checked_sub(self, v) } } -impl U32CheckedSub of core::num::traits::CheckedSub { +impl U32CheckedSub of crate::num::traits::CheckedSub { fn checked_sub(self: u32, v: u32) -> Option { u32_checked_sub(self, v) } } -impl U64CheckedSub of core::num::traits::CheckedSub { +impl U64CheckedSub of crate::num::traits::CheckedSub { fn checked_sub(self: u64, v: u64) -> Option { u64_checked_sub(self, v) } } -impl U128CheckedSub of core::num::traits::CheckedSub { +impl U128CheckedSub of crate::num::traits::CheckedSub { fn checked_sub(self: u128, v: u128) -> Option { u128_checked_sub(self, v) } } -impl U256CheckedSub of core::num::traits::CheckedSub { +impl U256CheckedSub of crate::num::traits::CheckedSub { fn checked_sub(self: u256, v: u256) -> Option { u256_checked_sub(self, v) } } -impl I8CheckedSub = core::num::traits::ops::checked::overflow_based::TCheckedSub; -impl I16CheckedSub = core::num::traits::ops::checked::overflow_based::TCheckedSub; -impl I32CheckedSub = core::num::traits::ops::checked::overflow_based::TCheckedSub; -impl I64CheckedSub = core::num::traits::ops::checked::overflow_based::TCheckedSub; -impl I128CheckedSub = core::num::traits::ops::checked::overflow_based::TCheckedSub; +impl I8CheckedSub = crate::num::traits::ops::checked::overflow_based::TCheckedSub; +impl I16CheckedSub = crate::num::traits::ops::checked::overflow_based::TCheckedSub; +impl I32CheckedSub = crate::num::traits::ops::checked::overflow_based::TCheckedSub; +impl I64CheckedSub = crate::num::traits::ops::checked::overflow_based::TCheckedSub; +impl I128CheckedSub = crate::num::traits::ops::checked::overflow_based::TCheckedSub; // CheckedMul implementations -impl U8CheckedMul = core::num::traits::ops::checked::overflow_based::TCheckedMul; -impl U16CheckedMul = core::num::traits::ops::checked::overflow_based::TCheckedMul; -impl U32CheckedMul = core::num::traits::ops::checked::overflow_based::TCheckedMul; -impl U64CheckedMul = core::num::traits::ops::checked::overflow_based::TCheckedMul; -impl U128CheckedMul = core::num::traits::ops::checked::overflow_based::TCheckedMul; -impl U256CheckedMul = core::num::traits::ops::checked::overflow_based::TCheckedMul; +impl U8CheckedMul = crate::num::traits::ops::checked::overflow_based::TCheckedMul; +impl U16CheckedMul = crate::num::traits::ops::checked::overflow_based::TCheckedMul; +impl U32CheckedMul = crate::num::traits::ops::checked::overflow_based::TCheckedMul; +impl U64CheckedMul = crate::num::traits::ops::checked::overflow_based::TCheckedMul; +impl U128CheckedMul = crate::num::traits::ops::checked::overflow_based::TCheckedMul; +impl U256CheckedMul = crate::num::traits::ops::checked::overflow_based::TCheckedMul; // SaturatingAdd implementations -impl U8SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl U16SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl U32SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl U64SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl U128SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl U256SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl I8SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl I16SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl I32SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl I64SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; -impl I128SaturatingAdd = core::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl U8SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl U16SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl U32SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl U64SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl U128SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl U256SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl I8SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl I16SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl I32SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl I64SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; +impl I128SaturatingAdd = crate::num::traits::ops::saturating::overflow_based::TSaturatingAdd; // SaturatingSub implementations -impl U8SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl U16SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl U32SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl U64SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl U128SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl U256SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl I8SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl I16SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl I32SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl I64SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; -impl I128SaturatingSub = core::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl U8SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl U16SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl U32SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl U64SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl U128SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl U256SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl I8SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl I16SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl I32SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl I64SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; +impl I128SaturatingSub = crate::num::traits::ops::saturating::overflow_based::TSaturatingSub; // SaturatingMul implementations -impl U8SaturatingMul = core::num::traits::ops::saturating::overflow_based::TSaturatingMul; -impl U16SaturatingMul = core::num::traits::ops::saturating::overflow_based::TSaturatingMul; -impl U32SaturatingMul = core::num::traits::ops::saturating::overflow_based::TSaturatingMul; -impl U64SaturatingMul = core::num::traits::ops::saturating::overflow_based::TSaturatingMul; -impl U128SaturatingMul = core::num::traits::ops::saturating::overflow_based::TSaturatingMul; -impl U256SaturatingMul = core::num::traits::ops::saturating::overflow_based::TSaturatingMul; +impl U8SaturatingMul = crate::num::traits::ops::saturating::overflow_based::TSaturatingMul; +impl U16SaturatingMul = crate::num::traits::ops::saturating::overflow_based::TSaturatingMul; +impl U32SaturatingMul = crate::num::traits::ops::saturating::overflow_based::TSaturatingMul; +impl U64SaturatingMul = crate::num::traits::ops::saturating::overflow_based::TSaturatingMul; +impl U128SaturatingMul = crate::num::traits::ops::saturating::overflow_based::TSaturatingMul; +impl U256SaturatingMul = crate::num::traits::ops::saturating::overflow_based::TSaturatingMul; /// Internal trait for easier finding of absolute values. diff --git a/corelib/src/internal/bounded_int.cairo b/corelib/src/internal/bounded_int.cairo index b542aef38d2..f67aad4102b 100644 --- a/corelib/src/internal/bounded_int.cairo +++ b/corelib/src/internal/bounded_int.cairo @@ -1,12 +1,12 @@ -use core::integer::{downcast, upcast}; -use core::RangeCheck; +use crate::integer::{downcast, upcast}; +use crate::RangeCheck; #[derive(Copy, Drop)] pub(crate) extern type BoundedInt; impl NumericLiteralBoundedInt< const MIN: felt252, const MAX: felt252 -> of core::integer::NumericLiteral>; +> of crate::integer::NumericLiteral>; impl BoundedIntIntoFelt252< const MIN: felt252, const MAX: felt252 @@ -27,7 +27,7 @@ impl Felt252TryIntoBoundedInt< } impl BoundedIntSerde = - core::serde::into_felt252_based::SerdeImpl>; + crate::serde::into_felt252_based::SerdeImpl>; impl BoundedIntPartialEq< const MIN: felt252, const MAX: felt252 @@ -39,7 +39,7 @@ impl BoundedIntPartialEq< } impl BoundedIntDebug = - core::fmt::into_felt252_based::DebugImpl>; + crate::fmt::into_felt252_based::DebugImpl>; /// A helper trait for adding two `BoundedInt` instances. pub trait AddHelper { diff --git a/corelib/src/keccak.cairo b/corelib/src/keccak.cairo index 7ee30d2d738..1389f6c9df3 100644 --- a/corelib/src/keccak.cairo +++ b/corelib/src/keccak.cairo @@ -1,7 +1,7 @@ -use core::array::{Span, ArrayTrait, SpanTrait}; -use core::traits::TryInto; -use core::option::OptionTrait; -use core::starknet::SyscallResultTrait; +use crate::array::{Span, ArrayTrait, SpanTrait}; +use crate::traits::TryInto; +use crate::option::OptionTrait; +use crate::starknet::SyscallResultTrait; const KECCAK_FULL_RATE_IN_BYTES: usize = 136; const KECCAK_FULL_RATE_IN_U64S: usize = 17; @@ -13,7 +13,7 @@ fn u128_to_u64(input: u128) -> u64 { } fn u128_split(input: u128) -> (u64, u64) { - let (high, low) = core::integer::u128_safe_divmod( + let (high, low) = crate::integer::u128_safe_divmod( input, 0x10000000000000000_u128.try_into().unwrap() ); @@ -48,10 +48,10 @@ pub fn keccak_u256s_le_inputs(mut input: Span) -> u256 { } fn keccak_add_u256_be(ref keccak_input: Array::, v: u256) { - let (high, low) = u128_split(core::integer::u128_byte_reverse(v.high)); + let (high, low) = u128_split(crate::integer::u128_byte_reverse(v.high)); keccak_input.append(low); keccak_input.append(high); - let (high, low) = u128_split(core::integer::u128_byte_reverse(v.low)); + let (high, low) = u128_split(crate::integer::u128_byte_reverse(v.low)); keccak_input.append(low); keccak_input.append(high); } @@ -94,7 +94,9 @@ pub fn cairo_keccak( fn add_padding(ref input: Array, last_input_word: u64, last_input_num_bytes: usize) { let words_divisor = KECCAK_FULL_RATE_IN_U64S.try_into().unwrap(); // `last_block_num_full_words` is in range [0, KECCAK_FULL_RATE_IN_U64S - 1] - let (_, last_block_num_full_words) = core::integer::u32_safe_divmod(input.len(), words_divisor); + let (_, last_block_num_full_words) = crate::integer::u32_safe_divmod( + input.len(), words_divisor + ); // The first word to append would be of the form // 0x1<`last_input_num_bytes` LSB bytes of `last_input_word`>. @@ -119,9 +121,9 @@ fn add_padding(ref input: Array, last_input_word: u64, last_input_num_bytes } else if last_input_num_bytes == 7 { 0x100000000000000 } else { - core::panic_with_felt252('Keccak last input word >7b') + crate::panic_with_felt252('Keccak last input word >7b') }; - let (_, r) = core::integer::u64_safe_divmod( + let (_, r) = crate::integer::u64_safe_divmod( last_input_word, first_padding_byte_part.try_into().unwrap() ); first_padding_byte_part + r diff --git a/corelib/src/lib.cairo b/corelib/src/lib.cairo index 554e6ddbda9..d0d6b13d06c 100644 --- a/corelib/src/lib.cairo +++ b/corelib/src/lib.cairo @@ -123,7 +123,7 @@ impl Felt252Serde of Serde { } fn deserialize(ref serialized: Span) -> Option { let mut snapshot = serialized.snapshot; - match core::array::array_snapshot_pop_front(ref snapshot) { + match crate::array::array_snapshot_pop_front(ref snapshot) { Option::Some(x) => { serialized = Span { snapshot }; Option::Some(*x.unbox()) diff --git a/corelib/src/math.cairo b/corelib/src/math.cairo index 881514e4a02..2a3a9de14d9 100644 --- a/corelib/src/math.cairo +++ b/corelib/src/math.cairo @@ -1,10 +1,10 @@ #[allow(unused_imports)] -use core::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable}; +use crate::zeroable::{IsZeroResult, NonZeroIntoImpl, Zeroable}; #[allow(unused_imports)] -use core::traits::{Into, TryInto}; -use core::option::OptionTrait; -use core::integer::{u256_wide_mul, u512_safe_div_rem_by_u256, U128MulGuarantee}; -use core::RangeCheck; +use crate::traits::{Into, TryInto}; +use crate::option::OptionTrait; +use crate::integer::{u256_wide_mul, u512_safe_div_rem_by_u256, U128MulGuarantee}; +use crate::RangeCheck; // TODO(yuval): use signed integers once supported. // TODO(yuval): use a single impl of a trait with associated impls, once associated impls are @@ -140,7 +140,7 @@ trait Oneable { pub(crate) mod one_based { pub(crate) impl OneableImpl< - T, impl OneImpl: core::num::traits::One, +Drop, +Copy + T, impl OneImpl: crate::num::traits::One, +Drop, +Copy > of super::Oneable { fn one() -> T { OneImpl::one() diff --git a/corelib/src/nullable.cairo b/corelib/src/nullable.cairo index 9d505ca451a..b6b463e323f 100644 --- a/corelib/src/nullable.cairo +++ b/corelib/src/nullable.cairo @@ -1,6 +1,6 @@ -use core::box::BoxTrait; -use core::traits::Default; -use core::traits::Felt252DictValue; +use crate::box::BoxTrait; +use crate::traits::Default; +use crate::traits::Felt252DictValue; #[derive(Copy, Drop)] pub extern type Nullable; @@ -15,11 +15,11 @@ pub(crate) extern fn nullable_from_box(value: Box) -> Nullable nopanic; pub extern fn match_nullable(value: Nullable) -> FromNullableResult nopanic; extern fn nullable_forward_snapshot(value: @Nullable) -> Nullable<@T> nopanic; -impl NullableDeref of core::ops::Deref> { +impl NullableDeref of crate::ops::Deref> { type Target = T; fn deref(self: Nullable) -> T { match match_nullable(self) { - FromNullableResult::Null => core::panic_with_felt252('Attempted to deref null value'), + FromNullableResult::Null => crate::panic_with_felt252('Attempted to deref null value'), FromNullableResult::NotNull(value) => value.unbox(), } } @@ -69,8 +69,8 @@ impl NullableFelt252DictValue of Felt252DictValue> { } } -impl NullableDebug> of core::fmt::Debug> { - fn fmt(self: @Nullable, ref f: core::fmt::Formatter) -> Result<(), core::fmt::Error> { +impl NullableDebug> of crate::fmt::Debug> { + fn fmt(self: @Nullable, ref f: crate::fmt::Formatter) -> Result<(), crate::fmt::Error> { match match_nullable(self.as_snapshot()) { FromNullableResult::Null => write!(f, "null"), FromNullableResult::NotNull(value) => { diff --git a/corelib/src/num/traits/ops/checked.cairo b/corelib/src/num/traits/ops/checked.cairo index 1fecc921646..cb55056268c 100644 --- a/corelib/src/num/traits/ops/checked.cairo +++ b/corelib/src/num/traits/ops/checked.cairo @@ -23,8 +23,8 @@ pub trait CheckedMul { pub(crate) mod overflow_based { pub(crate) impl TCheckedAdd< - T, +Drop, +core::num::traits::OverflowingAdd - > of core::num::traits::CheckedAdd { + T, +Drop, +crate::num::traits::OverflowingAdd + > of crate::num::traits::CheckedAdd { fn checked_add(self: T, v: T) -> Option { let (result, overflow) = self.overflowing_add(v); match overflow { @@ -35,8 +35,8 @@ pub(crate) mod overflow_based { } pub(crate) impl TCheckedSub< - T, +Drop, +core::num::traits::OverflowingSub - > of core::num::traits::CheckedSub { + T, +Drop, +crate::num::traits::OverflowingSub + > of crate::num::traits::CheckedSub { fn checked_sub(self: T, v: T) -> Option { let (result, overflow) = self.overflowing_sub(v); match overflow { @@ -47,8 +47,8 @@ pub(crate) mod overflow_based { } pub(crate) impl TCheckedMul< - T, +Drop, +core::num::traits::OverflowingMul - > of core::num::traits::CheckedMul { + T, +Drop, +crate::num::traits::OverflowingMul + > of crate::num::traits::CheckedMul { fn checked_mul(self: T, v: T) -> Option { let (result, overflow) = self.overflowing_mul(v); match overflow { diff --git a/corelib/src/num/traits/ops/saturating.cairo b/corelib/src/num/traits/ops/saturating.cairo index dff09f4927f..72a764011bd 100644 --- a/corelib/src/num/traits/ops/saturating.cairo +++ b/corelib/src/num/traits/ops/saturating.cairo @@ -21,36 +21,36 @@ pub trait SaturatingMul { pub(crate) mod overflow_based { pub(crate) impl TSaturatingAdd< - T, +Drop, +core::num::traits::OverflowingAdd, +core::num::traits::Bounded - > of core::num::traits::SaturatingAdd { + T, +Drop, +crate::num::traits::OverflowingAdd, +crate::num::traits::Bounded + > of crate::num::traits::SaturatingAdd { fn saturating_add(self: T, other: T) -> T { let (result, overflow) = self.overflowing_add(other); match overflow { - true => core::num::traits::Bounded::MAX, + true => crate::num::traits::Bounded::MAX, false => result, } } } pub(crate) impl TSaturatingSub< - T, +Drop, +core::num::traits::OverflowingSub, +core::num::traits::Bounded - > of core::num::traits::SaturatingSub { + T, +Drop, +crate::num::traits::OverflowingSub, +crate::num::traits::Bounded + > of crate::num::traits::SaturatingSub { fn saturating_sub(self: T, other: T) -> T { let (result, overflow) = self.overflowing_sub(other); match overflow { - true => core::num::traits::Bounded::MIN, + true => crate::num::traits::Bounded::MIN, false => result, } } } pub(crate) impl TSaturatingMul< - T, +Drop, +core::num::traits::OverflowingMul, +core::num::traits::Bounded - > of core::num::traits::SaturatingMul { + T, +Drop, +crate::num::traits::OverflowingMul, +crate::num::traits::Bounded + > of crate::num::traits::SaturatingMul { fn saturating_mul(self: T, other: T) -> T { let (result, overflow) = self.overflowing_mul(other); match overflow { - true => core::num::traits::Bounded::MAX, + true => crate::num::traits::Bounded::MAX, false => result, } } diff --git a/corelib/src/num/traits/ops/sqrt.cairo b/corelib/src/num/traits/ops/sqrt.cairo index 6cc1e5c9eb2..545a3f4bfb4 100644 --- a/corelib/src/num/traits/ops/sqrt.cairo +++ b/corelib/src/num/traits/ops/sqrt.cairo @@ -9,41 +9,41 @@ pub trait Sqrt { impl SqrtU8 of Sqrt { type Target = u8; fn sqrt(self: u8) -> u8 { - core::integer::u8_sqrt(self) + crate::integer::u8_sqrt(self) } } impl SqrtU16 of Sqrt { type Target = u8; fn sqrt(self: u16) -> u8 { - core::integer::u16_sqrt(self) + crate::integer::u16_sqrt(self) } } impl SqrtU32 of Sqrt { type Target = u16; fn sqrt(self: u32) -> u16 { - core::integer::u32_sqrt(self) + crate::integer::u32_sqrt(self) } } impl SqrtU64 of Sqrt { type Target = u32; fn sqrt(self: u64) -> u32 { - core::integer::u64_sqrt(self) + crate::integer::u64_sqrt(self) } } impl SqrtU128 of Sqrt { type Target = u64; fn sqrt(self: u128) -> u64 { - core::integer::u128_sqrt(self) + crate::integer::u128_sqrt(self) } } impl SqrtU256 of Sqrt { type Target = u128; fn sqrt(self: u256) -> u128 { - core::integer::u256_sqrt(self) + crate::integer::u256_sqrt(self) } } diff --git a/corelib/src/num/traits/ops/widemul.cairo b/corelib/src/num/traits/ops/widemul.cairo index c69cc9f3358..b2e2563ed7f 100644 --- a/corelib/src/num/traits/ops/widemul.cairo +++ b/corelib/src/num/traits/ops/widemul.cairo @@ -9,70 +9,70 @@ pub trait WideMul { impl WideMulI8 of WideMul { type Target = i16; fn wide_mul(self: i8, other: i8) -> i16 { - core::integer::i8_wide_mul(self, other) + crate::integer::i8_wide_mul(self, other) } } impl WideMulI16 of WideMul { type Target = i32; fn wide_mul(self: i16, other: i16) -> i32 { - core::integer::i16_wide_mul(self, other) + crate::integer::i16_wide_mul(self, other) } } impl WideMulI32 of WideMul { type Target = i64; fn wide_mul(self: i32, other: i32) -> i64 { - core::integer::i32_wide_mul(self, other) + crate::integer::i32_wide_mul(self, other) } } impl WideMulI64 of WideMul { type Target = i128; fn wide_mul(self: i64, other: i64) -> i128 { - core::integer::i64_wide_mul(self, other) + crate::integer::i64_wide_mul(self, other) } } impl WideMulU8 of WideMul { type Target = u16; fn wide_mul(self: u8, other: u8) -> u16 { - core::integer::u8_wide_mul(self, other) + crate::integer::u8_wide_mul(self, other) } } impl WideMulU16 of WideMul { type Target = u32; fn wide_mul(self: u16, other: u16) -> u32 { - core::integer::u16_wide_mul(self, other) + crate::integer::u16_wide_mul(self, other) } } impl WideMulU32 of WideMul { type Target = u64; fn wide_mul(self: u32, other: u32) -> u64 { - core::integer::u32_wide_mul(self, other) + crate::integer::u32_wide_mul(self, other) } } impl WideMulU64 of WideMul { type Target = u128; fn wide_mul(self: u64, other: u64) -> u128 { - core::integer::u64_wide_mul(self, other) + crate::integer::u64_wide_mul(self, other) } } impl WideMulU128 of WideMul { type Target = u256; fn wide_mul(self: u128, other: u128) -> u256 { - let (high, low) = core::integer::u128_wide_mul(self, other); + let (high, low) = crate::integer::u128_wide_mul(self, other); u256 { low, high } } } impl WideMulU256 of WideMul { - type Target = core::integer::u512; - fn wide_mul(self: u256, other: u256) -> core::integer::u512 { - core::integer::u256_wide_mul(self, other) + type Target = crate::integer::u512; + fn wide_mul(self: u256, other: u256) -> crate::integer::u512 { + crate::integer::u256_wide_mul(self, other) } } diff --git a/corelib/src/num/traits/ops/widesquare.cairo b/corelib/src/num/traits/ops/widesquare.cairo index d0c707965d6..5a151df0b99 100644 --- a/corelib/src/num/traits/ops/widesquare.cairo +++ b/corelib/src/num/traits/ops/widesquare.cairo @@ -1,4 +1,4 @@ -use core::num::traits::WideMul; +use crate::num::traits::WideMul; /// A trait for a type that can be squared to produce a wider type. pub trait WideSquare { @@ -27,16 +27,16 @@ impl WideSquareU32 = wide_mul_based::TWideSquare; impl WideSquareU64 = wide_mul_based::TWideSquare; impl WideSquareU128 = wide_mul_based::TWideSquare; impl WideSquareU256 of WideSquare { - type Target = core::integer::u512; + type Target = crate::integer::u512; fn wide_square(self: u256) -> Self::Target { inner::u256_wide_square(self) } } mod inner { - use core::integer::{u512, u128_add_with_bounded_int_carry, upcast}; - use core::internal::bounded_int; - use core::num::traits::{WideSquare, WideMul, WrappingAdd}; + use crate::integer::{u512, u128_add_with_bounded_int_carry, upcast}; + use crate::internal::bounded_int; + use crate::num::traits::{WideSquare, WideMul, WrappingAdd}; pub fn u256_wide_square(value: u256) -> u512 { let u256 { high: limb1, low: limb0 } = value.low.wide_square(); diff --git a/corelib/src/num/traits/ops/wrapping.cairo b/corelib/src/num/traits/ops/wrapping.cairo index 0295d4a010e..1bf54199d97 100644 --- a/corelib/src/num/traits/ops/wrapping.cairo +++ b/corelib/src/num/traits/ops/wrapping.cairo @@ -21,8 +21,8 @@ pub trait WrappingMul { pub(crate) mod overflow_based { pub(crate) impl TWrappingAdd< - T, +core::num::traits::OverflowingAdd - > of core::num::traits::WrappingAdd { + T, +crate::num::traits::OverflowingAdd + > of crate::num::traits::WrappingAdd { fn wrapping_add(self: T, v: T) -> T { let (result, _) = self.overflowing_add(v); result @@ -30,8 +30,8 @@ pub(crate) mod overflow_based { } pub(crate) impl TWrappingSub< - T, +core::num::traits::OverflowingSub - > of core::num::traits::WrappingSub { + T, +crate::num::traits::OverflowingSub + > of crate::num::traits::WrappingSub { fn wrapping_sub(self: T, v: T) -> T { let (result, _) = self.overflowing_sub(v); result @@ -39,8 +39,8 @@ pub(crate) mod overflow_based { } pub(crate) impl TWrappingMul< - T, +core::num::traits::OverflowingMul - > of core::num::traits::WrappingMul { + T, +crate::num::traits::OverflowingMul + > of crate::num::traits::WrappingMul { fn wrapping_mul(self: T, v: T) -> T { let (result, _) = self.overflowing_mul(v); result diff --git a/corelib/src/ops/arith.cairo b/corelib/src/ops/arith.cairo index 2ad4bd4f36f..a111fcc6651 100644 --- a/corelib/src/ops/arith.cairo +++ b/corelib/src/ops/arith.cairo @@ -29,7 +29,7 @@ pub trait RemAssign { } #[feature("deprecated-op-assign-traits")] -use core::traits::{AddEq, SubEq, MulEq, DivEq, RemEq}; +use crate::traits::{AddEq, SubEq, MulEq, DivEq, RemEq}; impl DeprecatedAddAssign> of AddAssign { fn add_assign(ref self: T, rhs: T) { diff --git a/corelib/src/ops/index.cairo b/corelib/src/ops/index.cairo index f3913b3d8fd..0ce29fdc9b0 100644 --- a/corelib/src/ops/index.cairo +++ b/corelib/src/ops/index.cairo @@ -1,7 +1,7 @@ #[feature("deprecated-index-traits")] -use core::traits::IndexView as DeprecatedIndexView; +use crate::traits::IndexView as DeprecatedIndexView; #[feature("deprecated-index-traits")] -use core::traits::Index as DeprecatedIndex; +use crate::traits::Index as DeprecatedIndex; /// The following two traits are for implementing the [] operator. Only one should be implemented /// for each type. Both are not consuming of self, the first gets a snapshot of the object and @@ -15,7 +15,7 @@ pub trait IndexView { } impl DeprecatedIndexViewImpl< C, I, V, impl Deprecated: DeprecatedIndexView -> of core::ops::IndexView { +> of crate::ops::IndexView { type Target = V; fn index(self: @C, index: I) -> Self::Target { Deprecated::index(self, index) @@ -32,7 +32,7 @@ pub trait Index { #[feature("deprecated-index-traits")] impl DeprecatedIndexImpl< C, I, V, impl Deprecated: DeprecatedIndex -> of core::ops::Index { +> of crate::ops::Index { type Target = V; fn index(ref self: C, index: I) -> Self::Target { Deprecated::index(ref self, index) diff --git a/corelib/src/option.cairo b/corelib/src/option.cairo index a5223cb77bf..ad83ebea80e 100644 --- a/corelib/src/option.cairo +++ b/corelib/src/option.cairo @@ -46,7 +46,7 @@ pub impl OptionTraitImpl of OptionTrait { fn expect(self: Option, err: felt252) -> T { match self { Option::Some(x) => x, - Option::None => core::panic_with_felt252(err), + Option::None => crate::panic_with_felt252(err), } } diff --git a/corelib/src/panics.cairo b/corelib/src/panics.cairo index c6b49cc6e4b..fcccd890ca5 100644 --- a/corelib/src/panics.cairo +++ b/corelib/src/panics.cairo @@ -1,4 +1,4 @@ -use core::array::Array; +use crate::array::Array; pub struct Panic {} @@ -7,13 +7,13 @@ pub enum PanicResult { Err: (Panic, Array), } -pub extern fn panic(data: Array) -> core::never; +pub extern fn panic(data: Array) -> crate::never; /// Panics with the given ByteArray. That is, panics with an `Array` with /// `BYTE_ARRAY_MAGIC`, and then the serialized given ByteArray. #[inline(always)] -pub fn panic_with_byte_array(err: @ByteArray) -> core::never { - let mut serialized = array![core::byte_array::BYTE_ARRAY_MAGIC]; +pub fn panic_with_byte_array(err: @ByteArray) -> crate::never { + let mut serialized = array![crate::byte_array::BYTE_ARRAY_MAGIC]; err.serialize(ref serialized); panic(serialized) } diff --git a/corelib/src/pedersen.cairo b/corelib/src/pedersen.cairo index 8a5bf72a55e..d2c7a111151 100644 --- a/corelib/src/pedersen.cairo +++ b/corelib/src/pedersen.cairo @@ -18,7 +18,7 @@ pub impl PedersenImpl of PedersenTrait { } } -impl HashStateImpl of core::hash::HashStateTrait { +impl HashStateImpl of crate::hash::HashStateTrait { #[inline(always)] fn update(self: HashState, value: felt252) -> HashState { HashState { state: pedersen(self.state, value) } diff --git a/corelib/src/poseidon.cairo b/corelib/src/poseidon.cairo index 9540160e272..13ac33ab636 100644 --- a/corelib/src/poseidon.cairo +++ b/corelib/src/poseidon.cairo @@ -1,7 +1,7 @@ -use core::array::Span; -use core::array::SpanTrait; -use core::option::OptionTrait; -use core::hash::HashStateTrait; +use crate::array::Span; +use crate::array::SpanTrait; +use crate::option::OptionTrait; +use crate::hash::HashStateTrait; pub extern type Poseidon; @@ -63,12 +63,12 @@ impl HashStateImpl of HashStateTrait { /// To distinguish between different input sizes always pads with 1, and possibly with another 0 to /// complete to an even-sized input. pub fn poseidon_hash_span(mut span: Span) -> felt252 { - _poseidon_hash_span_inner(core::gas::get_builtin_costs(), (0, 0, 0), ref span) + _poseidon_hash_span_inner(crate::gas::get_builtin_costs(), (0, 0, 0), ref span) } /// Helper function for poseidon_hash_span. fn _poseidon_hash_span_inner( - builtin_costs: core::gas::BuiltinCosts, + builtin_costs: crate::gas::BuiltinCosts, state: (felt252, felt252, felt252), ref span: Span ) -> felt252 { @@ -82,6 +82,6 @@ fn _poseidon_hash_span_inner( Option::None => { return HashState { s0: s0 + x, s1, s2, odd: true }.finalize(); }, }; let next_state = hades_permutation(s0 + x, s1 + y, s2); - core::gas::withdraw_gas_all(builtin_costs).expect('Out of gas'); + crate::gas::withdraw_gas_all(builtin_costs).expect('Out of gas'); _poseidon_hash_span_inner(builtin_costs, next_state, ref span) } diff --git a/corelib/src/prelude/v2023_01.cairo b/corelib/src/prelude/v2023_01.cairo index e79e498621c..3cae7cec310 100644 --- a/corelib/src/prelude/v2023_01.cairo +++ b/corelib/src/prelude/v2023_01.cairo @@ -1,4 +1,4 @@ -use core::{ +use crate::{ BoolBitAnd, BoolBitOr, BoolBitXor, BoolFelt252DictValue, BoolIntoFelt252, BoolNot, BoolPartialEq, BoolSerde, Felt252Add, Felt252AddEq, Felt252Default, Felt252Felt252DictValue, Felt252Mul, Felt252MulEq, Felt252Neg, Felt252PartialEq, Felt252Serde, Felt252Sub, Felt252SubEq, @@ -7,32 +7,32 @@ use core::{ felt252_div, felt252_is_zero, felt252_mul, felt252_sub, never, panic_with_felt252, usize }; -use core::{array, array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}}; -use core::{box, box::{Box, BoxTrait}}; -use core::{ +use crate::{array, array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}}; +use crate::{box, box::{Box, BoxTrait}}; +use crate::{ bytes_31, bytes_31::{ Bytes31IndexView, Bytes31IntoFelt252, Bytes31Trait, Felt252TryIntoBytes31, bytes31, bytes31_const } }; -use core::{ +use crate::{ byte_array, byte_array::{ByteArray, ByteArrayIndexView, ByteArrayStringLiteral, ByteArrayTrait} }; -use core::{clone, clone::Clone}; -use core::cmp; -use core::debug; -use core::{ +use crate::{clone, clone::Clone}; +use crate::cmp; +use crate::debug; +use crate::{ dict, dict::{ Felt252Dict, Felt252DictTrait, SquashedFelt252Dict, felt252_dict_new, felt252_dict_squash } }; -use core::{ec, ec::{EcOp, EcPoint, EcState}}; -use core::ecdsa; -use core::{gas, gas::{BuiltinCosts, GasBuiltin, get_builtin_costs}}; -use core::hash; -use core::{ +use crate::{ec, ec::{EcOp, EcPoint, EcState}}; +use crate::ecdsa; +use crate::{gas, gas::{BuiltinCosts, GasBuiltin, get_builtin_costs}}; +use crate::hash; +use crate::{ integer, integer::{ Bitwise, Felt252IntoU256, Felt252TryIntoU128, Felt252TryIntoU16, Felt252TryIntoU32, @@ -44,22 +44,22 @@ use core::{ }; #[feature("corelib-internal-use")] #[deprecated(feature: "corelib-internal-use", note: "Use `core::num::traits::Sqrt` instead")] -use core::integer::{u128_sqrt, u256_sqrt}; -use core::internal; -use core::keccak; -use core::math; -use core::{nullable, nullable::{Nullable, NullableTrait, match_nullable, null, nullable_from_box}}; -use core::{option, option::{Option, OptionTrait}}; -use core::{panics, panics::{Panic, PanicResult, panic}}; -use core::{pedersen, pedersen::Pedersen}; -use core::{poseidon, poseidon::Poseidon}; -use core::{result, result::{Result, ResultTrait}}; -use core::{serde, serde::Serde}; -use core::{starknet, starknet::System}; -use core::{string, string::StringLiteral}; -use core::testing; -use core::to_byte_array; -use core::{ +use crate::integer::{u128_sqrt, u256_sqrt}; +use crate::internal; +use crate::keccak; +use crate::math; +use crate::{nullable, nullable::{Nullable, NullableTrait, match_nullable, null, nullable_from_box}}; +use crate::{option, option::{Option, OptionTrait}}; +use crate::{panics, panics::{Panic, PanicResult, panic}}; +use crate::{pedersen, pedersen::Pedersen}; +use crate::{poseidon, poseidon::Poseidon}; +use crate::{result, result::{Result, ResultTrait}}; +use crate::{serde, serde::Serde}; +use crate::{starknet, starknet::System}; +use crate::{string, string::StringLiteral}; +use crate::testing; +use crate::to_byte_array; +use crate::{ traits, traits::{ Add, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivRem, Drop, @@ -72,37 +72,37 @@ use core::{ feature: "deprecated-op-assign-traits", note: "Use `core::ops::AddAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::AddEq; +pub use crate::traits::AddEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::SubAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::SubEq; +pub use crate::traits::SubEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::MulAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::MulEq; +pub use crate::traits::MulEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::DivAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::DivEq; +pub use crate::traits::DivEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::RemAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::RemEq; +pub use crate::traits::RemEq; #[feature("deprecated-index-traits")] -use core::traits::Index; +use crate::traits::Index; #[feature("deprecated-index-traits")] -use core::traits::IndexView; -use core::{zeroable, zeroable::{NonZero, Zeroable}}; +use crate::traits::IndexView; +use crate::{zeroable, zeroable::{NonZero, Zeroable}}; #[cfg(test)] -use core::test; -pub use core::ops::Deref; +use crate::test; +pub use crate::ops::Deref; pub use starknet::storage::{ diff --git a/corelib/src/prelude/v2023_10.cairo b/corelib/src/prelude/v2023_10.cairo index f4e35947e89..28302085786 100644 --- a/corelib/src/prelude/v2023_10.cairo +++ b/corelib/src/prelude/v2023_10.cairo @@ -1,25 +1,25 @@ -pub use core::{RangeCheck, SegmentArena, assert, bool, felt252, usize}; +pub use crate::{RangeCheck, SegmentArena, assert, bool, felt252, usize}; -pub use core::array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}; -pub use core::box::{Box, BoxTrait}; -pub use core::bytes_31::{Bytes31Trait, bytes31}; -pub use core::byte_array::{ByteArray, ByteArrayTrait}; -pub use core::clone::Clone; -pub use core::dict::{Felt252Dict, Felt252DictTrait, SquashedFelt252Dict}; -pub use core::gas::GasBuiltin; -pub use core::integer::{Bitwise, i128, i16, i32, i64, i8, u128, u16, u256, u32, u64, u8}; -pub use core::keccak; -pub use core::math; -pub use core::nullable::{Nullable, NullableTrait}; -pub use core::option::{Option, OptionTrait}; -pub use core::panics::{Panic, PanicResult, panic}; -pub use core::pedersen::Pedersen; -pub use core::poseidon::Poseidon; -pub use core::result::{Result, ResultTrait}; -pub use core::serde::Serde; -pub use core::{starknet, starknet::System}; -pub use core::to_byte_array; -pub use core::traits::{ +pub use crate::array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}; +pub use crate::box::{Box, BoxTrait}; +pub use crate::bytes_31::{Bytes31Trait, bytes31}; +pub use crate::byte_array::{ByteArray, ByteArrayTrait}; +pub use crate::clone::Clone; +pub use crate::dict::{Felt252Dict, Felt252DictTrait, SquashedFelt252Dict}; +pub use crate::gas::GasBuiltin; +pub use crate::integer::{Bitwise, i128, i16, i32, i64, i8, u128, u16, u256, u32, u64, u8}; +pub use crate::keccak; +pub use crate::math; +pub use crate::nullable::{Nullable, NullableTrait}; +pub use crate::option::{Option, OptionTrait}; +pub use crate::panics::{Panic, PanicResult, panic}; +pub use crate::pedersen::Pedersen; +pub use crate::poseidon::Poseidon; +pub use crate::result::{Result, ResultTrait}; +pub use crate::serde::Serde; +pub use crate::{starknet, starknet::System}; +pub use crate::to_byte_array; +pub use crate::traits::{ Add, BitAnd, BitNot, BitOr, BitXor, Copy, Default, Destruct, Div, DivRem, Drop, Felt252DictValue, Into, Mul, Neg, Not, PanicDestruct, PartialEq, PartialOrd, Rem, Sub, TryInto }; @@ -29,40 +29,40 @@ pub use core::traits::{ feature: "deprecated-op-assign-traits", note: "Use `core::ops::AddAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::AddEq; +pub use crate::traits::AddEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::SubAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::SubEq; +pub use crate::traits::SubEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::MulAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::MulEq; +pub use crate::traits::MulEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::DivAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::DivEq; +pub use crate::traits::DivEq; #[deprecated( feature: "deprecated-op-assign-traits", note: "Use `core::ops::RemAssign`.", since: "2.7.0" )] #[feature("deprecated-op-assign-traits")] -pub use core::traits::RemEq; +pub use crate::traits::RemEq; #[deprecated( feature: "deprecated-index-traits", note: "Use `core::ops::index::Index`.", since: "2.7.0" )] #[feature("deprecated-index-traits")] -pub use core::traits::Index; +pub use crate::traits::Index; #[deprecated( feature: "deprecated-index-traits", note: "Use `core::ops::index::IndexView`.", since: "2.7.0" )] #[feature("deprecated-index-traits")] -pub use core::traits::IndexView; -pub use core::zeroable::NonZero; -pub use core::ops::Deref; +pub use crate::traits::IndexView; +pub use crate::zeroable::NonZero; +pub use crate::ops::Deref; pub use starknet::storage::{ StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess diff --git a/corelib/src/prelude/v2024_07.cairo b/corelib/src/prelude/v2024_07.cairo index dc2d8a78b66..dae63eb9e14 100644 --- a/corelib/src/prelude/v2024_07.cairo +++ b/corelib/src/prelude/v2024_07.cairo @@ -1,22 +1,22 @@ -pub use core::{assert, bool, felt252, usize}; +pub use crate::{assert, bool, felt252, usize}; -pub use core::array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}; -pub use core::box::{Box, BoxTrait}; -pub use core::bytes_31::{Bytes31Trait, bytes31}; -pub use core::byte_array::{ByteArray, ByteArrayTrait}; -pub use core::clone::Clone; -pub use core::dict::Felt252DictTrait; -pub use core::integer::{i128, i16, i32, i64, i8, u128, u16, u256, u32, u64, u8}; -pub use core::nullable::{Nullable, NullableTrait}; -pub use core::option::{Option, OptionTrait}; -pub use core::panics::{Panic, PanicResult, panic}; -pub use core::result::{Result, ResultTrait}; -pub use core::serde::Serde; -pub use core::{starknet, starknet::System}; -pub use core::traits::{ +pub use crate::array::{Array, ArrayTrait, Span, SpanTrait, ToSpanTrait}; +pub use crate::box::{Box, BoxTrait}; +pub use crate::bytes_31::{Bytes31Trait, bytes31}; +pub use crate::byte_array::{ByteArray, ByteArrayTrait}; +pub use crate::clone::Clone; +pub use crate::dict::Felt252DictTrait; +pub use crate::integer::{i128, i16, i32, i64, i8, u128, u16, u256, u32, u64, u8}; +pub use crate::nullable::{Nullable, NullableTrait}; +pub use crate::option::{Option, OptionTrait}; +pub use crate::panics::{Panic, PanicResult, panic}; +pub use crate::result::{Result, ResultTrait}; +pub use crate::serde::Serde; +pub use crate::{starknet, starknet::System}; +pub use crate::traits::{ Add, Copy, Default, Destruct, Div, DivRem, Drop, Felt252DictValue, Into, Mul, Neg, Not, PanicDestruct, PartialEq, PartialOrd, Rem, Sub, TryInto }; -pub use core::zeroable::NonZero; -pub use core::ops::Deref; +pub use crate::zeroable::NonZero; +pub use crate::ops::Deref; diff --git a/corelib/src/result.cairo b/corelib/src/result.cairo index ca072a0960e..44438d0b0d5 100644 --- a/corelib/src/result.cairo +++ b/corelib/src/result.cairo @@ -1,9 +1,9 @@ #[allow(unused_imports)] -use core::array::ArrayTrait; +use crate::array::ArrayTrait; #[allow(unused_imports)] -use core::serde::Serde; +use crate::serde::Serde; #[allow(unused_imports)] -use core::array::SpanTrait; +use crate::array::SpanTrait; #[must_use] #[derive(Copy, Drop, Debug, Serde, PartialEq)] @@ -18,7 +18,7 @@ pub impl ResultTraitImpl of ResultTrait { fn expect<+PanicDestruct>(self: Result, err: felt252) -> T { match self { Result::Ok(x) => x, - Result::Err(_) => core::panic_with_felt252(err), + Result::Err(_) => crate::panic_with_felt252(err), } } /// If `val` is `Result::Ok(x)`, returns `x`. Otherwise, panics. @@ -44,7 +44,7 @@ pub impl ResultTraitImpl of ResultTrait { /// If `val` is `Result::Err(x)`, returns `x`. Otherwise, panics with `err`. fn expect_err<+PanicDestruct>(self: Result, err: felt252) -> E { match self { - Result::Ok(_) => core::panic_with_felt252(err), + Result::Ok(_) => crate::panic_with_felt252(err), Result::Err(x) => x, } } diff --git a/corelib/src/serde.cairo b/corelib/src/serde.cairo index f0e939b5105..aa59473daf1 100644 --- a/corelib/src/serde.cairo +++ b/corelib/src/serde.cairo @@ -1,5 +1,5 @@ #[allow(unused_imports)] -use core::array::{ArrayTrait, SpanTrait}; +use crate::array::{ArrayTrait, SpanTrait}; pub trait Serde { fn serialize(self: @T, ref output: Array); @@ -9,7 +9,7 @@ pub trait Serde { /// Tuple style structs `Serde` implementation. impl SerdeTuple< T, - impl TSF: core::metaprogramming::TupleSnapForward, + impl TSF: crate::metaprogramming::TupleSnapForward, impl Serialize: SerializeTuple, impl Deserialize: DeserializeTuple, > of Serde { @@ -65,7 +65,7 @@ impl DeserializeTupleBaseFixedSizedArray of DeserializeTuple<[T; 0]> { /// Recursive implementation of `SerializeTuple` for tuple style structs. impl SerializeTupleNext< T, - impl TS: core::metaprogramming::TupleSplit, + impl TS: crate::metaprogramming::TupleSplit, +SerializeTuple, +SerializeTuple, +Drop, @@ -80,7 +80,7 @@ impl SerializeTupleNext< /// Recursive implementation of `DeserializeTuple` for tuple style structs. impl DeserializeTupleNext< T, - impl TS: core::metaprogramming::TupleSplit, + impl TS: crate::metaprogramming::TupleSplit, +Serde, +DeserializeTuple, +Drop, @@ -99,8 +99,8 @@ impl DeserializeTupleNext< /// impl MyTypeSerde = core::serde::into_felt252_based::SerdeImpl;` /// ``` pub mod into_felt252_based { - use core::traits::{Into, TryInto}; - use core::array::ArrayTrait; + use crate::traits::{Into, TryInto}; + use crate::array::ArrayTrait; pub impl SerdeImpl, +Into, +TryInto> of super::Serde { #[inline(always)] fn serialize(self: @T, ref output: Array) { diff --git a/corelib/src/sha256.cairo b/corelib/src/sha256.cairo index a9fe4d18c69..1d9a81c8227 100644 --- a/corelib/src/sha256.cairo +++ b/corelib/src/sha256.cairo @@ -1,4 +1,4 @@ -use core::starknet::SyscallResultTrait; +use crate::starknet::SyscallResultTrait; /// A handle to the state of a SHA-256 hash. #[derive(Copy, Drop)] @@ -81,7 +81,7 @@ fn add_sha256_padding(ref arr: Array, last_input_word: u32, last_input_num_ } else { (0x1000000, 0x100, 0x80) }; - let (_, r) = core::integer::u32_safe_divmod(last_input_word, q); + let (_, r) = crate::integer::u32_safe_divmod(last_input_word, q); arr.append(r * m + pad); } diff --git a/corelib/src/test/array_test.cairo b/corelib/src/test/array_test.cairo index accd8c6a4e5..7fffc886db0 100644 --- a/corelib/src/test/array_test.cairo +++ b/corelib/src/test/array_test.cairo @@ -1,5 +1,5 @@ -use core::test::test_utils::assert_eq; -use core::iter::{IntoIterator, Iterator}; +use crate::test::test_utils::assert_eq; +use crate::iter::{IntoIterator, Iterator}; #[test] fn test_array() { diff --git a/corelib/src/test/bool_test.cairo b/corelib/src/test/bool_test.cairo index 9cab5d6778a..586efdc26f5 100644 --- a/corelib/src/test/bool_test.cairo +++ b/corelib/src/test/bool_test.cairo @@ -1,4 +1,4 @@ -use core::test::test_utils::{assert_eq, assert_ne}; +use crate::test::test_utils::{assert_eq, assert_ne}; #[test] fn test_bool_operators() { diff --git a/corelib/src/test/box_test.cairo b/corelib/src/test/box_test.cairo index 2b11365e4e1..d496a3f3ade 100644 --- a/corelib/src/test/box_test.cairo +++ b/corelib/src/test/box_test.cairo @@ -1,4 +1,4 @@ -use core::test::test_utils::assert_eq; +use crate::test::test_utils::assert_eq; #[test] fn test_box_unbox_felt252s() { diff --git a/corelib/src/test/byte_array_test.cairo b/corelib/src/test/byte_array_test.cairo index 3879ad24c83..1b7643be324 100644 --- a/corelib/src/test/byte_array_test.cairo +++ b/corelib/src/test/byte_array_test.cairo @@ -1,4 +1,4 @@ -use core::test::test_utils::{assert_eq, assert_ne}; +use crate::test::test_utils::{assert_eq, assert_ne}; #[test] fn test_append_byte() { @@ -502,7 +502,7 @@ fn compare_byte_array( assert_eq!(ba_pending_word_felt, pending_word); } -fn compare_spans, +PartialEq, +Copy, +Drop>( +fn compare_spans, +PartialEq, +Copy, +Drop>( mut a: Span, mut b: Span ) { assert_eq!(a.len(), b.len()); diff --git a/corelib/src/test/bytes31_test.cairo b/corelib/src/test/bytes31_test.cairo index 9176c2b5668..cee0a4b9080 100644 --- a/corelib/src/test/bytes31_test.cairo +++ b/corelib/src/test/bytes31_test.cairo @@ -1,4 +1,4 @@ -use core::bytes_31::{split_bytes31, bytes31_const}; +use crate::bytes_31::{split_bytes31, bytes31_const}; const POW_2_248: felt252 = 0x100000000000000000000000000000000000000000000000000000000000000; diff --git a/corelib/src/test/circuit_test.cairo b/corelib/src/test/circuit_test.cairo index 1a572ca0629..bda227010a7 100644 --- a/corelib/src/test/circuit_test.cairo +++ b/corelib/src/test/circuit_test.cairo @@ -1,10 +1,10 @@ -use core::circuit::{ +use crate::circuit::{ RangeCheck96, AddMod, MulMod, u96, CircuitElement, CircuitInput, circuit_add, circuit_sub, circuit_mul, circuit_inverse, EvalCircuitTrait, u384, CircuitOutputsTrait, CircuitModulus, AddInputResultTrait, CircuitInputs, }; -use core::traits::TryInto; +use crate::traits::TryInto; #[test] fn test_u96() { @@ -20,9 +20,9 @@ fn test_try_into_u96() { #[test] fn test_builtins() { - core::internal::require_implicit::(); - core::internal::require_implicit::(); - core::internal::require_implicit::(); + crate::internal::require_implicit::(); + crate::internal::require_implicit::(); + crate::internal::require_implicit::(); } #[test] diff --git a/corelib/src/test/cmp_test.cairo b/corelib/src/test/cmp_test.cairo index d2b147bb1ee..55a5e7a9674 100644 --- a/corelib/src/test/cmp_test.cairo +++ b/corelib/src/test/cmp_test.cairo @@ -1,5 +1,5 @@ -use core::cmp::{max, min, minmax}; -use core::test::test_utils::assert_eq; +use crate::cmp::{max, min, minmax}; +use crate::test::test_utils::assert_eq; // Integer tests diff --git a/corelib/src/test/coupon_test.cairo b/corelib/src/test/coupon_test.cairo index 02259f561f8..3cc03d57d64 100644 --- a/corelib/src/test/coupon_test.cairo +++ b/corelib/src/test/coupon_test.cairo @@ -1,4 +1,4 @@ -use core::test::test_utils::assert_eq; +use crate::test::test_utils::assert_eq; extern fn coupon_buy() -> T nopanic; @@ -7,7 +7,7 @@ fn arr_sum(arr: Array<(u128, arr_sum::Coupon)>) -> u128 nopanic { match arr.pop_front_consume() { Option::Some(( rem, (elm, coupon) - )) => core::integer::u128_wrapping_add(elm, arr_sum(rem, __coupon__: coupon)), + )) => crate::integer::u128_wrapping_add(elm, arr_sum(rem, __coupon__: coupon)), Option::None => 0, } } @@ -19,9 +19,9 @@ fn test_arr_sum() { arr.append((4, coupon_buy())); arr.append((5, coupon_buy())); - let available_gas = core::testing::get_available_gas(); + let available_gas = crate::testing::get_available_gas(); let res = arr_sum(arr); // Check that arr_sum did not consume any gas. - assert_eq(@core::testing::get_available_gas(), @available_gas, 'Gas was consumed by arr_sum'); + assert_eq(@crate::testing::get_available_gas(), @available_gas, 'Gas was consumed by arr_sum'); assert_eq(@res, @12, 'Wrong array sum.'); } diff --git a/corelib/src/test/deref_test.cairo b/corelib/src/test/deref_test.cairo index 2d44959f2bc..c2db1bdf01e 100644 --- a/corelib/src/test/deref_test.cairo +++ b/corelib/src/test/deref_test.cairo @@ -16,14 +16,14 @@ struct S3 { } -impl S2Deref of core::ops::deref::Deref { +impl S2Deref of crate::ops::deref::Deref { type Target = S1; fn deref(self: S2) -> S1 { self.inner } } -impl S3Deref of core::ops::deref::Deref { +impl S3Deref of crate::ops::deref::Deref { type Target = S2; fn deref(self: S3) -> S2 { self.inner @@ -50,7 +50,7 @@ enum E1 { V2: S1, } -impl E1Deref of core::ops::deref::Deref { +impl E1Deref of crate::ops::deref::Deref { type Target = S1; fn deref(self: E1) -> S1 { match self { @@ -74,7 +74,7 @@ enum E3 { V2: S3, } -impl E3Deref of core::ops::deref::Deref { +impl E3Deref of crate::ops::deref::Deref { type Target = S3; fn deref(self: E3) -> S3 { match self { @@ -103,7 +103,7 @@ struct S4 { a: usize, } -impl S4Deref of core::ops::deref::Deref { +impl S4Deref of crate::ops::deref::Deref { type Target = E3; fn deref(self: S4) -> E3 { self.e3 @@ -132,7 +132,7 @@ struct ArithOps { div: usize, } -impl UsizeTupleDeref of core::ops::deref::Deref<(usize, usize)> { +impl UsizeTupleDeref of crate::ops::deref::Deref<(usize, usize)> { type Target = ArithOps; fn deref(self: (usize, usize)) -> ArithOps { let (x, y) = self; @@ -140,7 +140,7 @@ impl UsizeTupleDeref of core::ops::deref::Deref<(usize, usize)> { } } -impl UsizeFixedSizeArrayDeref of core::ops::deref::Deref<[usize; 2]> { +impl UsizeFixedSizeArrayDeref of crate::ops::deref::Deref<[usize; 2]> { type Target = ArithOps; fn deref(self: [usize; 2]) -> ArithOps { let [x, y] = self; diff --git a/corelib/src/test/dict_test.cairo b/corelib/src/test/dict_test.cairo index 4c0621bbbca..7a485846dc5 100644 --- a/corelib/src/test/dict_test.cairo +++ b/corelib/src/test/dict_test.cairo @@ -1,6 +1,6 @@ -use core::dict::{Felt252DictEntryTrait, Felt252Dict}; -use core::test::test_utils::assert_eq; -use core::nullable; +use crate::dict::{Felt252DictEntryTrait, Felt252Dict}; +use crate::test::test_utils::assert_eq; +use crate::nullable; #[test] fn test_dict_new() -> Felt252Dict { diff --git a/corelib/src/test/ec_test.cairo b/corelib/src/test/ec_test.cairo index 36ffd824d6e..ab55338249e 100644 --- a/corelib/src/test/ec_test.cairo +++ b/corelib/src/test/ec_test.cairo @@ -1,8 +1,8 @@ -use core::ec::{EcPoint, EcPointTrait, EcStateTrait}; -use core::ecdsa; -use core::option::OptionTrait; -use core::test::test_utils::assert_eq; -use core::traits::TryInto; +use crate::ec::{EcPoint, EcPointTrait, EcStateTrait}; +use crate::ecdsa; +use crate::option::OptionTrait; +use crate::test::test_utils::assert_eq; +use crate::traits::TryInto; #[test] #[should_panic] diff --git a/corelib/src/test/felt_test.cairo b/corelib/src/test/felt_test.cairo index fdcbede7deb..e897d5724a9 100644 --- a/corelib/src/test/felt_test.cairo +++ b/corelib/src/test/felt_test.cairo @@ -1,4 +1,4 @@ -use core::test::test_utils::assert_eq; +use crate::test::test_utils::assert_eq; #[test] fn test_felt252_operators() { diff --git a/corelib/src/test/fmt_test.cairo b/corelib/src/test/fmt_test.cairo index 0e763f866ce..17bc63cd0ed 100644 --- a/corelib/src/test/fmt_test.cairo +++ b/corelib/src/test/fmt_test.cairo @@ -79,11 +79,11 @@ fn test_format_debug() { format!("{:?}", (empty, [1], [2, 3], [4, 5, 6])) == "([], [1], [2, 3], [4, 5, 6])", 'bad fixed sized array fmt' ); - assert(format!("{:?}", core::box::BoxTrait::new(1)) == "&1", 'bad box fmt'); + assert(format!("{:?}", crate::box::BoxTrait::new(1)) == "&1", 'bad box fmt'); assert( - format!("{:?}", core::nullable::NullableTrait::new(1)) == "&1", 'bad nullable value fmt' + format!("{:?}", crate::nullable::NullableTrait::new(1)) == "&1", 'bad nullable value fmt' ); - assert(format!("{:?}", core::nullable::null::()) == "null", 'bad null fmt'); + assert(format!("{:?}", crate::nullable::null::()) == "null", 'bad null fmt'); } #[test] diff --git a/corelib/src/test/hash_test.cairo b/corelib/src/test/hash_test.cairo index 2ae57ce5979..fba2e9efc50 100644 --- a/corelib/src/test/hash_test.cairo +++ b/corelib/src/test/hash_test.cairo @@ -1,11 +1,11 @@ -use core::test::test_utils::assert_eq; -use core::hash::{HashStateTrait, HashStateExTrait}; -use core::poseidon::PoseidonTrait; +use crate::test::test_utils::assert_eq; +use crate::hash::{HashStateTrait, HashStateExTrait}; +use crate::poseidon::PoseidonTrait; #[test] fn test_pedersen_hash() { assert_eq( - @core::pedersen::pedersen(1, 2), + @crate::pedersen::pedersen(1, 2), @2592987851775965742543459319508348457290966253241455514226127639100457844774, 'Wrong hash value' ); @@ -13,7 +13,7 @@ fn test_pedersen_hash() { #[test] fn test_poseidon_hades_permutation() { - let (s0, s1, s2) = core::poseidon::hades_permutation(1, 2, 3); + let (s0, s1, s2) = crate::poseidon::hades_permutation(1, 2, 3); assert_eq( @s0, @442682200349489646213731521593476982257703159825582578145778919623645026501, @@ -35,13 +35,13 @@ fn test_poseidon_hades_permutation() { fn test_poseidon_hash_span() { // Test odd number of inputs. assert_eq!( - core::poseidon::poseidon_hash_span([1, 2, 3].span()), + crate::poseidon::poseidon_hash_span([1, 2, 3].span()), 0x2f0d8840bcf3bc629598d8a6cc80cb7c0d9e52d93dab244bbf9cd0dca0ad082, ); // Test even number of inputs. assert_eq!( - core::poseidon::poseidon_hash_span([1, 2, 3, 4].span()), + crate::poseidon::poseidon_hash_span([1, 2, 3, 4].span()), 0x26e3ad8b876e02bc8a4fc43dad40a8f81a6384083cabffa190bcf40d512ae1d, ); } diff --git a/corelib/src/test/integer_test.cairo b/corelib/src/test/integer_test.cairo index af10baf72c1..1018412180a 100644 --- a/corelib/src/test/integer_test.cairo +++ b/corelib/src/test/integer_test.cairo @@ -1,7 +1,7 @@ #[feature("deprecated-bounded-int-trait")] -use core::{integer, integer::{u512_safe_div_rem_by_u256, u512}}; -use core::test::test_utils::{assert_eq, assert_ne, assert_le, assert_lt, assert_gt, assert_ge}; -use core::num::traits::{Bounded, Sqrt, WideMul, WideSquare, WrappingSub}; +use crate::{integer, integer::{u512_safe_div_rem_by_u256, u512}}; +use crate::test::test_utils::{assert_eq, assert_ne, assert_le, assert_lt, assert_gt, assert_ge}; +use crate::num::traits::{Bounded, Sqrt, WideMul, WideSquare, WrappingSub}; #[test] fn test_u8_operators() { @@ -1873,11 +1873,11 @@ fn test_signed_int_diff() { } mod bounded_int { - use core::internal::{ + use crate::internal::{ bounded_int, bounded_int::{BoundedInt, AddHelper, SubHelper, MulHelper, DivRemHelper, ConstrainHelper} }; - use core::RangeCheck; + use crate::RangeCheck; extern fn downcast(index: T) -> Option implicits(RangeCheck) nopanic; extern fn upcast(index: T) -> S nopanic; diff --git a/corelib/src/test/keccak_test.cairo b/corelib/src/test/keccak_test.cairo index db5c85af0d5..0b94eb4ce89 100644 --- a/corelib/src/test/keccak_test.cairo +++ b/corelib/src/test/keccak_test.cairo @@ -1,4 +1,4 @@ -use core::keccak; +use crate::keccak; #[test] fn test_keccak_syscall() { diff --git a/corelib/src/test/language_features/const_folding_test.cairo b/corelib/src/test/language_features/const_folding_test.cairo index 339da9623c4..8cc3ba32b8c 100644 --- a/corelib/src/test/language_features/const_folding_test.cairo +++ b/corelib/src/test/language_features/const_folding_test.cairo @@ -1,5 +1,5 @@ -use core::num::traits::{WrappingAdd, WrappingSub, WrappingMul}; -use core::integer::i8_diff; +use crate::num::traits::{WrappingAdd, WrappingSub, WrappingMul}; +use crate::integer::i8_diff; /// Helper to prevent const folding. #[inline(never)] diff --git a/corelib/src/test/language_features/const_test.cairo b/corelib/src/test/language_features/const_test.cairo index f0365411313..5b4c97c31aa 100644 --- a/corelib/src/test/language_features/const_test.cairo +++ b/corelib/src/test/language_features/const_test.cairo @@ -1,4 +1,4 @@ -use core::box::BoxTrait; +use crate::box::BoxTrait; mod enum_value { pub extern type Const; diff --git a/corelib/src/test/language_features/for_test.cairo b/corelib/src/test/language_features/for_test.cairo index 23dbe774c29..c046153204e 100644 --- a/corelib/src/test/language_features/for_test.cairo +++ b/corelib/src/test/language_features/for_test.cairo @@ -1,4 +1,4 @@ -use core::iter::IntoIterator; +use crate::iter::IntoIterator; #[test] fn test_for_loop_array_sum() { diff --git a/corelib/src/test/language_features/panics_test.cairo b/corelib/src/test/language_features/panics_test.cairo index 70dcf26dba8..daffa8b41e9 100644 --- a/corelib/src/test/language_features/panics_test.cairo +++ b/corelib/src/test/language_features/panics_test.cairo @@ -1,5 +1,5 @@ -use core::byte_array::BYTE_ARRAY_MAGIC; -use core::{panics, panic_with_felt252}; +use crate::byte_array::BYTE_ARRAY_MAGIC; +use crate::{panics, panic_with_felt252}; #[test] #[should_panic(expected: 'short_string')] diff --git a/corelib/src/test/math_test.cairo b/corelib/src/test/math_test.cairo index 741131c6b68..810561f1d09 100644 --- a/corelib/src/test/math_test.cairo +++ b/corelib/src/test/math_test.cairo @@ -1,5 +1,5 @@ -use core::option::OptionTrait; -use core::math; +use crate::option::OptionTrait; +use crate::math; #[test] fn test_egcd() { diff --git a/corelib/src/test/nullable_test.cairo b/corelib/src/test/nullable_test.cairo index 1c8c1af4206..92a6d8ea588 100644 --- a/corelib/src/test/nullable_test.cairo +++ b/corelib/src/test/nullable_test.cairo @@ -1,5 +1,5 @@ -use core::test::test_utils::assert_eq; -use core::nullable::null; +use crate::test::test_utils::assert_eq; +use crate::nullable::null; #[test] fn test_nullable_felt252s() { diff --git a/corelib/src/test/num_test.cairo b/corelib/src/test/num_test.cairo index f6537013946..cc425ab57e9 100644 --- a/corelib/src/test/num_test.cairo +++ b/corelib/src/test/num_test.cairo @@ -1,9 +1,9 @@ -use core::num::traits::BitSize; -use core::num::traits::{ +use crate::num::traits::BitSize; +use crate::num::traits::{ OverflowingAdd, OverflowingSub, OverflowingMul, WrappingAdd, WrappingSub, WrappingMul, CheckedAdd, CheckedSub, CheckedMul, SaturatingAdd, SaturatingSub, SaturatingMul }; -use core::num::traits::Bounded; +use crate::num::traits::Bounded; #[test] diff --git a/corelib/src/test/plugins_test.cairo b/corelib/src/test/plugins_test.cairo index 95ccf8f8c68..a45be296e5e 100644 --- a/corelib/src/test/plugins_test.cairo +++ b/corelib/src/test/plugins_test.cairo @@ -1,4 +1,4 @@ -use core::test::test_utils::assert_eq; +use crate::test::test_utils::assert_eq; #[derive(Copy, Debug, Drop, Serde, PartialEq)] enum EnumForSerde { diff --git a/corelib/src/test/print_test.cairo b/corelib/src/test/print_test.cairo index 161d10a8ebf..64192bf2415 100644 --- a/corelib/src/test/print_test.cairo +++ b/corelib/src/test/print_test.cairo @@ -1,5 +1,5 @@ -use core::byte_array::BYTE_ARRAY_MAGIC; -use core::debug::{PrintTrait, print_byte_array_as_string}; +use crate::byte_array::BYTE_ARRAY_MAGIC; +use crate::debug::{PrintTrait, print_byte_array_as_string}; #[ignore] #[test] diff --git a/corelib/src/test/result_test.cairo b/corelib/src/test/result_test.cairo index e151fdd92c0..f5b5a3c72b3 100644 --- a/corelib/src/test/result_test.cairo +++ b/corelib/src/test/result_test.cairo @@ -1,4 +1,4 @@ -use core::result::{Result, ResultTraitImpl}; +use crate::result::{Result, ResultTraitImpl}; #[test] fn test_result_ok_expect() { diff --git a/corelib/src/test/secp256k1_test.cairo b/corelib/src/test/secp256k1_test.cairo index f5ad6a956f9..daeb32be0de 100644 --- a/corelib/src/test/secp256k1_test.cairo +++ b/corelib/src/test/secp256k1_test.cairo @@ -1,4 +1,4 @@ -use core::serde::Serde; +use crate::serde::Serde; use starknet::{ eth_address::U256IntoEthAddress, EthAddress, secp256k1::Secp256k1Impl, SyscallResultTrait }; diff --git a/corelib/src/test/secp256r1_test.cairo b/corelib/src/test/secp256r1_test.cairo index d67536babfa..a1c0ffea415 100644 --- a/corelib/src/test/secp256r1_test.cairo +++ b/corelib/src/test/secp256r1_test.cairo @@ -1,8 +1,8 @@ -use core::option::OptionTrait; +use crate::option::OptionTrait; use starknet::{secp256r1::Secp256r1Impl, SyscallResultTrait}; use starknet::secp256_trait::{recover_public_key, Secp256PointTrait, Signature, is_valid_signature}; use starknet::secp256r1::Secp256r1Point; -use core::test::test_utils::assert_eq; +use crate::test::test_utils::assert_eq; #[test] fn test_secp256k1_point_serde() { diff --git a/corelib/src/test/sha256_test.cairo b/corelib/src/test/sha256_test.cairo index c3a2f963021..74e9f54d304 100644 --- a/corelib/src/test/sha256_test.cairo +++ b/corelib/src/test/sha256_test.cairo @@ -1,4 +1,4 @@ -use core::sha256::compute_sha256_byte_array; +use crate::sha256::compute_sha256_byte_array; #[test] fn test_sha256_byte_array() { diff --git a/corelib/src/test/testing_test.cairo b/corelib/src/test/testing_test.cairo index 16326c151dd..94dc1d37b55 100644 --- a/corelib/src/test/testing_test.cairo +++ b/corelib/src/test/testing_test.cairo @@ -1,10 +1,10 @@ -use core::test::test_utils::assert_gt; +use crate::test::test_utils::assert_gt; #[test] #[should_panic(expected: ('panic_with_felt252()',))] fn test_panic_with_felt252() { - // No semicolon here: Missing implementation for core::traits::Drop:: - core::panic_with_felt252('panic_with_felt252()') + // No semicolon here: Missing implementation for crate::traits::Drop:: + crate::panic_with_felt252('panic_with_felt252()') } #[test] @@ -116,13 +116,13 @@ fn test_assert_eq_no_description() { #[test] #[available_gas(static)] fn test_get_available_gas_no_gas_supply() { - assert_eq!(core::testing::get_available_gas(), 0) + assert_eq!(crate::testing::get_available_gas(), 0) } #[test] #[available_gas(10000)] fn test_get_available_gas_with_gas_supply() { - assert_gt(core::testing::get_available_gas(), 5000, 'high amount of gas used') + assert_gt(crate::testing::get_available_gas(), 5000, 'high amount of gas used') } #[test] diff --git a/corelib/src/test/to_byte_array_test.cairo b/corelib/src/test/to_byte_array_test.cairo index 8d6f8149be8..bb89f79b080 100644 --- a/corelib/src/test/to_byte_array_test.cairo +++ b/corelib/src/test/to_byte_array_test.cairo @@ -1,5 +1,5 @@ -use core::test::test_utils::assert_eq; -use core::to_byte_array::{FormatAsByteArray, AppendFormattedToByteArray}; +use crate::test::test_utils::assert_eq; +use crate::to_byte_array::{FormatAsByteArray, AppendFormattedToByteArray}; #[test] fn test_to_string_hex() { diff --git a/corelib/src/testing.cairo b/corelib/src/testing.cairo index 11c476a062d..f7d69ab04a8 100644 --- a/corelib/src/testing.cairo +++ b/corelib/src/testing.cairo @@ -1,4 +1,4 @@ -use core::gas::GasBuiltin; +use crate::gas::GasBuiltin; /// Returns the amount of gas available in the `GasBuiltin`. /// diff --git a/corelib/src/to_byte_array.cairo b/corelib/src/to_byte_array.cairo index 1ee7899a144..787a358b156 100644 --- a/corelib/src/to_byte_array.cairo +++ b/corelib/src/to_byte_array.cairo @@ -1,7 +1,7 @@ -use core::byte_array::ByteArrayTrait; -use core::traits::{Into, TryInto}; -use core::option::OptionTrait; -use core::zeroable::Zeroable; +use crate::byte_array::ByteArrayTrait; +use crate::traits::{Into, TryInto}; +use crate::option::OptionTrait; +use crate::zeroable::Zeroable; /// Formats a type that behaves like uint to its Ascii representation and appends the formatted /// result into the given ByteArray. diff --git a/corelib/src/traits.cairo b/corelib/src/traits.cairo index 4b09019b9c1..2688d6c4bec 100644 --- a/corelib/src/traits.cairo +++ b/corelib/src/traits.cairo @@ -1,4 +1,4 @@ -use core::panics::Panic; +use crate::panics::Panic; pub trait Copy; pub trait Drop; @@ -218,15 +218,15 @@ pub(crate) impl TupleSize0Copy of Copy<()>; pub(crate) impl TupleSize0Drop of Drop<()>; impl TupleNextDrop< T, - impl TH: core::metaprogramming::TupleSplit, - +core::metaprogramming::IsTuple, + impl TH: crate::metaprogramming::TupleSplit, + +crate::metaprogramming::IsTuple, +Drop, +Drop > of Drop; impl TupleNextCopy< T, - impl TH: core::metaprogramming::TupleSplit, - +core::metaprogramming::IsTuple, + impl TH: crate::metaprogramming::TupleSplit, + +crate::metaprogramming::IsTuple, +Copy, +Copy > of Copy; @@ -234,7 +234,7 @@ impl TupleNextCopy< /// Tuple `PartialEq` implementation. impl TuplePartialEq< T, - impl TSF: core::metaprogramming::TupleSnapForward, + impl TSF: crate::metaprogramming::TupleSnapForward, +TuplePartialEqHelper, > of PartialEq { fn eq(lhs: @T, rhs: @T) -> bool { @@ -286,7 +286,7 @@ impl TuplePartialEqHelperBaseFixedSizedArray of TuplePartialEqHelper<[@T; 0]> /// The recursive implementation of `TuplePartialEqHelper` for tuple style structs. impl TuplePartialEqHelperNext< T, - impl TS: core::metaprogramming::TupleSplit, + impl TS: crate::metaprogramming::TupleSplit, +TuplePartialEqHelper, +TuplePartialEqHelper, +Drop, @@ -322,7 +322,7 @@ impl DefaultFixedSizedArray of Default<[T; 0]> { /// Recursive implementation for `Default` for tuple style structs. impl DefaultNext< T, - impl TS: core::metaprogramming::TupleSplit, + impl TS: crate::metaprogramming::TupleSplit, +Default, +Default, +Drop, @@ -338,7 +338,7 @@ impl FixedSizedArrayCopy, const N: u32> of Copy<[T; N]>; /// Recursive implementation of `Destruct` for tuple style structs. impl TupleNextDestruct< T, - impl TH: core::metaprogramming::TupleSplit, + impl TH: crate::metaprogramming::TupleSplit, +Destruct, +Destruct, -Drop, diff --git a/corelib/src/zeroable.cairo b/corelib/src/zeroable.cairo index 138e2118073..9112a9ea2fb 100644 --- a/corelib/src/zeroable.cairo +++ b/corelib/src/zeroable.cairo @@ -46,7 +46,7 @@ pub(crate) trait Zeroable { pub(crate) mod zero_based { /// Implements `Zeroable` for any type that implements `Zero`, `Drop`, and `Copy`. pub(crate) impl ZeroableImpl< - T, impl ZeroImpl: core::num::traits::Zero, +Drop, +Copy + T, impl ZeroImpl: crate::num::traits::Zero, +Drop, +Copy > of super::Zeroable { /// Returns the zero value for the type. fn zero() -> T { diff --git a/crates/cairo-lang-language-server/src/ide/semantic_highlighting/token_kind.rs b/crates/cairo-lang-language-server/src/ide/semantic_highlighting/token_kind.rs index 149086ba5fe..e7df0990b4e 100644 --- a/crates/cairo-lang-language-server/src/ide/semantic_highlighting/token_kind.rs +++ b/crates/cairo-lang-language-server/src/ide/semantic_highlighting/token_kind.rs @@ -2,7 +2,7 @@ use cairo_lang_semantic::db::SemanticGroup; use cairo_lang_semantic::items::function_with_body::SemanticExprLookup; use cairo_lang_semantic::lookup_item::LookupItemEx; use cairo_lang_semantic::resolve::{ - ResolvedConcreteItem, ResolvedGenericItem, SELF_TYPE_KW, SUPER_KW, + ResolvedConcreteItem, ResolvedGenericItem, CRATE_KW, SELF_TYPE_KW, SUPER_KW, }; use cairo_lang_syntax::node::kind::SyntaxKind; use cairo_lang_syntax::node::utils::grandparent_kind; @@ -86,7 +86,7 @@ impl SemanticTokenKind { node = node.parent().unwrap(); let identifier = ast::TerminalIdentifier::from_syntax_node(syntax_db, node.clone()); - if [SUPER_KW, SELF_TYPE_KW].contains(&identifier.text(syntax_db).as_str()) { + if [SUPER_KW, SELF_TYPE_KW, CRATE_KW].contains(&identifier.text(syntax_db).as_str()) { return Some(SemanticTokenKind::Keyword); } diff --git a/crates/cairo-lang-semantic/src/resolve/mod.rs b/crates/cairo-lang-semantic/src/resolve/mod.rs index f753907edfa..fbda3382b5f 100644 --- a/crates/cairo-lang-semantic/src/resolve/mod.rs +++ b/crates/cairo-lang-semantic/src/resolve/mod.rs @@ -65,6 +65,7 @@ mod item; // Remove when these are added as actual keywords. pub const SELF_TYPE_KW: &str = "Self"; pub const SUPER_KW: &str = "super"; +pub const CRATE_KW: &str = "crate"; /// Lookback maps for item resolving. Can be used to quickly check what is the semantic resolution /// of any path segment. @@ -369,12 +370,16 @@ impl<'db> Resolver<'db> { ResolvedConcreteItem::Module(module_id) } else { // This identifier is a crate. + let crate_ident = identifier.text(syntax_db); + let crate_id = if crate_ident == CRATE_KW { + self.owning_crate_id + } else { + CrateLongId::Real(crate_ident).intern(db) + }; self.resolved_items.mark_concrete( db, segments.next().unwrap(), - ResolvedConcreteItem::Module(ModuleId::CrateRoot( - CrateLongId::Real(identifier.text(syntax_db)).intern(db), - )), + ResolvedConcreteItem::Module(ModuleId::CrateRoot(crate_id)), ) } } @@ -486,12 +491,16 @@ impl<'db> Resolver<'db> { ResolvedGenericItem::Module(module_id) } else { // This identifier is a crate. + let crate_ident = identifier.text(syntax_db); + let crate_id = if crate_ident == CRATE_KW { + self.owning_crate_id + } else { + CrateLongId::Real(crate_ident).intern(db) + }; self.resolved_items.mark_generic( db, segments.next().unwrap(), - ResolvedGenericItem::Module(ModuleId::CrateRoot( - CrateLongId::Real(identifier.text(syntax_db)).intern(db), - )), + ResolvedGenericItem::Module(ModuleId::CrateRoot(crate_id)), ) } } @@ -954,6 +963,8 @@ impl<'db> Resolver<'db> { return Some(self.module_file_id.0); } + // If the first element is `crate`, use the crate's root module as the base module. + require(ident != CRATE_KW)?; // If the first segment is a name of a crate, use the crate's root module as the base // module. let crate_id = CrateLongId::Real(ident).intern(self.db); diff --git a/crates/cairo-lang-sierra-generator/src/statement_location_test_data/simple b/crates/cairo-lang-sierra-generator/src/statement_location_test_data/simple index 1f5bdc4c83d..e976f584969 100644 --- a/crates/cairo-lang-sierra-generator/src/statement_location_test_data/simple +++ b/crates/cairo-lang-sierra-generator/src/statement_location_test_data/simple @@ -396,8 +396,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -417,8 +417,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -438,8 +438,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -459,8 +459,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -480,8 +480,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -501,8 +501,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -514,8 +514,8 @@ Inlined at: In function: lib.cairo::foo enum_init, 1>([26]) -> ([27]) Originating location: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -527,8 +527,8 @@ Inlined at: In function: lib.cairo::foo store_temp([19]) -> ([19]) Originating location: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -540,8 +540,8 @@ Inlined at: In function: lib.cairo::foo store_temp>([27]) -> ([27]) Originating location: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -553,8 +553,8 @@ Inlined at: In function: lib.cairo::foo return([19], [27]) Originating location: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -566,8 +566,8 @@ Inlined at: In function: lib.cairo::foo label_test::foo::8: Originating location: - Option::None => core::panic_with_felt252(err), - ^***************************^ + Option::None => crate::panic_with_felt252(err), + ^****************************^ In function: core::option::OptionTraitImpl::expect Inlined at: u8_wide_mul(lhs, rhs).try_into().expect('u8_mul Overflow') @@ -729,8 +729,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -750,8 +750,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -771,8 +771,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -792,8 +792,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -813,8 +813,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -834,8 +834,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -847,8 +847,8 @@ Inlined at: In function: lib.cairo::foo enum_init, 1>([38]) -> ([39]) Originating location: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -860,8 +860,8 @@ Inlined at: In function: lib.cairo::foo store_temp([30]) -> ([30]) Originating location: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -873,8 +873,8 @@ Inlined at: In function: lib.cairo::foo store_temp>([39]) -> ([39]) Originating location: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -886,8 +886,8 @@ Inlined at: In function: lib.cairo::foo return([30], [39]) Originating location: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -899,8 +899,8 @@ Inlined at: In function: lib.cairo::foo label_test::foo::10: Originating location: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -912,8 +912,8 @@ Inlined at: In function: lib.cairo::foo label_test::foo::6: Originating location: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -925,8 +925,8 @@ Inlined at: In function: lib.cairo::foo label_test::foo::3: Originating location: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2343,8 +2343,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2368,8 +2368,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2393,8 +2393,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2418,8 +2418,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2443,8 +2443,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2468,8 +2468,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2575,8 +2575,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2600,8 +2600,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2625,8 +2625,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2650,8 +2650,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2675,8 +2675,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2700,8 +2700,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2820,8 +2820,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2845,8 +2845,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2870,8 +2870,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2895,8 +2895,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2920,8 +2920,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -2945,8 +2945,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -3078,8 +3078,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -3103,8 +3103,8 @@ Inlined at: ^****************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -3128,8 +3128,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -3153,8 +3153,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -3178,8 +3178,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -3203,8 +3203,8 @@ Inlined at: ^**************************************************************************^ In function: core::array_inline_macro Inlined at: - Result::Err(_) => core::panic_with_felt252(err), - ^***************************^ + Result::Err(_) => crate::panic_with_felt252(err), + ^****************************^ In function: core::result::ResultTraitImpl::expect Inlined at: u8_overflowing_add(lhs, rhs).expect('u8_add Overflow') @@ -3654,8 +3654,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::debug::array_inline_macro Inlined at: core::debug::print_byte_array_as_string(@__formatter_for_print_macros__.buffer); @@ -3667,8 +3667,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::debug::array_inline_macro Inlined at: core::debug::print_byte_array_as_string(@__formatter_for_print_macros__.buffer); @@ -4443,8 +4443,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::debug::array_inline_macro Inlined at: core::debug::print_byte_array_as_string(@__formatter_for_print_macros__.buffer); @@ -4456,8 +4456,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::debug::array_inline_macro Inlined at: core::debug::print_byte_array_as_string(@__formatter_for_print_macros__.buffer); @@ -6265,8 +6265,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::panics::array_inline_macro Inlined at: core::panics::panic_with_byte_array(@__formatter_for_assert_macro__.buffer) @@ -6278,8 +6278,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::panics::array_inline_macro Inlined at: core::panics::panic_with_byte_array(@__formatter_for_assert_macro__.buffer) @@ -6291,8 +6291,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::panics::array_inline_macro Inlined at: core::panics::panic_with_byte_array(@__formatter_for_assert_macro__.buffer) @@ -6304,8 +6304,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::panics::array_inline_macro Inlined at: core::panics::panic_with_byte_array(@__formatter_for_assert_macro__.buffer) @@ -6317,8 +6317,8 @@ Originating location: ^***************************^ In function: core::array::ArrayImpl::append Inlined at: - core::array::ArrayTrait::append(ref __array_builder_macro_result__,core::byte_array::BYTE_ARRAY_MAGIC); - ^****************************************************************************************************^ + core::array::ArrayTrait::append(ref __array_builder_macro_result__,crate::byte_array::BYTE_ARRAY_MAGIC); + ^*****************************************************************************************************^ In function: core::panics::array_inline_macro Inlined at: core::panics::panic_with_byte_array(@__formatter_for_assert_macro__.buffer)