Skip to content

Commit e370955

Browse files
committed
Add track_caller in from_str_radix error code
1 parent 786d30e commit e370955

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

library/core/src/num/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1409,10 +1409,12 @@ pub const fn can_not_overflow<T>(radix: u32, is_signed_ty: bool, digits: &[u8])
14091409
radix <= 16 && digits.len() <= mem::size_of::<T>() * 2 - is_signed_ty as usize
14101410
}
14111411

1412+
#[track_caller]
14121413
const fn from_str_radix_panic_ct(_radix: u32) -> ! {
14131414
panic!("from_str_radix_int: must lie in the range `[2, 36]`");
14141415
}
14151416

1417+
#[track_caller]
14161418
fn from_str_radix_panic_rt(radix: u32) -> ! {
14171419
panic!("from_str_radix_int: must lie in the range `[2, 36]` - found {}", radix);
14181420
}

tests/ui/consts/const-eval/parse_ints.stderr

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,28 @@ error[E0080]: evaluation of constant value failed
33
|
44
= note: the evaluated program panicked at 'from_str_radix_int: must lie in the range `[2, 36]`', $SRC_DIR/core/src/num/mod.rs:LL:COL
55
|
6-
note: inside `core::num::from_str_radix_panic_ct`
7-
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
86
note: inside `core::num::<impl u64>::from_str_radix`
97
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
108
note: inside `_TOO_LOW`
119
--> $DIR/parse_ints.rs:7:24
1210
|
1311
LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); };
1412
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `from_str_radix` (in Nightly builds, run with -Z macro-backtrace for more info)
13+
= note: this error originates in the macro `from_str_radix` (in Nightly builds, run with -Z macro-backtrace for more info)
1614

1715
error[E0080]: evaluation of constant value failed
1816
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
1917
|
2018
= note: the evaluated program panicked at 'from_str_radix_int: must lie in the range `[2, 36]`', $SRC_DIR/core/src/num/mod.rs:LL:COL
2119
|
22-
note: inside `core::num::from_str_radix_panic_ct`
23-
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
2420
note: inside `core::num::<impl u64>::from_str_radix`
2521
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
2622
note: inside `_TOO_HIGH`
2723
--> $DIR/parse_ints.rs:8:25
2824
|
2925
LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); };
3026
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `from_str_radix` (in Nightly builds, run with -Z macro-backtrace for more info)
27+
= note: this error originates in the macro `from_str_radix` (in Nightly builds, run with -Z macro-backtrace for more info)
3228

3329
error: aborting due to 2 previous errors
3430

0 commit comments

Comments
 (0)