Skip to content

thread_local! doc improvements + tests for operational pedantics - #163387

Open
clarfonthey wants to merge 1 commit into
rust-lang:mainfrom
clarfonthey:thread-local
Open

clarfonthey wants to merge 1 commit into
rust-lang:mainfrom
clarfonthey:thread-local

Conversation

@clarfonthey

@clarfonthey clarfonthey commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

cc @RalfJung who requested these in #159564.

r? libs

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 26, 2026

@clarfonthey clarfonthey Sep 26, 2026 •

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.

cc @RalfJung since you mentioned having tests for this. Admittedly, I kind of struggled to come up with anything for this that might be even remotely sensible (and these aren't that), but, please feel free to comment whether this is satisfactory.

View changes since the review

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.

Yeah that's fair, I wasn't sure either. It just felt like something we should test for.

@rust-bors

This comment has been minimized.

@clarfonthey
clarfonthey marked this pull request as ready for review September 26, 2026 23:49
@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 Sep 26, 2026
Comment on lines +84 to +87
// NOTE: The `PhantomData` here is a nice trick to ensure that *all* usages of `$t` can be
// inferred to have static lifetimes. This function definition would normally *not* be such
// a definition, but because lifetime elision tends to prefer lifetimes matching arguments
// to a function, the `'static` lifetime inside the `PhantomData` qualifies here.

@RalfJung RalfJung Sep 27, 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.

Suggested change
// NOTE: The `PhantomData` here is a nice trick to ensure that *all* usages of `$t` can be
// inferred to have static lifetimes. This function definition would normally *not* be such
// a definition, but because lifetime elision tends to prefer lifetimes matching arguments
// to a function, the `'static` lifetime inside the `PhantomData` qualifies here.
// NOTE: The `PhantomData` here is a nice trick to ensure that *all* usages of `$t` can be
// inferred to have static lifetimes: if `$t` has missing lifetimes, like `&str`,
// then lifetime elision will pick up the only lifetime in the argument,
// `'static`. The we type-check `$init` against that expanded type.

View changes since the review

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

This branch has not been deployed

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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