@@ -235,8 +235,7 @@ macro_rules! push_rules {
235
235
236
236
( @match $conclusion_name: ident inputs( ) patterns( ) args( @body ( $judgment_name: ident; $n: literal; $v: expr; $output: expr) ; $inputs: tt; $( $m: tt) * ) ) => {
237
237
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) * ) ;
240
239
} ) ;
241
240
} ;
242
241
@@ -284,28 +283,25 @@ macro_rules! push_rules {
284
283
// expression `v` is carried in from the conclusion and forms the final
285
284
// output of this rule, once all the conditions are evaluated.
286
285
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) * ) => {
288
287
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) * ) ;
291
289
} else {
292
290
$crate:: push_rules!( @record_failure $inputs; $step_index, $c; $crate:: judgment:: RuleFailureCause :: IfFalse {
293
291
expr: stringify!( $c) . to_string( ) ,
294
292
} ) ;
295
293
}
296
294
} ;
297
295
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) * ) => {
299
297
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) * ) ;
302
299
} ;
303
300
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) * ) => {
305
302
let value = & $e;
306
303
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) * ) ;
309
305
} else {
310
306
$crate:: push_rules!( @record_failure $inputs; $step_index, $e; $crate:: judgment:: RuleFailureCause :: IfLetDidNotMatch {
311
307
pattern: stringify!( $p) . to_string( ) ,
@@ -314,14 +310,13 @@ macro_rules! push_rules {
314
310
}
315
311
} ;
316
312
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) * ) => {
318
314
// Explicitly calling `into_iter` silences some annoying lints
319
315
// in the case where `$i` is an `Option` or a `Result`
320
316
match $crate:: judgment:: TryIntoIter :: try_into_iter( $i, || stringify!( $i) . to_string( ) ) {
321
317
Ok ( i) => {
322
- $step_index += 1 ;
323
318
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) * ) ;
325
320
}
326
321
}
327
322
Err ( e) => {
@@ -330,17 +325,15 @@ macro_rules! push_rules {
330
325
}
331
326
} ;
332
327
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) * ) => {
334
329
{
335
330
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) * ) ;
338
332
}
339
333
} ;
340
334
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 ; ) => {
342
336
{
343
- let _ = $step_index; // suppress warnings about value not being read
344
337
let result = $crate:: Upcast :: upcast( $v) ;
345
338
tracing:: debug!( "produced {:?} from rule {:?} in judgment {:?}" , result, $rule_name, stringify!( $judgment_name) ) ;
346
339
$output. insert( result)
@@ -349,7 +342,7 @@ macro_rules! push_rules {
349
342
350
343
//
351
344
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) => {
353
346
let file = $crate:: respan!( $step_expr ( file!( ) ) ) ;
354
347
let line = $crate:: respan!( $step_expr ( line!( ) ) ) ;
355
348
let column = $crate:: respan!( $step_expr ( column!( ) ) ) ;
0 commit comments