Skip to content

Commit

Permalink
Fixed uses of Self in corelib (starkware-libs#5479)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvalsw authored Apr 25, 2024
1 parent 8e3b175 commit 113133c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions corelib/src/ec.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub impl EcPointImpl of EcPointTrait {
/// Creates a new EC point from its (x, y) coordinates.
#[inline(always)]
fn new(x: felt252, y: felt252) -> Option<EcPoint> {
Option::Some(EcPointTrait::new_nz(:x, :y)?.into())
Option::Some(Self::new_nz(:x, :y)?.into())
}
/// Creates a new NonZero EC point from its (x, y) coordinates.
#[inline(always)]
Expand All @@ -134,7 +134,7 @@ pub impl EcPointImpl of EcPointTrait {
/// Creates a new EC point from its x coordinate.
#[inline(always)]
fn new_from_x(x: felt252) -> Option<EcPoint> {
Option::Some(EcPointTrait::new_nz_from_x(:x)?.into())
Option::Some(Self::new_nz_from_x(:x)?.into())
}
/// Creates a new NonZero EC point from its x coordinate.
#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions corelib/src/felt_252.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(crate) impl Felt252Zero of core::num::traits::Zero<felt252> {

#[inline(always)]
fn is_zero(self: @felt252) -> bool {
*self == Felt252Zero::zero()
*self == Self::zero()
}

#[inline(always)]
Expand All @@ -21,7 +21,7 @@ pub(crate) impl Felt252One of core::num::traits::One<felt252> {

#[inline(always)]
fn is_one(self: @felt252) -> bool {
*self == Felt252One::one()
*self == Self::one()
}

#[inline(always)]
Expand Down
44 changes: 22 additions & 22 deletions corelib/src/integer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ impl U8Zero of core::num::traits::Zero<u8> {
}
#[inline(always)]
fn is_zero(self: @u8) -> bool {
*self == U8Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @u8) -> bool {
Expand All @@ -2490,7 +2490,7 @@ impl U16Zero of core::num::traits::Zero<u16> {
}
#[inline(always)]
fn is_zero(self: @u16) -> bool {
*self == U16Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @u16) -> bool {
Expand All @@ -2504,7 +2504,7 @@ impl U32Zero of core::num::traits::Zero<u32> {
}
#[inline(always)]
fn is_zero(self: @u32) -> bool {
*self == U32Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @u32) -> bool {
Expand All @@ -2518,7 +2518,7 @@ impl U64Zero of core::num::traits::Zero<u64> {
}
#[inline(always)]
fn is_zero(self: @u64) -> bool {
*self == U64Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @u64) -> bool {
Expand All @@ -2532,7 +2532,7 @@ impl U128Zero of core::num::traits::Zero<u128> {
}
#[inline(always)]
fn is_zero(self: @u128) -> bool {
*self == U128Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @u128) -> bool {
Expand All @@ -2546,7 +2546,7 @@ impl U256Zero of core::num::traits::Zero<u256> {
}
#[inline(always)]
fn is_zero(self: @u256) -> bool {
*self == U256Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @u256) -> bool {
Expand All @@ -2560,7 +2560,7 @@ impl I8Zero of core::num::traits::Zero<i8> {
}
#[inline(always)]
fn is_zero(self: @i8) -> bool {
*self == I8Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @i8) -> bool {
Expand All @@ -2574,7 +2574,7 @@ impl I16Zero of core::num::traits::Zero<i16> {
}
#[inline(always)]
fn is_zero(self: @i16) -> bool {
*self == I16Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @i16) -> bool {
Expand All @@ -2588,7 +2588,7 @@ impl I32Zero of core::num::traits::Zero<i32> {
}
#[inline(always)]
fn is_zero(self: @i32) -> bool {
*self == I32Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @i32) -> bool {
Expand All @@ -2602,7 +2602,7 @@ impl I64Zero of core::num::traits::Zero<i64> {
}
#[inline(always)]
fn is_zero(self: @i64) -> bool {
*self == I64Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @i64) -> bool {
Expand All @@ -2616,7 +2616,7 @@ impl I128Zero of core::num::traits::Zero<i128> {
}
#[inline(always)]
fn is_zero(self: @i128) -> bool {
*self == I128Zero::zero()
*self == Self::zero()
}
#[inline(always)]
fn is_non_zero(self: @i128) -> bool {
Expand All @@ -2632,7 +2632,7 @@ impl U8One of core::num::traits::One<u8> {
}
#[inline(always)]
fn is_one(self: @u8) -> bool {
*self == U8One::one()
*self == Self::one()
}
#[inline(always)]
fn is_non_one(self: @u8) -> bool {
Expand All @@ -2646,7 +2646,7 @@ impl U16One of core::num::traits::One<u16> {
}
#[inline(always)]
fn is_one(self: @u16) -> bool {
*self == U16One::one()
*self == Self::one()
}
#[inline(always)]
fn is_non_one(self: @u16) -> bool {
Expand All @@ -2660,7 +2660,7 @@ impl U32One of core::num::traits::One<u32> {
}
#[inline(always)]
fn is_one(self: @u32) -> bool {
*self == U32One::one()
*self == Self::one()
}
#[inline(always)]
fn is_non_one(self: @u32) -> bool {
Expand All @@ -2674,7 +2674,7 @@ impl U64One of core::num::traits::One<u64> {
}
#[inline(always)]
fn is_one(self: @u64) -> bool {
*self == U64One::one()
*self == Self::one()
}
#[inline(always)]
fn is_non_one(self: @u64) -> bool {
Expand All @@ -2688,7 +2688,7 @@ impl U128One of core::num::traits::One<u128> {
}
#[inline(always)]
fn is_one(self: @u128) -> bool {
*self == U128One::one()
*self == Self::one()
}
#[inline(always)]
fn is_non_one(self: @u128) -> bool {
Expand All @@ -2702,7 +2702,7 @@ impl U256One of core::num::traits::One<u256> {
}
#[inline(always)]
fn is_one(self: @u256) -> bool {
*self == U256One::one()
*self == Self::one()
}
#[inline(always)]
fn is_non_one(self: @u256) -> bool {
Expand All @@ -2717,7 +2717,7 @@ impl I8One of core::num::traits::One<i8> {

#[inline(always)]
fn is_one(self: @i8) -> bool {
*self == I8One::one()
*self == Self::one()
}

#[inline(always)]
Expand All @@ -2733,7 +2733,7 @@ impl I16One of core::num::traits::One<i16> {

#[inline(always)]
fn is_one(self: @i16) -> bool {
*self == I16One::one()
*self == Self::one()
}

#[inline(always)]
Expand All @@ -2749,7 +2749,7 @@ impl I32One of core::num::traits::One<i32> {

#[inline(always)]
fn is_one(self: @i32) -> bool {
*self == I32One::one()
*self == Self::one()
}

#[inline(always)]
Expand All @@ -2765,7 +2765,7 @@ impl I64One of core::num::traits::One<i64> {

#[inline(always)]
fn is_one(self: @i64) -> bool {
*self == I64One::one()
*self == Self::one()
}

#[inline(always)]
Expand All @@ -2781,7 +2781,7 @@ impl I128One of core::num::traits::One<i128> {

#[inline(always)]
fn is_one(self: @i128) -> bool {
*self == I128One::one()
*self == Self::one()
}

#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions tests/bug_samples/issue3153.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ fn unpack_proposal_fields(packed: felt252) -> (felt252, u64) {

impl ProposalStore of Store<Proposal> {
fn read(address_domain: u32, base: StorageBaseAddress) -> SyscallResult<Proposal> {
ProposalStore::read_at_offset(address_domain, base, 0)
Self::read_at_offset(address_domain, base, 0)
}

fn write(address_domain: u32, base: StorageBaseAddress, value: Proposal) -> SyscallResult<()> {
ProposalStore::write_at_offset(address_domain, base, 0, value)
Self::write_at_offset(address_domain, base, 0, value)
}
fn read_at_offset(
address_domain: u32, base: StorageBaseAddress, offset: u8
Expand Down

0 comments on commit 113133c

Please sign in to comment.