Skip to content

Document the recursion_limit built-in attribute - #162369

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
kiana1kaslana:doc-recursion-limit-attribute
Oct 21, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
kiana1kaslana:doc-recursion-limit-attribute

Conversation

@kiana1kaslana

@kiana1kaslana kiana1kaslana commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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.

@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
Contributor 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.

@rust-bors

This comment has been minimized.

@JohnTitor

Copy link
Copy Markdown
Member

LGTM, could you resolve the conflict?

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 8576dc3 to f35da9e Compare October 20, 2026 12:22
@rustbot

rustbot commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@kiana1kaslana

Copy link
Copy Markdown
Contributor Author

Alright, resolved conflicts, thanks.

@JohnTitor JohnTitor left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f35da9e has been approved by JohnTitor

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 21, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 21, 2026
…attribute, r=JohnTitor

Document the `recursion_limit` built-in attribute

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 rust-lang#157604 (comment).

Part of rust-lang#157604.
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #162460 (Feat - `#[inline(always)] + #[target_feature(enable = "....")]` #2)
 - #163485 (`rustc_builtin_macros` cleanup, part 8)
 - #164578 (Don't ignore unknown LLVM diagnostics)
 - #162369 (Document the `recursion_limit` built-in attribute)
 - #162840 (tier 3 target policy: target CPU and features must be supported by upstream backend)
 - #164330 (Skip redundant monomorphization checks)
 - #164656 (stabilize ExitCodeExt for Windows)
 - #164660 (Touch up attribute docs)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 21, 2026
…attribute, r=JohnTitor

Document the `recursion_limit` built-in attribute

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 rust-lang#157604 (comment).

Part of rust-lang#157604.
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #162460 (Feat - `#[inline(always)] + #[target_feature(enable = "....")]` #2)
 - #163485 (`rustc_builtin_macros` cleanup, part 8)
 - #164457 (Add `vec_visualizer` lldb test)
 - #161253 (Implement `AsMut<T>` and `AsRef<T>` for `!`.)
 - #162369 (Document the `recursion_limit` built-in attribute)
 - #162840 (tier 3 target policy: target CPU and features must be supported by upstream backend)
 - #164329 (use default_field_values in declare_lint)
 - #164330 (Skip redundant monomorphization checks)
 - #164527 (doc: added addtional docs for Write)
 - #164656 (stabilize ExitCodeExt for Windows)
 - #164660 (Touch up attribute docs)
 - #164681 (tidy: use repository-relative path for style checks)
 - #164688 (re-enable test_dir_remove_dir test on QNX)
@rust-bors
rust-bors Bot merged commit d308c2e into rust-lang:main Oct 21, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
Rollup merge of #162369 - kiana1kaslana:doc-recursion-limit-attribute, r=JohnTitor

Document the `recursion_limit` built-in attribute

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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