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:
commit
9866b090f4
51 changed files with 100 additions and 229 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue