-
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
Stabilize const_option
#131120
Stabilize const_option
#131120
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy The Miri subtree was changed cc @rust-lang/miri |
FCP started today so should complete on the 11th. The beta branch is the same day, so if this gets approved before then, this API will make 1.83.
|
That's fine from my side. |
library/core/src/option.rs
Outdated
@@ -1712,7 +1716,9 @@ impl<T> Option<T> { | |||
/// ``` | |||
#[inline] | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
#[rustc_const_unstable(feature = "const_option", issue = "67441")] | |||
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] | |||
#[rustc_allow_const_fn_unstable(const_replace)] // todo: drop if we don't get stable const_replace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still in FCP at #130954, so we have to wait until tomorrow before we can land this PR as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That just merged so I was able to update & drop those gates.
This makes the following API stable in const contexts: impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <rust-lang#67441>
5af32ad
to
19f6c17
Compare
FCP complete at #67441 (comment). |
Looks great :)
@bors r+ rollup
|
…=RalfJung Stabilize `const_option` This makes the following API stable in const contexts: ```rust impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } ``` The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <rust-lang#67441>
Rollup of 7 pull requests Successful merges: - rust-lang#131120 (Stabilize `const_option`) - rust-lang#131207 (ci: aarch64-gnu-debug job) - rust-lang#131334 (Enable sanitizers for loongarch64-unknown-*) - rust-lang#131358 (force "HEAD" for non-CI and `git_upstream_merge_base` for CI environment) - rust-lang#131418 (Use throw intrinsic from stdarch in wasm libunwind) - rust-lang#131579 (Remap path prefix in the panic message of `tests/ui/meta/revision-bad.rs`) - rust-lang#131591 (add latest crash tests) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang#131120 (Stabilize `const_option`) - rust-lang#131334 (Enable sanitizers for loongarch64-unknown-*) - rust-lang#131358 (force "HEAD" for non-CI and `git_upstream_merge_base` for CI environment) - rust-lang#131418 (Use throw intrinsic from stdarch in wasm libunwind) - rust-lang#131579 (Remap path prefix in the panic message of `tests/ui/meta/revision-bad.rs`) - rust-lang#131591 (add latest crash tests) - rust-lang#131626 (remove a couple of redundant String to String conversion) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131120 - tgross35:stabilize-const_option, r=RalfJung Stabilize `const_option` This makes the following API stable in const contexts: ```rust impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } ``` The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <rust-lang#67441>
It looks like this may have made the version cutoff after all 🎉 lucky us that a LLVM bump delayed #131560 |
…=RalfJung Stabilize `const_option` This makes the following API stable in const contexts: ```rust impl<T> Option<T> { pub const fn as_mut(&mut self) -> Option<&mut T>; pub const fn expect(self, msg: &str) -> T; pub const fn unwrap(self) -> T; pub const unsafe fn unwrap_unchecked(self) -> T; pub const fn take(&mut self) -> Option<T>; pub const fn replace(&mut self, value: T) -> Option<T>; } impl<T> Option<&T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T> Option<&mut T> { pub const fn copied(self) -> Option<T> where T: Copy; } impl<T, E> Option<Result<T, E>> { pub const fn transpose(self) -> Result<Option<T>, E> } impl<T> Option<Option<T>> { pub const fn flatten(self) -> Option<T>; } ``` The following functions make use of the unstable `const_precise_live_drops` feature: - `expect` - `unwrap` - `unwrap_unchecked` - `transpose` - `flatten` Fixes: <rust-lang#67441>
This makes the following API stable in const contexts:
The following functions make use of the unstable
const_precise_live_drops
feature:expect
unwrap
unwrap_unchecked
transpose
flatten
Fixes: #67441
Cc @rust-lang/wg-const-eval