diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-18 16:50:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-18 16:50:59 -0700 |
| commit | 2fad396368dfbe404f0bd6ce6307a0314794537c (patch) | |
| tree | da077af6b53e4264b80f5f71f092d3304025dcdb /src/libcore | |
| parent | 1a54b61e39b2c5d383da622d3d390bcda32f6b3c (diff) | |
| parent | 6cd164f49e6f9c2b914fa5d55755d78e3fabbc27 (diff) | |
| download | rust-2fad396368dfbe404f0bd6ce6307a0314794537c.tar.gz rust-2fad396368dfbe404f0bd6ce6307a0314794537c.zip | |
Rollup merge of #74459 - canova:const-unreachable-unchecked, r=oli-obk
Make unreachable_unchecked a const fn This PR makes `std::hint::unreachable_unchecked` a const fn so we can use it inside a const function. r? @RalfJung Fixes #53188.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/hint.rs | 3 | ||||
| -rw-r--r-- | src/libcore/intrinsics.rs | 1 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs index 9ebcde79b63..3116815f5d6 100644 --- a/src/libcore/hint.rs +++ b/src/libcore/hint.rs @@ -45,7 +45,8 @@ use crate::intrinsics; /// ``` #[inline] #[stable(feature = "unreachable", since = "1.27.0")] -pub unsafe fn unreachable_unchecked() -> ! { +#[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] +pub const unsafe fn unreachable_unchecked() -> ! { // SAFETY: the safety contract for `intrinsics::unreachable` must // be upheld by the caller. unsafe { intrinsics::unreachable() } diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 080760aa81f..8f0cf4361e7 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -932,6 +932,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is /// [`std::hint::unreachable_unchecked`](../../std/hint/fn.unreachable_unchecked.html). + #[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] pub fn unreachable() -> !; /// Informs the optimizer that a condition is always true. diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 1621cf79751..2e443064706 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -92,6 +92,7 @@ #![feature(const_slice_ptr_len)] #![feature(const_type_name)] #![feature(const_likely)] +#![feature(const_unreachable_unchecked)] #![feature(custom_inner_attributes)] #![feature(decl_macro)] #![feature(doc_cfg)] |
