about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCDirkx <christiaan@dirkx.com>2020-08-31 02:11:48 +0200
committerChristiaan <christiaan@dirkx.email>2020-09-20 22:42:14 +0200
commit9486f728790e1fb15bb88db672d2f164078a19eb (patch)
tree16577702f0e9891da45a38f8e66a836fbe8ac6c5
parent81e02708f1f4760244756548981277d5199baa9a (diff)
Stabilize some Option methods as const
Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

Possible because of stabilization of #49146 (Allow if and match in constants).
-rw-r--r--library/core/src/option.rs6
-rw-r--r--src/test/ui/consts/const-option.rs2
2 files changed, 3 insertions, 5 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index 7e560d63fe2..b1589008be0 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -175,7 +175,7 @@ impl<T> Option<T> {
     /// ```
     #[must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead"]
     #[inline]
-    #[rustc_const_unstable(feature = "const_option", issue = "67441")]
+    #[rustc_const_stable(feature = "const_option", since = "1.48.0")]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub const fn is_some(&self) -> bool {
         matches!(*self, Some(_))
@@ -195,7 +195,7 @@ impl<T> Option<T> {
     #[must_use = "if you intended to assert that this doesn't have a value, consider \
                   `.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"]
     #[inline]
-    #[rustc_const_unstable(feature = "const_option", issue = "67441")]
+    #[rustc_const_stable(feature = "const_option", since = "1.48.0")]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub const fn is_none(&self) -> bool {
         !self.is_some()
@@ -254,7 +254,7 @@ impl<T> Option<T> {
     /// println!("still can print text: {:?}", text);
     /// ```
     #[inline]
-    #[rustc_const_unstable(feature = "const_option", issue = "67441")]
+    #[rustc_const_stable(feature = "const_option", since = "1.48.0")]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub const fn as_ref(&self) -> Option<&T> {
         match *self {
diff --git a/src/test/ui/consts/const-option.rs b/src/test/ui/consts/const-option.rs
index fbf20b9db67..793f78c8d20 100644
--- a/src/test/ui/consts/const-option.rs
+++ b/src/test/ui/consts/const-option.rs
@@ -1,7 +1,5 @@
 // run-pass
 
-#![feature(const_option)]
-
 const X: Option<i32> = Some(32);
 const Y: Option<&i32> = X.as_ref();