-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 some Option, Result methods unstably const #82130
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
These functions implicitly depend on |
Triage: @ecstatic-morse seems busy recently, r? @RalfJung could you take a look? |
This LGTM; Cc @rust-lang/wg-const-eval |
With regard to the const-hack label, should we really consider this a hack? I just quickly checked on godbolt, and it looks like the new implementation actually optimizes slightly better at lower opt levels. Not a huge deal either way, but I figure we may as well take a minuscule performance gain where we can. The implementation is straightforward in either situation. |
We typically use that label when code gets changed to be const-compatible. I don't feel competent to evaluate whether the old or the new implementation is better, but I can imagine that avoiding higher-order functions helps. @oli-obk what do you think? |
I actually prefer the new implementation since imo it's more readable, even if the old version is more compact |
All right, I tend to agree so I removed the label. |
The following functions are now unstably const: - Option::transpose - Option::flatten - Result::transpose
@bors r+ rollup |
📌 Commit 79c2b75 has been approved by |
…Jung Make some Option, Result methods unstably const The following methods are now unstably const: - Option::transpose - Option::flatten - Result::flatten While some methods for could likely be made `const` in the future, nearly all of them require something to be dropped at compile-time, which isn't currently supported. The functions listed above should have a trivial path to stabilization.
Rollup of 13 pull requests Successful merges: - rust-lang#77916 (Change built-in kernel targets to be os = none throughout) - rust-lang#82130 (Make some Option, Result methods unstably const) - rust-lang#82292 (Prevent specialized ZipImpl from calling `__iterator_get_unchecked` twice with the same index) - rust-lang#82402 (Remove RefCell around `module_trait_cache`) - rust-lang#82592 (Improve transmute docs with further clarifications) - rust-lang#82651 (Cleanup rustdoc warnings) - rust-lang#82720 (Fix diagnostic suggests adding type `[type error]`) - rust-lang#82751 (improve offset_from docs) - rust-lang#82793 (Move some tests to more suitable subdirs) - rust-lang#82803 (rustdoc: Add an unstable option to print all unversioned files) - rust-lang#82808 (Sync rustc_codegen_cranelift) - rust-lang#82822 (Fix typo) - rust-lang#82837 (tweak MaybeUninit docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The following methods are now unstably const:
While some methods for could likely be made
const
in the future, nearly all of them require something to be dropped at compile-time, which isn't currently supported. The functions listed above should have a trivial path to stabilization.