Skip to content

Commit d1b8c9b

Browse files
Merge pull request #22652 from ChayimFriedman2/doc-macro-recursion-limit
fix: Respect the recursion limit for `#![doc = macro!()]`
2 parents 5d15d9f + 7a57380 commit d1b8c9b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

crates/hir-def/src/attrs/docs.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ fn expand_doc_expr_via_macro_pipeline<'db>(
353353
let macro_call = macro_expr.macro_call()?;
354354
let (expr, new_source_ctx) = expand_doc_macro_call(expander, source_ctx, macro_call)?;
355355
// After expansion, the expr lives in the expansion file; use its source context.
356-
expand_doc_expr_via_macro_pipeline(expander, &new_source_ctx, expr)
356+
expander.recursion_depth += 1;
357+
let expansion = expand_doc_expr_via_macro_pipeline(expander, &new_source_ctx, expr);
358+
expander.recursion_depth -= 1;
359+
expansion
357360
}
358361
_ => None,
359362
}
@@ -389,10 +392,8 @@ fn expand_doc_macro_call<'db>(
389392
.ok()?
390393
.value?;
391394

392-
expander.recursion_depth += 1;
393395
let parse = expander.db.parse_macro_expansion(call_id).value.0.clone();
394396
let expr = parse.cast::<ast::Expr>().map(|parse| parse.tree())?;
395-
expander.recursion_depth -= 1;
396397

397398
// Build a new source context for the expansion file so that any further
398399
// recursive expansion (e.g. a user macro expanding to `concat!(...)`)

0 commit comments

Comments
 (0)