Skip to content

Add documentation for the cold and track_caller attributes#158484

Open
valentynkit wants to merge 1 commit into
rust-lang:mainfrom
valentynkit:docs-cold-track-caller-attributes
Open

Add documentation for the cold and track_caller attributes#158484
valentynkit wants to merge 1 commit into
rust-lang:mainfrom
valentynkit:docs-cold-track-caller-attributes

Conversation

@valentynkit

@valentynkit valentynkit commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Adds cold and track_caller, the two code generation attributes left from my claim on the tracking issue.

Both stay guide-level, with one runnable example each. For track_caller I used a small assert-style helper, since the attribute mainly affects which line a panic points at. inline is already up in #158348.

Part of #157604

r? @GuillaumeGomez

Tested with ./x test library/std --doc --test-args attribute_docs.

@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 Jun 27, 2026
@rust-bors

This comment has been minimized.

@valentynkit valentynkit force-pushed the docs-cold-track-caller-attributes branch from a5d8d3c to ea8581e Compare July 9, 2026 15:42
@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@valentynkit valentynkit force-pushed the docs-cold-track-caller-attributes branch from ea8581e to 3cc0b65 Compare July 13, 2026 11:31
@rustbot

This comment has been minimized.

@valentynkit

Copy link
Copy Markdown
Contributor Author

@GuillaumeGomez could you please check this PR?

Comment thread library/core/src/attribute_docs.rs Outdated
Comment on lines +414 to +415
/// optimize for the common case where the function is not called. Like `inline`, it is only a
/// hint and does not change the function's behavior.

@GuillaumeGomez GuillaumeGomez Jul 14, 2026

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.

Instead of mentioning inline, please instead "inline" (hehe) the compiler hint explanation here as well.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied the changes.

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

Just one change but otherwise looks good to me.

View changes since this review

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 14, 2026
@rustbot

rustbot commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 14, 2026
@rust-bors

This comment has been minimized.

Document the built-in `cold` and `track_caller` attributes in the standard
library using the `#[doc(attribute = "...")]` mechanism, following the
existing `must_use` and `inline` attribute documentation.
@valentynkit valentynkit force-pushed the docs-cold-track-caller-attributes branch from 3cc0b65 to 0858f89 Compare July 15, 2026 12:04
@rustbot

rustbot commented Jul 15, 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.

@valentynkit

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 15, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0858f89 has been approved by GuillaumeGomez

It is now in the queue for this repository.

@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 Jul 15, 2026
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.

3 participants