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

Make {Mutex, Condvar, RwLock}::new() const. #97791

Merged
merged 2 commits into from
Jun 19, 2022
Merged

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Jun 6, 2022

This makes it possible to have static M: Mutex<_> = Mutex::new(..); 🎉

Our implementations on Linux, on Windows, and various BSDs and some tier 3 platforms have already been using a non-allocating const-constructible implementation. As of #97647, the remaining platforms (most notably macOS) now have a const-constructible implementation as well. This means we can finally make these functions publicly const.

Tracking issue: #93740

@m-ou-se m-ou-se added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. labels Jun 6, 2022
@m-ou-se m-ou-se self-assigned this Jun 6, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 6, 2022
@m-ou-se
Copy link
Member Author

m-ou-se commented Jun 6, 2022

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Jun 6, 2022

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jun 6, 2022
@m-ou-se m-ou-se added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 7, 2022
@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jun 7, 2022
@rfcbot
Copy link

rfcbot commented Jun 7, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jun 7, 2022
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jun 17, 2022
@rfcbot
Copy link

rfcbot commented Jun 17, 2022

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@m-ou-se
Copy link
Member Author

m-ou-se commented Jun 18, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jun 18, 2022

📌 Commit edae495 has been approved by m-ou-se

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 18, 2022
@bors
Copy link
Contributor

bors commented Jun 19, 2022

⌛ Testing commit edae495 with merge 15fc228...

@bors
Copy link
Contributor

bors commented Jun 19, 2022

☀️ Test successful - checks-actions
Approved by: m-ou-se
Pushing 15fc228 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 19, 2022
@bors bors merged commit 15fc228 into rust-lang:master Jun 19, 2022
@rustbot rustbot added this to the 1.63.0 milestone Jun 19, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (15fc228): comparison url.

Instruction count

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-1.7% -1.7% 1
All 😿🎉 (primary) N/A N/A 0

Max RSS (memory usage)

Results
  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
0.0% 0.0% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) 0.0% 0.0% 1

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-3.3% -3.3% 1
Improvements 🎉
(secondary)
-2.3% -2.3% 1
All 😿🎉 (primary) -3.3% -3.3% 1

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@m-ou-se m-ou-se deleted the const-locks branch June 19, 2022 20:52
japaric added a commit to japaric/cargo-call-stack that referenced this pull request Jun 22, 2022
rust-lang/rust#97791 appears to have broken -Z build-std (?)
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Sep 8, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 25, 2022
make Condvar, Mutex, RwLock const constructors work with the `unsupported` impl

applying this patch locally to the `rust-src` component fixes rust-lang#98378

however, the solution seems wrong to me because PR rust-lang#97791 didn't add any `rustc_const_stable` attribute to underlying implementations like `std::sys::unix::futex`, so I must be missing something about how const-stability is checked ... maybe the `restricted_std` feature (gate?) has an effect?

fixes rust-lang#98378
fixes rust-lang#98293 (probably)
@pronebird
Copy link

pronebird commented Feb 10, 2024

It raised my eyebrows when static mutex just worked, that's how I found this page! Holy shit, great work! 💪

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
…lnay

Make `Barrier::new()` const

I guess this was just missed in rust-lang#97791?

`@rustbot` label T-libs-api -T-libs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants