@@ -235,8 +235,7 @@ macro_rules! push_rules {
235235
236236 ( @match $conclusion_name: ident inputs( ) patterns( ) args( @body ( $judgment_name: ident; $n: literal; $v: expr; $output: expr) ; $inputs: tt; $( $m: tt) * ) ) => {
237237 tracing:: trace_span!( "matched rule" , rule = $n, judgment = stringify!( $judgment_name) ) . in_scope( || {
238- let mut step_index = 0 ;
239- $crate:: push_rules!( @body ( $judgment_name, $n, $v, $output) ; $inputs; step_index; $( $m) * ) ;
238+ $crate:: push_rules!( @body ( $judgment_name, $n, $v, $output) ; $inputs; 0 ; $( $m) * ) ;
240239 } ) ;
241240 } ;
242241
@@ -284,28 +283,25 @@ macro_rules! push_rules {
284283 // expression `v` is carried in from the conclusion and forms the final
285284 // output of this rule, once all the conditions are evaluated.
286285
287- ( @body $args: tt; $inputs: tt; $step_index: ident ; ( if $c: expr) $( $m: tt) * ) => {
286+ ( @body $args: tt; $inputs: tt; $step_index: expr ; ( if $c: expr) $( $m: tt) * ) => {
288287 if $c {
289- $step_index += 1 ;
290- $crate:: push_rules!( @body $args; $inputs; $step_index; $( $m) * ) ;
288+ $crate:: push_rules!( @body $args; $inputs; $step_index + 1 ; $( $m) * ) ;
291289 } else {
292290 $crate:: push_rules!( @record_failure $inputs; $step_index, $c; $crate:: judgment:: RuleFailureCause :: IfFalse {
293291 expr: stringify!( $c) . to_string( ) ,
294292 } ) ;
295293 }
296294 } ;
297295
298- ( @body $args: tt; $inputs: tt; $step_index: ident ; ( assert $c: expr) $( $m: tt) * ) => {
296+ ( @body $args: tt; $inputs: tt; $step_index: expr ; ( assert $c: expr) $( $m: tt) * ) => {
299297 assert!( $c) ;
300- $step_index += 1 ;
301- $crate:: push_rules!( @body $args; $inputs; $step_index; $( $m) * ) ;
298+ $crate:: push_rules!( @body $args; $inputs; $step_index + 1 ; $( $m) * ) ;
302299 } ;
303300
304- ( @body $args: tt; $inputs: tt; $step_index: ident ; ( if let $p: pat = $e: expr) $( $m: tt) * ) => {
301+ ( @body $args: tt; $inputs: tt; $step_index: expr ; ( if let $p: pat = $e: expr) $( $m: tt) * ) => {
305302 let value = & $e;
306303 if let $p = Clone :: clone( value) {
307- $step_index += 1 ;
308- $crate:: push_rules!( @body $args; $inputs; $step_index; $( $m) * ) ;
304+ $crate:: push_rules!( @body $args; $inputs; $step_index + 1 ; $( $m) * ) ;
309305 } else {
310306 $crate:: push_rules!( @record_failure $inputs; $step_index, $e; $crate:: judgment:: RuleFailureCause :: IfLetDidNotMatch {
311307 pattern: stringify!( $p) . to_string( ) ,
@@ -314,14 +310,13 @@ macro_rules! push_rules {
314310 }
315311 } ;
316312
317- ( @body $args: tt; $inputs: tt; $step_index: ident ; ( $i: expr => $p: pat) $( $m: tt) * ) => {
313+ ( @body $args: tt; $inputs: tt; $step_index: expr ; ( $i: expr => $p: pat) $( $m: tt) * ) => {
318314 // Explicitly calling `into_iter` silences some annoying lints
319315 // in the case where `$i` is an `Option` or a `Result`
320316 match $crate:: judgment:: TryIntoIter :: try_into_iter( $i, || stringify!( $i) . to_string( ) ) {
321317 Ok ( i) => {
322- $step_index += 1 ;
323318 for $p in std:: iter:: IntoIterator :: into_iter( i) {
324- $crate:: push_rules!( @body $args; $inputs; $step_index; $( $m) * ) ;
319+ $crate:: push_rules!( @body $args; $inputs; $step_index + 1 ; $( $m) * ) ;
325320 }
326321 }
327322 Err ( e) => {
@@ -330,17 +325,15 @@ macro_rules! push_rules {
330325 }
331326 } ;
332327
333- ( @body $args: tt; $inputs: tt; $step_index: ident ; ( let $p: pat = $i: expr) $( $m: tt) * ) => {
328+ ( @body $args: tt; $inputs: tt; $step_index: expr ; ( let $p: pat = $i: expr) $( $m: tt) * ) => {
334329 {
335330 let $p = $i;
336- $step_index += 1 ;
337- $crate:: push_rules!( @body $args; $inputs; $step_index; $( $m) * ) ;
331+ $crate:: push_rules!( @body $args; $inputs; $step_index + 1 ; $( $m) * ) ;
338332 }
339333 } ;
340334
341- ( @body ( $judgment_name: ident, $rule_name: literal, $v: expr, $output: expr) ; $inputs: tt; $step_index: ident ; ) => {
335+ ( @body ( $judgment_name: ident, $rule_name: literal, $v: expr, $output: expr) ; $inputs: tt; $step_index: expr ; ) => {
342336 {
343- let _ = $step_index; // suppress warnings about value not being read
344337 let result = $crate:: Upcast :: upcast( $v) ;
345338 tracing:: debug!( "produced {:?} from rule {:?} in judgment {:?}" , result, $rule_name, stringify!( $judgment_name) ) ;
346339 $output. insert( result)
@@ -349,7 +342,7 @@ macro_rules! push_rules {
349342
350343 //
351344
352- ( @record_failure ( $failed_rules: expr, $match_index: expr, $inputs: tt, $rule_name: literal) ; $step_index: ident , $step_expr: expr; $cause: expr) => {
345+ ( @record_failure ( $failed_rules: expr, $match_index: expr, $inputs: tt, $rule_name: literal) ; $step_index: expr , $step_expr: expr; $cause: expr) => {
353346 let file = $crate:: respan!( $step_expr ( file!( ) ) ) ;
354347 let line = $crate:: respan!( $step_expr ( line!( ) ) ) ;
355348 let column = $crate:: respan!( $step_expr ( column!( ) ) ) ;
0 commit comments