about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-10 11:48:15 +0000
committerbors <bors@rust-lang.org>2024-05-10 11:48:15 +0000
commitcf774742b6029e0c2e00654975c001d192063b5b (patch)
tree21a67f7e0ab7dfd33c4484baf50e0f4c4278dd10
parente93f34210120d1fc6a0195d527eee828a36e57b1 (diff)
parenteac37b6caf00aa9376198c906f19e3e6e850bcab (diff)
downloadrust-cf774742b6029e0c2e00654975c001d192063b5b.tar.gz
rust-cf774742b6029e0c2e00654975c001d192063b5b.zip
Auto merge of #124863 - DaniPopes:from-str-radix-panic, r=Amanieu
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.
-rw-r--r--library/core/src/num/mod.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs
index c02f73fdf03..09a341e4d80 100644
--- a/library/core/src/num/mod.rs
+++ b/library/core/src/num/mod.rs
@@ -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 {
@@ -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 });