@@ -93,16 +93,16 @@ impl<T> fmt::Debug for Pos<T> {
9393#[ derive( Debug , Default ) ]
9494pub struct EncodedOps {
9595 buffer : Vec < u8 > ,
96- temp : Option < ( BytePos , TempBuffer ) > ,
96+ temp : Option < ReportingPos > ,
9797}
9898
99- /// The kind of temporary/scratch stored object .
99+ /// A [`Pos`] of an encoded item that needs to be reported back .
100100#[ derive( Debug ) ]
101- enum TempBuffer {
101+ enum ReportingPos {
102102 /// The temporary object is a [`BranchOffset`].
103- BranchOffset ,
103+ BranchOffset ( Pos < BranchOffset > ) ,
104104 /// The temporary object is a [`BlockFuel`].
105- BlockFuel ,
105+ BlockFuel ( Pos < BlockFuel > ) ,
106106}
107107
108108impl Reset for EncodedOps {
@@ -118,9 +118,9 @@ impl EncodedOps {
118118 BytePos :: from ( self . buffer . len ( ) )
119119 }
120120
121- /// Takes the temporay buffer if any exists.
121+ /// Takes the reporting [`Pos`] if any exists.
122122 #[ must_use]
123- fn take_temp ( & mut self ) -> Option < ( BytePos , TempBuffer ) > {
123+ fn take_reporting_pos ( & mut self ) -> Option < ReportingPos > {
124124 self . temp . take ( )
125125 }
126126}
@@ -148,7 +148,7 @@ impl ir::Encoder for EncodedOps {
148148 _branch_offset : BranchOffset ,
149149 ) -> Result < ( ) , Self :: Error > {
150150 debug_assert ! ( self . temp. is_none( ) ) ;
151- self . temp = Some ( ( pos , TempBuffer :: BranchOffset ) ) ;
151+ self . temp = Some ( ReportingPos :: BranchOffset ( pos . into ( ) ) ) ;
152152 Ok ( ( ) )
153153 }
154154
@@ -158,7 +158,7 @@ impl ir::Encoder for EncodedOps {
158158 _block_fuel : ir:: BlockFuel ,
159159 ) -> Result < ( ) , Self :: Error > {
160160 debug_assert ! ( self . temp. is_none( ) ) ;
161- self . temp = Some ( ( pos , TempBuffer :: BlockFuel ) ) ;
161+ self . temp = Some ( ReportingPos :: BlockFuel ( pos . into ( ) ) ) ;
162162 Ok ( ( ) )
163163 }
164164}
@@ -408,7 +408,7 @@ impl OpEncoder {
408408 self . try_encode_staged ( ) ?;
409409 self . bump_fuel_consumption ( fuel_pos, fuel_selector) ?;
410410 let pos = self . encode_impl ( op) ?;
411- debug_assert ! ( self . ops. take_temp ( ) . is_none( ) ) ;
411+ debug_assert ! ( self . ops. take_reporting_pos ( ) . is_none( ) ) ;
412412 debug_assert ! ( self . staged. is_none( ) ) ;
413413 Ok ( pos)
414414 }
@@ -425,11 +425,11 @@ impl OpEncoder {
425425 let consumed_fuel = BlockFuel :: from ( fuel_costs. base ( ) ) ;
426426 self . try_encode_staged ( ) ?;
427427 Op :: consume_fuel ( consumed_fuel) . encode ( & mut self . ops ) ?;
428- let Some ( ( pos , TempBuffer :: BlockFuel ) ) = self . ops . take_temp ( ) else {
428+ let Some ( ReportingPos :: BlockFuel ( pos ) ) = self . ops . take_reporting_pos ( ) else {
429429 unreachable ! ( "expected encoded `BlockFuel` entry but found none" )
430430 } ;
431431 debug_assert ! ( self . staged. is_none( ) ) ;
432- Ok ( Some ( Pos :: from ( pos) ) )
432+ Ok ( Some ( pos) )
433433 }
434434
435435 /// Encodes a type with [`BranchOffset`] to the [`OpEncoder`] and returns its [`Pos<Op>`] and [`Pos<BranchOffset>`].
@@ -452,12 +452,13 @@ impl OpEncoder {
452452 let offset = self . try_resolve_label ( dst) ?;
453453 let item = make_branch ( offset) ;
454454 let pos_item = self . encode_impl ( item) ?;
455- let pos_offset = match self . ops . take_temp ( ) {
456- Some ( ( pos , TempBuffer :: BranchOffset ) ) => Pos :: from ( pos) ,
455+ let pos_offset = match self . ops . take_reporting_pos ( ) {
456+ Some ( ReportingPos :: BranchOffset ( pos ) ) => pos,
457457 _ => panic ! ( "missing encoded position for `BranchOffset`" ) ,
458458 } ;
459459 if !self . labels . is_pinned ( dst) {
460- self . labels . new_user ( dst, pos_item. value , pos_offset) ;
460+ self . labels
461+ . new_user ( dst, BytePos :: from ( pos_item) , pos_offset) ;
461462 }
462463 debug_assert ! ( self . staged. is_none( ) ) ;
463464 Ok ( ( pos_item, pos_offset) )
0 commit comments