From 3cfa0a0dff610e228819579709c035c9a1d4310b Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Sat, 3 Apr 2021 10:00:09 +0200 Subject: [PATCH 1/2] Remove nightly features in rustc_type_ir --- compiler/rustc_index/src/vec.rs | 4 ++-- compiler/rustc_type_ir/src/lib.rs | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs index 3882818952c33..6b29079109e10 100644 --- a/compiler/rustc_index/src/vec.rs +++ b/compiler/rustc_index/src/vec.rs @@ -124,7 +124,7 @@ macro_rules! newtype_index { #[inline] $v const fn from_usize(value: usize) -> Self { - assert!(value <= ($max as usize)); + [()][(value > ($max as usize)) as usize]; unsafe { Self::from_u32_unchecked(value as u32) } @@ -132,7 +132,7 @@ macro_rules! newtype_index { #[inline] $v const fn from_u32(value: u32) -> Self { - assert!(value <= $max); + [()][(value > $max) as usize]; unsafe { Self::from_u32_unchecked(value) } diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index fccd8b795ef56..8fcdf813b4137 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -1,7 +1,3 @@ -#![feature(never_type)] -#![feature(const_panic)] -#![feature(control_flow_enum)] - #[macro_use] extern crate bitflags; #[macro_use] From 3ea7c90a947132977ddb95024bbf05faea851fd9 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Sat, 3 Apr 2021 13:07:03 +0200 Subject: [PATCH 2/2] Add fixme comment to revert change once const_panic is stable --- compiler/rustc_index/src/vec.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs index 6b29079109e10..1b1a59a254e6f 100644 --- a/compiler/rustc_index/src/vec.rs +++ b/compiler/rustc_index/src/vec.rs @@ -124,6 +124,7 @@ 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 [()][(value > ($max as usize)) as usize]; unsafe { Self::from_u32_unchecked(value as u32) @@ -132,6 +133,7 @@ macro_rules! newtype_index { #[inline] $v const fn from_u32(value: u32) -> Self { + // FIXME: replace with `assert!(value <= $max);` once `const_panic` is stable [()][(value > $max) as usize]; unsafe { Self::from_u32_unchecked(value)