Make {Mutex, Condvar, RwLock}::new() const.#97791
Conversation
|
@rfcbot merge |
|
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. |
|
🔔 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. |
|
@bors r+ |
|
📌 Commit edae495 has been approved by |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (15fc228): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
rust-lang/rust#97791 appears to have broken -Z build-std (?)
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! 💪 |
…lnay Make `Barrier::new()` const I guess this was just missed in rust-lang#97791? `@rustbot` label T-libs-api -T-libs
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