@@ -234,6 +234,7 @@ impl<'matcher> Tracker<'matcher> for NoopTracker {
234
234
235
235
/// Expands the rules based macro defined by `lhses` and `rhses` for a given
236
236
/// input `arg`.
237
+ #[instrument(skip(cx, transparency, arg, lhses, rhses))]
237
238
fn expand_macro<'cx>(
238
239
cx: &'cx mut ExtCtxt<'_>,
239
240
sp: Span,
@@ -429,6 +430,7 @@ enum CanRetry {
429
430
/// Try expanding the macro. Returns the index of the sucessful arm and its named_matches if it was successful,
430
431
/// and nothing if it failed. On failure, it's the callers job to use `track` accordingly to record all errors
431
432
/// correctly.
433
+ #[instrument(level = "debug", skip(sess, arg, lhses, track), fields(tracking = %T::description()))]
432
434
fn try_match_macro<'matcher, T: Tracker<'matcher>>(
433
435
sess: &ParseSess,
434
436
name: Ident,
@@ -460,6 +462,8 @@ fn try_match_macro<'matcher, T: Tracker<'matcher>>(
460
462
// Try each arm's matchers.
461
463
let mut tt_parser = TtParser::new(name);
462
464
for (i, lhs) in lhses.iter().enumerate() {
465
+ let _tracing_span = trace_span!("Matching arm", %i);
466
+
463
467
// Take a snapshot of the state of pre-expansion gating at this point.
464
468
// This is used so that if a matcher is not `Success(..)`ful,
465
469
// then the spans which became gated when parsing the unsuccessful matcher
@@ -472,20 +476,24 @@ fn try_match_macro<'matcher, T: Tracker<'matcher>>(
472
476
473
477
match result {
474
478
Success(named_matches) => {
479
+ debug!("Parsed arm successfully");
475
480
// The matcher was `Success(..)`ful.
476
481
// Merge the gated spans from parsing the matcher with the pre-existing ones.
477
482
sess.gated_spans.merge(gated_spans_snapshot);
478
483
479
484
return Ok((i, named_matches));
480
485
}
481
486
Failure(_, _) => {
487
+ trace!("Failed to match arm, trying the next one");
482
488
// Try the next arm
483
489
}
484
490
Error(_, _) => {
491
+ debug!("Fatal error occurred during matching");
485
492
// We haven't emitted an error yet
486
493
return Err(CanRetry::Yes);
487
494
}
488
495
ErrorReported(guarantee) => {
496
+ debug!("Fatal error occurred and was reported during matching");
489
497
return Err(CanRetry::No(guarantee));
490
498
}
491
499
}
0 commit comments