Make {Mutex, Condvar, RwLock}::new() const. by m-ou-se · Pull Request #97791 · rust-lang/rust (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
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
stepancheg, pluiedev, Cassy343, up-to-you, and pronebird reacted with thumbs up emoji taiki-e, wwylele, slanterns, Folyd, darksv, BurntSushi, lcnr, bestgopher, rtzoeller, Kobzol, and 40 more reacted with hooray emoji Noratrieb, Lokathor, CryZe, Dushistov, mati865, saiksy, akiross, Kogia-sima, tux3, IndigoLily, and 9 more reacted with heart emoji
m-ou-se added T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
This change is insta-stable, so needs a completed FCP to proceed.
labels
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 added the final-comment-period
In the final comment period and will be merged soon unless new substantive objections are raised.
label
🔔 This is now entering its final comment period, as per the review above. 🔔
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.
📌 Commit edae495 has been approved by m-ou-se
bors added the S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
label
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
mejrs mentioned this pull request
japaric added a commit to japaric/cargo-call-stack that referenced this pull request
This was referenced
Jun 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request
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)
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
…lnay
Make Barrier::new()
const
I guess this was just missed in rust-lang#97791?
@rustbot
label T-libs-api -T-libs
Labels
This issue / PR is in PFCP or FCP with a disposition to merge it.
The final comment period is finished for this PR / Issue.
This PR was explicitly merged by bors.
This change is insta-stable, so needs a completed FCP to proceed.
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Status: PR is in FCP and is awaiting for FCP to complete.
Relevant to the library API team, which will review and decide on the PR/issue.