about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-06-28 20:47:52 +0000
committerbors <bors@rust-lang.org>2020-06-28 20:47:52 +0000
commitc977b8775dd72d191ff1d8e8dceaf4b4cd5db86c (patch)
tree6c2daa59e240a4c245503456ae4fd2efd1ddfa2e /src/libcore
parent2f517ce6f28b5d638cce4c1eccdbe63255b11420 (diff)
parent8509b6951a6a4f29b9426227e1edff6d6484571f (diff)
downloadrust-c977b8775dd72d191ff1d8e8dceaf4b4cd5db86c.tar.gz
rust-c977b8775dd72d191ff1d8e8dceaf4b4cd5db86c.zip
Auto merge of #72437 - ecstatic-morse:stabilize-const-if-match, r=oli-obk
Stabilize `#![feature(const_if_match)]`

Quoting from the [stabilization report](https://github.com/rust-lang/rust/issues/49146#issuecomment-616301045):

> `if` and `match` expressions as well as the short-circuiting logic operators `&&` and `||` will become legal in all [const contexts](https://doc.rust-lang.org/reference/const_eval.html#const-context). A const context is any of the following:
>
> - The initializer of a `const`, `static`, `static mut` or enum discriminant.
> - The body of a `const fn`.
> - The value of a const generic (nightly only).
> - The length of an array type (`[u8; 3]`) or an array repeat expression (`[0u8; 3]`).
>
> Furthermore, the short-circuiting logic operators will no longer be lowered to their bitwise equivalents (`&` and `|` respectively) in `const` and `static` initializers (see #57175). As a result, `let` bindings can be used alongside short-circuiting logic in those initializers.

Resolves #49146.

Ideally, we would resolve :whale: #66753 before this lands on stable, so it might be worth pushing this back a release. Also, this means we should get the process started for #52000, otherwise people will have no recourse except recursion for iterative `const fn`.

r? @oli-obk
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/lib.rs4
-rw-r--r--src/libcore/num/mod.rs6
2 files changed, 5 insertions, 5 deletions
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 15466ce94a8..aeb52bffbf2 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -73,8 +73,8 @@
 #![feature(const_ascii_ctype_on_intrinsics)]
 #![feature(const_alloc_layout)]
 #![feature(const_discriminant)]
-#![feature(const_if_match)]
-#![feature(const_loop)]
+#![cfg_attr(bootstrap, feature(const_if_match))]
+#![cfg_attr(bootstrap, feature(const_loop))]
 #![feature(const_checked_int_methods)]
 #![feature(const_euclidean_int_methods)]
 #![feature(const_overflowing_int_methods)]
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index b1317bc2121..1714d2ee98e 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -1578,7 +1578,7 @@ $EndFeature, "
             #[stable(feature = "no_panic_abs", since = "1.13.0")]
             #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
             #[allow(unused_attributes)]
-            #[allow_internal_unstable(const_if_match)]
+            #[cfg_attr(bootstrap, allow_internal_unstable(const_if_match))]
             #[inline]
             pub const fn wrapping_abs(self) -> Self {
                  if self.is_negative() {
@@ -1867,7 +1867,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
             #[stable(feature = "wrapping", since = "1.7.0")]
             #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
             #[allow(unused_attributes)]
-            #[allow_internal_unstable(const_if_match)]
+            #[cfg_attr(bootstrap, allow_internal_unstable(const_if_match))]
             pub const fn overflowing_neg(self) -> (Self, bool) {
                 if self == Self::MIN {
                     (Self::MIN, true)
@@ -2160,7 +2160,7 @@ $EndFeature, "
             #[stable(feature = "rust1", since = "1.0.0")]
             #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
             #[allow(unused_attributes)]
-            #[allow_internal_unstable(const_if_match)]
+            #[cfg_attr(bootstrap, allow_internal_unstable(const_if_match))]
             #[inline]
             #[rustc_inherit_overflow_checks]
             pub const fn abs(self) -> Self {