about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-01 07:42:52 -0700
committerGitHub <noreply@github.com>2020-07-01 07:42:52 -0700
commitec41d01d4f7c668a75eff1ba724b8a67c7ec90b4 (patch)
tree8418d77e0d1dcb6cf2dfba9c1a951f7a3b7e0a60 /src/libcore
parentd6bee55855093d86c7e110116beebb369cd89654 (diff)
parent8b43012453de32d4e429c923171131f938d3ead8 (diff)
downloadrust-ec41d01d4f7c668a75eff1ba724b8a67c7ec90b4.tar.gz
rust-ec41d01d4f7c668a75eff1ba724b8a67c7ec90b4.zip
Rollup merge of #73778 - nbdd0121:const_likely, r=oli-obk
Make `likely` and `unlikely` const, gated by feature `const_unlikely`

This PR also contains a fix to allow `#[allow_internal_unstable]` to work properly with `#[rustc_const_unstable]`.

cc @RalfJung @nagisa

r? @oli-obk
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/intrinsics.rs2
-rw-r--r--src/libcore/lib.rs1
2 files changed, 3 insertions, 0 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 5d090187591..57ffed19c00 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -952,6 +952,7 @@ extern "rust-intrinsic" {
     /// Any use other than with `if` statements will probably not have an effect.
     ///
     /// This intrinsic does not have a stable counterpart.
+    #[rustc_const_unstable(feature = "const_likely", issue = "none")]
     pub fn likely(b: bool) -> bool;
 
     /// Hints to the compiler that branch condition is likely to be false.
@@ -960,6 +961,7 @@ extern "rust-intrinsic" {
     /// Any use other than with `if` statements will probably not have an effect.
     ///
     /// This intrinsic does not have a stable counterpart.
+    #[rustc_const_unstable(feature = "const_likely", issue = "none")]
     pub fn unlikely(b: bool) -> bool;
 
     /// Executes a breakpoint trap, for inspection by a debugger.
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index b732dacae1c..63ddd97eed3 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -92,6 +92,7 @@
 #![feature(const_slice_from_raw_parts)]
 #![feature(const_slice_ptr_len)]
 #![feature(const_type_name)]
+#![feature(const_likely)]
 #![feature(custom_inner_attributes)]
 #![feature(decl_macro)]
 #![feature(doc_cfg)]