Skip to content
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

Move __thread_local_inner to sys #108927

Merged
merged 3 commits into from
Mar 11, 2023
Merged

Move __thread_local_inner to sys #108927

merged 3 commits into from
Mar 11, 2023

Conversation

Ayush1325
Copy link
Contributor

Move __thread_local_inner macro in crate::thread::local to crate::sys. Initially, I was thinking about removing this macro completely, but I could not find a way to create the generic statics without macros, so in the end, I just moved to code around.

This probably will need a rebase once #108917 is merged

r? @workingjubilee

@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 Mar 9, 2023
@rustbot
Copy link
Collaborator

rustbot commented Mar 9, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@joboet
Copy link
Member

joboet commented Mar 9, 2023

Perhaps it would make sense to split the macro up and use #[cfg] to choose the macro? That would reduce the code the compiler has to look at.

I'm not sure if sys is the right place, but the alternative (sys_common) does not seem to fit either... see also #84187.

@Ayush1325
Copy link
Contributor Author

Perhaps it would make sense to split the macro up and use #[cfg] to choose the macro? That would reduce the code the compiler has to look at.

I'm not sure if sys is the right place, but the alternative (sys_common) does not seem to fit either... see also #84187.

Well, the problem with splitting the macro is that currently, the macro has to be public. As far as I understand, any macro called by the public macro should also be public, which means exporting many macros that are internal implementation details. That's why I initially thought about using functions, but well, it is not possible to have generic statics, so I ended up just moving the whole thing to sys.

Also, I think sys_common is supposed not to have any platform-dependent code, so it probably isn't the correct place. Maybe @devsnek can provide better ideas?

@joboet
Copy link
Member

joboet commented Mar 9, 2023

Well, the problem with splitting the macro is that currently, the macro has to be public. As far as I understand, any macro called by the public macro should also be public, which means exporting many macros that are internal implementation details. That's why I initially thought about using functions, but well, it is not possible to have generic statics, so I ended up just moving the whole thing to sys.

I meant something like this, where the right __thread_local_inner macro is chosen with #[cfg]s.

@Ayush1325
Copy link
Contributor Author

Ayush1325 commented Mar 9, 2023

Well, the problem with splitting the macro is that currently, the macro has to be public. As far as I understand, any macro called by the public macro should also be public, which means exporting many macros that are internal implementation details. That's why I initially thought about using functions, but well, it is not possible to have generic statics, so I ended up just moving the whole thing to sys.

I meant something like this, where the right __thread_local_inner macro is chosen with #[cfg]s.

I see, I will try to do it this way. It would definitely make the code more readable.

@workingjubilee
Copy link
Member

Can we push this into sys/common/thread_local.rs or something like that? I want to keep this as a "directory" file. It's fine if this file grows a couple of additional use declarations.

Move __thread_local_inner macro in crate::thread::local to crate::sys.
Currently, the tidy check does not fail for `library/std/src/thread/local.rs` even though it contains platform specific code. This is beacause target_family did not exist at the time the tidy checks were written [1].

[1]: rust-lang#105861 (comment)

Signed-off-by: Ayush Singh <[email protected]>
Split the __thread_local_inner macro to make it more readable. Also move
everything to crate::sys::common::thread_local.

Signed-off-by: Ayush Singh <[email protected]>
@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Mar 10, 2023
@Ayush1325 Ayush1325 force-pushed the pal-cleanup branch 3 times, most recently from aadefd1 to 5828910 Compare March 10, 2023 17:55
This allows removing all the platform-dependent code from `library/std/src/thread/local.rs` and `library/std/src/thread/mod.rs`

Signed-off-by: Ayush Singh <[email protected]>
@workingjubilee
Copy link
Member

Excellent, thank you!

Let's see what the full CI run says about it.
@bors r+

@bors
Copy link
Contributor

bors commented Mar 10, 2023

📌 Commit 5828910 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors 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 Mar 10, 2023
@workingjubilee
Copy link
Member

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 11, 2023
@workingjubilee
Copy link
Member

Sorry, another review inspired me to take a closer look at some things and I just verified they are actually correct. More confident this will pass in a rollup now.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 11, 2023

📌 Commit 5828910 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 11, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 11, 2023
…bilee

Move __thread_local_inner to sys

Move `__thread_local_inner` macro in `crate::thread::local` to `crate::sys`. Initially, I was thinking about removing this macro completely, but I could not find a way to create the generic statics without macros, so in the end, I just moved to code around.

This probably will need a rebase once rust-lang#108917 is merged

r? `@workingjubilee`
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 11, 2023
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#106276 (Fix `vec_deque::Drain` FIXME)
 - rust-lang#107629 (rustdoc: sort deprecated items lower in search)
 - rust-lang#108711 (Add note when matching token with nonterminal)
 - rust-lang#108757 (rustdoc: Migrate `document_item_info` to Askama)
 - rust-lang#108784 (rustdoc: Migrate sidebar rendering to Askama)
 - rust-lang#108927 (Move __thread_local_inner to sys)
 - rust-lang#108949 (Honor current target when checking conditional compilation values)
 - rust-lang#108950 (Directly construct Inherited in typeck.)
 - rust-lang#108988 (rustdoc: Don't crash on `crate` references in blocks)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5e52ada into rust-lang:master Mar 11, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 11, 2023
@Ayush1325 Ayush1325 deleted the pal-cleanup branch March 12, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc 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.

5 participants