Skip to content

Commit

Permalink
Auto merge of #124863 - DaniPopes:from-str-radix-panic, r=Amanieu
Browse files Browse the repository at this point in the history
from_str_radix: outline only the panic function

In the `{integer}::from_str_radix` function, the radix check is labeled as `cold` and `inline(never)`, along with its corresponding panic. It probably was intended to apply these attributes only to the panic function.
  • Loading branch information
bors committed May 10, 2024
2 parents e93f342 + eac37b6 commit cf77474
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,11 +1412,9 @@ fn from_str_radix_panic_rt(radix: u32) -> ! {
#[cfg_attr(feature = "panic_immediate_abort", inline)]
#[cold]
#[track_caller]
const fn from_str_radix_assert(radix: u32) {
if 2 > radix || radix > 36 {
// The only difference between these two functions is their panic message.
intrinsics::const_eval_select((radix,), from_str_radix_panic_ct, from_str_radix_panic_rt);
}
const fn from_str_radix_panic(radix: u32) {
// The only difference between these two functions is their panic message.
intrinsics::const_eval_select((radix,), from_str_radix_panic_ct, from_str_radix_panic_rt);
}

macro_rules! from_str_radix {
Expand Down Expand Up @@ -1450,7 +1448,9 @@ macro_rules! from_str_radix {
use self::IntErrorKind::*;
use self::ParseIntError as PIE;

from_str_radix_assert(radix);
if 2 > radix || radix > 36 {
from_str_radix_panic(radix);
}

if src.is_empty() {
return Err(PIE { kind: Empty });
Expand Down

0 comments on commit cf77474

Please sign in to comment.