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)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user