Skip to content

Commit

Permalink
Rollup merge of #132966 - RalfJung:const_option_ext, r=jhpratt
Browse files Browse the repository at this point in the history
stabilize const_option_ext

Fixes #91930

FCP passed in that issue.
  • Loading branch information
matthiaskrgr authored Nov 12, 2024
2 parents b952f2e + 324d059 commit ae5c00f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
#![feature(const_float_methods)]
#![feature(const_heap)]
#![feature(const_nonnull_new)]
#![feature(const_option_ext)]
#![feature(const_pin_2)]
#![feature(const_ptr_is_null)]
#![feature(const_ptr_sub_ptr)]
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ impl<T> Option<T> {
#[inline]
#[must_use]
#[stable(feature = "pin", since = "1.33.0")]
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
#[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> {
// FIXME(const-hack): use `map` once that is possible
match Pin::get_ref(self).as_ref() {
Expand All @@ -755,7 +755,7 @@ impl<T> Option<T> {
#[inline]
#[must_use]
#[stable(feature = "pin", since = "1.33.0")]
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
#[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> {
// SAFETY: `get_unchecked_mut` is never used to move the `Option` inside `self`.
// `x` is guaranteed to be pinned because it comes from `self` which is pinned.
Expand Down Expand Up @@ -802,7 +802,7 @@ impl<T> Option<T> {
#[inline]
#[must_use]
#[stable(feature = "option_as_slice", since = "1.75.0")]
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
#[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_slice(&self) -> &[T] {
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
// to the payload, with a length of 1, so this is equivalent to
Expand Down Expand Up @@ -857,7 +857,7 @@ impl<T> Option<T> {
#[inline]
#[must_use]
#[stable(feature = "option_as_slice", since = "1.75.0")]
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
#[rustc_const_stable(feature = "const_option_ext", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_mut_slice(&mut self) -> &mut [T] {
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
// to the payload, with a length of 1, so this is equivalent to
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#![feature(const_eval_select)]
#![feature(const_heap)]
#![feature(const_nonnull_new)]
#![feature(const_option_ext)]
#![feature(const_pin_2)]
#![feature(const_trait_impl)]
#![feature(core_intrinsics)]
Expand Down

0 comments on commit ae5c00f

Please sign in to comment.