diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2021-10-04 00:33:43 -0400 |
|---|---|---|
| committer | Jacob Pratt <jacob@jhpratt.dev> | 2021-10-04 02:33:33 -0400 |
| commit | bce86219830e386d1247364b6018ede2e85d3036 (patch) | |
| tree | 86f296c4d5473370fb9267b3ae5818e7cdf966fe /compiler/rustc_index/src | |
| parent | e737694a4d66b01308b73d4559a35b43e414faf9 (diff) | |
| download | rust-bce86219830e386d1247364b6018ede2e85d3036.tar.gz rust-bce86219830e386d1247364b6018ede2e85d3036.zip | |
Stabilize `const_panic`
Diffstat (limited to 'compiler/rustc_index/src')
| -rw-r--r-- | compiler/rustc_index/src/vec.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs index 8535a7c866d..453469f5574 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) |
