-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More const {} init in thread_local #137194
Conversation
was 40cf00a meant to be part of this PR? (not particularly that I have an issue with it, just curious since it's not obvious why this PR would come with that particular test). |
This comment has been minimized.
This comment has been minimized.
...well, okay, to be clear bors is going to take issue with it so you probably can't get this merged with that commit |
I think that commit is included because |
@rustbot author for the above |
I've put the test in the same commit it tests, and added a comment why. ad56664 |
As far as I know, thread locals must appear as different addresses when accessed from different threads, so whether a constant or lazy initializer was used shouldn't make a difference here. The sanity check certainly doesn't hurt though. (I'm going to double check with opsem to make sure this is accurate) Thanks for the changes! @bors r+ |
Rollup of 9 pull requests Successful merges: - rust-lang#135354 ([Debuginfo] Add MSVC Synthetic and Summary providers to LLDB) - rust-lang#136826 (Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in Unix) - rust-lang#137194 (More const {} init in thread_local) - rust-lang#137334 (Greatly simplify lifetime captures in edition 2024) - rust-lang#137382 (bootstrap: add doc for vendor build step) - rust-lang#137423 (Improve a bit HIR pretty printer) - rust-lang#137435 (Fix "missing match arm body" suggestion involving `!`) - rust-lang#137448 (Fix bugs due to unhandled `ControlFlow` in compiler) - rust-lang#137458 (Fix missing self subst when rendering `impl Fn*<T>` with no output type) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#137194 - kornelski:ftls, r=tgross35 More const {} init in thread_local `const {}` in `thread_local!` gets an optimization just based on the syntax, rather than the expression being const-compatible. This is easy to miss, so I've added more examples to the docs. I've also added `const {}` in a couple of places in std where this optimization has been missed.
const {}
inthread_local!
gets an optimization just based on the syntax, rather than the expression being const-compatible. This is easy to miss, so I've added more examples to the docs.I've also added
const {}
in a couple of places in std where this optimization has been missed.