Document const-initialization for thread_local! macro#109908
Document const-initialization for thread_local! macro#109908AnthonyMikh wants to merge 1 commit intorust-lang:masterfrom
thread_local! macro#109908Conversation
|
(rustbot has picked a reviewer for you, use r? to override) |
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
169925f to
0b23d47
Compare
|
Documenting this looks great to me. I do however have a concern about going into the details of const contexts. It talks a bit about what can and can't be done in const contexts, which is more or less true enough today but might not be tomorrow. E.g. "doing so does not change the behavior" and the failing example using Documenting the current const details may be useful but I'm not sure that this is the place to do it. |
|
@ChrisDenton I understand your concerns, but I think that without such a counterexample the documentation would be incomplete. Besides, it is a |
| /// Doing so does not change the behavior, but might enable more efficient implementation | ||
| /// of [`LocalKey`][`std::thread::LocalKey`] on supported platforms. |
There was a problem hiding this comment.
Fair enough. Then I would narrow my concerns to the following suggestion:
| /// Doing so does not change the behavior, but might enable more efficient implementation | |
| /// of [`LocalKey`][`std::thread::LocalKey`] on supported platforms. | |
| /// Doing so might enable more efficient implementation | |
| /// of [`LocalKey`][`std::thread::LocalKey`] on supported platforms. |
|
Superseded by now merged #110620 |
#83416 added const initialization for statics in
std::thread::thread_localmacro. Surprisingly, it was merged completely undocumented, so I suspect most of Rust users are not even aware of this functionality. This PR intents to close this gap.@rustbot labels: +A-docs