@@ -147,7 +147,9 @@ impl Sub<usize> for Relocatable {
147147 type Output = Result < Relocatable , MathError > ;
148148 fn sub ( self , other : usize ) -> Result < Self , MathError > {
149149 if self . offset < other {
150- return Err ( MathError :: RelocatableSubNegOffset ( Box :: new ( ( self , other) ) ) ) ;
150+ return Err ( MathError :: RelocatableSubUsizeNegOffset ( Box :: new ( (
151+ self , other,
152+ ) ) ) ) ;
151153 }
152154 let new_offset = self . offset - other;
153155 Ok ( relocatable ! ( self . segment_index, new_offset) )
@@ -161,7 +163,7 @@ impl Sub<Relocatable> for Relocatable {
161163 return Err ( MathError :: RelocatableSubDiffIndex ( Box :: new ( ( self , other) ) ) ) ;
162164 }
163165 if self . offset < other. offset {
164- return Err ( MathError :: RelocatableSubNegOffset ( Box :: new ( (
166+ return Err ( MathError :: RelocatableSubUsizeNegOffset ( Box :: new ( (
165167 self ,
166168 other. offset ,
167169 ) ) ) ) ;
@@ -268,10 +270,7 @@ impl MaybeRelocatable {
268270 Ok ( MaybeRelocatable :: from ( (
269271 rel_a. segment_index ,
270272 ( rel_a. offset - num_b) . to_usize ( ) . ok_or_else ( || {
271- MathError :: RelocatableAddFelt252OffsetExceeded ( Box :: new ( (
272- * rel_a,
273- num_b. clone ( ) ,
274- ) ) )
273+ MathError :: RelocatableSubFelt252NegOffset ( Box :: new ( ( * rel_a, num_b. clone ( ) ) ) )
275274 } ) ?,
276275 ) ) )
277276 }
@@ -789,7 +788,7 @@ mod tests {
789788
790789 assert_eq ! (
791790 reloc + ( -3 ) ,
792- Err ( MathError :: RelocatableSubNegOffset ( Box :: new( (
791+ Err ( MathError :: RelocatableSubUsizeNegOffset ( Box :: new( (
793792 relocatable!( 1 , 1 ) ,
794793 3
795794 ) ) ) )
@@ -814,7 +813,7 @@ mod tests {
814813 assert_eq ! ( reloc - relocatable!( 7 , 5 ) , Ok ( 1 ) ) ;
815814 assert_eq ! (
816815 reloc - relocatable!( 7 , 9 ) ,
817- Err ( MathError :: RelocatableSubNegOffset ( Box :: new( (
816+ Err ( MathError :: RelocatableSubUsizeNegOffset ( Box :: new( (
818817 relocatable!( 7 , 6 ) ,
819818 9
820819 ) ) ) )
0 commit comments