Skip to content

Document the recursion_limit built-in attribute - #162369

Open
kiana1kaslana wants to merge 1 commit into
rust-lang:mainfrom
kiana1kaslana:doc-recursion-limit-attribute
Open

Document the recursion_limit built-in attribute#162369
kiana1kaslana wants to merge 1 commit into
rust-lang:mainfrom
kiana1kaslana:doc-recursion-limit-attribute

Conversation

@kiana1kaslana

@kiana1kaslana kiana1kaslana commented Sep 6, 2026

Copy link
Copy Markdown

Document the recursion_limit built-in attribute in std via
#[doc(attribute = "recursion_limit")], covering:

  • what the limit applies to (macro expansion, auto-dereference)
  • the default (128) and how to raise it
  • the diagnostics produced when the limit is reached
  • a note on when raising it is appropriate

As claimed in #157604 (comment).

Part of #157604.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 6, 2026
@rustbot

rustbot commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @JohnTitor (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey

@rustbot

This comment has been minimized.

@kiana1kaslana
kiana1kaslana force-pushed the doc-recursion-limit-attribute branch from 9f9f9fa to b0d3fe7 Compare September 6, 2026 11:46
@lukaslueg

Copy link
Copy Markdown
Contributor

Personal drive-by suggestions: While the docs do introduce "compile-time operations" explicitly, I suggest to go one step further add a clarifying sentence wrt not having anything to do with run-time recursion; people have confused the attribute to affect recursive code, which it does not. Also I suggest to explicitly advise readers to increase the limit in measured steps instead of just punching in 9999999; punching the limit may cause other people to experience resource exhaustion and general sadness due to what in their case is an unlimited infinite recursion.

Adds an entry for `recursion_limit` to `library/core/src/attribute_docs.rs`
using `#[doc(attribute = "...")]`.
@kiana1kaslana
kiana1kaslana force-pushed the doc-recursion-limit-attribute branch from b0d3fe7 to 8576dc3 Compare September 6, 2026 12:40
@kiana1kaslana

Copy link
Copy Markdown
Author

Personal drive-by suggestions: While the docs do introduce "compile-time operations" explicitly, I suggest to go one step further add a clarifying sentence wrt not having anything to do with run-time recursion; people have confused the attribute to affect recursive code, which it does not. Also I suggest to explicitly advise readers to increase the limit in measured steps instead of just punching in 9999999; punching the limit may cause other people to experience resource exhaustion and general sadness due to what in their case is an unlimited infinite recursion.

Good points, thanks. I added a clarifying sentence that the limit is compile-time only and has no effect on runtime recursion, and I explicitly advise raising it in measured steps instead of jumping to a very large number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants