diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2024-10-12 21:38:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-12 21:38:35 -0500 |
| commit | c8b2f7e458a23511ec6bcdac5c88faed2034b81b (patch) | |
| tree | 6074ce8be99f67853e2807b26d59e3d0beb728eb /compiler | |
| parent | ef4e8259b5016d85e261587b605028b2ff06c13d (diff) | |
| parent | 19f6c17df486c5f70c1000ecada39c62b9c93550 (diff) | |
| download | rust-c8b2f7e458a23511ec6bcdac5c88faed2034b81b.tar.gz rust-c8b2f7e458a23511ec6bcdac5c88faed2034b81b.zip | |
Rollup merge of #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: <https://github.com/rust-lang/rust/issues/67441>
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_serialize/src/lib.rs | 1 |
2 files changed, 0 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 70e61df1ab4..e9b73d25ba2 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -37,7 +37,6 @@ #![feature(box_as_ptr)] #![feature(box_patterns)] #![feature(closure_track_caller)] -#![feature(const_option)] #![feature(const_type_name)] #![feature(core_intrinsics)] #![feature(coroutines)] diff --git a/compiler/rustc_serialize/src/lib.rs b/compiler/rustc_serialize/src/lib.rs index b7977a848ce..47f72298e22 100644 --- a/compiler/rustc_serialize/src/lib.rs +++ b/compiler/rustc_serialize/src/lib.rs @@ -10,7 +10,6 @@ test(attr(allow(unused_variables), deny(warnings))) )] #![doc(rust_logo)] -#![feature(const_option)] #![feature(core_intrinsics)] #![feature(min_specialization)] #![feature(never_type)] |
