diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-10-27 22:03:34 +0200 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-11-02 21:09:41 +0100 |
| commit | 1e21b3cfa38c5040ae0faf99178b0112fc90fd93 (patch) | |
| tree | 0f4f16e337d63a2a9acca3a0b637d9d0e59f14d0 /compiler/rustc_expand/src | |
| parent | 5f73eac51bebc2c2a9768a84e029cbd719cdb6dc (diff) | |
| download | rust-1e21b3cfa38c5040ae0faf99178b0112fc90fd93.tar.gz rust-1e21b3cfa38c5040ae0faf99178b0112fc90fd93.zip | |
Add some debug logs to macro matching
These were useful while debugging, so I'll leave them here.
Diffstat (limited to 'compiler/rustc_expand/src')
| -rw-r--r-- | compiler/rustc_expand/src/mbe/macro_rules.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index b1214543e5d..78b3fa337ae 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -234,6 +234,7 @@ impl<'matcher> Tracker<'matcher> for NoopTracker { /// Expands the rules based macro defined by `lhses` and `rhses` for a given /// input `arg`. +#[instrument(skip(cx, transparency, arg, lhses, rhses))] fn expand_macro<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, @@ -429,6 +430,7 @@ enum CanRetry { /// Try expanding the macro. Returns the index of the sucessful arm and its named_matches if it was successful, /// and nothing if it failed. On failure, it's the callers job to use `track` accordingly to record all errors /// correctly. +#[instrument(level = "debug", skip(sess, arg, lhses, track), fields(tracking = %T::description()))] fn try_match_macro<'matcher, T: Tracker<'matcher>>( sess: &ParseSess, name: Ident, @@ -460,6 +462,8 @@ fn try_match_macro<'matcher, T: Tracker<'matcher>>( // Try each arm's matchers. let mut tt_parser = TtParser::new(name); for (i, lhs) in lhses.iter().enumerate() { + let _tracing_span = trace_span!("Matching arm", %i); + // Take a snapshot of the state of pre-expansion gating at this point. // This is used so that if a matcher is not `Success(..)`ful, // then the spans which became gated when parsing the unsuccessful matcher @@ -472,6 +476,7 @@ fn try_match_macro<'matcher, T: Tracker<'matcher>>( match result { Success(named_matches) => { + debug!("Parsed arm successfully"); // The matcher was `Success(..)`ful. // Merge the gated spans from parsing the matcher with the pre-existing ones. sess.gated_spans.merge(gated_spans_snapshot); @@ -479,13 +484,16 @@ fn try_match_macro<'matcher, T: Tracker<'matcher>>( return Ok((i, named_matches)); } Failure(_, _) => { + trace!("Failed to match arm, trying the next one"); // Try the next arm } Error(_, _) => { + debug!("Fatal error occurred during matching"); // We haven't emitted an error yet return Err(CanRetry::Yes); } ErrorReported(guarantee) => { + debug!("Fatal error occurred and was reported during matching"); return Err(CanRetry::No(guarantee)); } } |
