about summary refs log tree commit diff
path: root/compiler/rustc_index
diff options
context:
space:
mode:
authorJubilee <46493976+workingjubilee@users.noreply.github.com>2021-10-04 13:58:17 -0700
committerGitHub <noreply@github.com>2021-10-04 13:58:17 -0700
commit9866b090f48fc5f45ca9c80618976e41987fc25d (patch)
tree2684f9670ab0a20213c782cf681e637d30095459 /compiler/rustc_index
parent3d4467dfcc512fcb2dc2454c9cf77c23ff3de343 (diff)
parentbce86219830e386d1247364b6018ede2e85d3036 (diff)
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Stabilize `const_panic`

Closes #51999

FCP completed in #89006

```@rustbot``` label +A-const-eval +A-const-fn +T-lang

cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
Diffstat (limited to 'compiler/rustc_index')
-rw-r--r--compiler/rustc_index/src/vec.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs
index 56ea04539e5..88315246834 100644
--- a/compiler/rustc_index/src/vec.rs
+++ b/compiler/rustc_index/src/vec.rs
@@ -124,7 +124,9 @@ macro_rules! newtype_index {
 
             #[inline]
             $v const fn from_usize(value: usize) -> Self {
-                // FIXME: replace with `assert!(value <= ($max as usize));` once `const_panic` is stable
+                #[cfg(not(bootstrap))]
+                assert!(value <= ($max as usize));
+                #[cfg(bootstrap)]
                 [()][(value > ($max as usize)) as usize];
                 unsafe {
                     Self::from_u32_unchecked(value as u32)
@@ -133,7 +135,9 @@ macro_rules! newtype_index {
 
             #[inline]
             $v const fn from_u32(value: u32) -> Self {
-                // FIXME: replace with `assert!(value <= $max);` once `const_panic` is stable
+                #[cfg(not(bootstrap))]
+                assert!(value <= $max);
+                #[cfg(bootstrap)]
                 [()][(value > $max) as usize];
                 unsafe {
                     Self::from_u32_unchecked(value)