Skip to content

Commit 0a370d8

Browse files
committed
Revert "Auto merge of #132662 - RalfJung:const-panic-inlining, r=tgross35"
This reverts commit 8adb4b3, reversing changes made to a00df61.
1 parent dae7ac1 commit 0a370d8

File tree

4 files changed

+10
-34
lines changed

4 files changed

+10
-34
lines changed

library/core/src/intrinsics/mod.rs

+2-23
Original file line numberDiff line numberDiff line change
@@ -3463,35 +3463,14 @@ pub(crate) macro const_eval_select {
34633463
$(#[$compiletime_attr:meta])* $compiletime:block
34643464
else
34653465
$(#[$runtime_attr:meta])* $runtime:block
3466-
) => {
3467-
// Use the `noinline` arm, after adding explicit `inline` attributes
3468-
$crate::intrinsics::const_eval_select!(
3469-
@capture { $($arg : $ty = $val),* } $(-> $ret)? :
3470-
#[noinline]
3471-
if const
3472-
#[inline] // prevent codegen on this function
3473-
$(#[$compiletime_attr])*
3474-
$compiletime
3475-
else
3476-
#[inline] // avoid the overhead of an extra fn call
3477-
$(#[$runtime_attr])*
3478-
$runtime
3479-
)
3480-
},
3481-
// With a leading #[noinline], we don't add inline attributes
3482-
(
3483-
@capture { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? :
3484-
#[noinline]
3485-
if const
3486-
$(#[$compiletime_attr:meta])* $compiletime:block
3487-
else
3488-
$(#[$runtime_attr:meta])* $runtime:block
34893466
) => {{
3467+
#[inline] // avoid the overhead of an extra fn call
34903468
$(#[$runtime_attr])*
34913469
fn runtime($($arg: $ty),*) $( -> $ret )? {
34923470
$runtime
34933471
}
34943472

3473+
#[inline] // prevent codegen on this function
34953474
$(#[$compiletime_attr])*
34963475
const fn compiletime($($arg: $ty),*) $( -> $ret )? {
34973476
// Don't warn if one of the arguments is unused.

library/core/src/num/f128.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1258,9 +1258,8 @@ impl f128 {
12581258
min <= max,
12591259
"min > max, or either was NaN",
12601260
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
1261-
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
1262-
min: &f128 = &min,
1263-
max: &f128 = &max,
1261+
min: f128,
1262+
max: f128,
12641263
);
12651264

12661265
if self < min {

library/core/src/num/f16.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,8 @@ impl f16 {
12351235
min <= max,
12361236
"min > max, or either was NaN",
12371237
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
1238-
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
1239-
min: &f16 = &min,
1240-
max: &f16 = &max,
1238+
min: f16,
1239+
max: f16,
12411240
);
12421241

12431242
if self < min {

library/core/src/panic.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,15 @@ pub macro const_panic {
206206
// add the `rustc_allow_const_fn_unstable`. This is okay to do
207207
// because both variants will panic, just with different messages.
208208
#[rustc_allow_const_fn_unstable(const_eval_select)]
209-
#[inline(always)] // inline the wrapper
209+
#[inline(always)]
210210
#[track_caller]
211211
#[cfg_attr(bootstrap, rustc_const_stable(feature = "const_panic", since = "CURRENT_RUSTC_VERSION"))]
212212
const fn do_panic($($arg: $ty),*) -> ! {
213213
$crate::intrinsics::const_eval_select!(
214-
@capture { $($arg: $ty = $arg),* } -> !:
215-
#[noinline]
216-
if const #[track_caller] #[inline] { // Inline this, to prevent codegen
214+
@capture { $($arg: $ty),* } -> !:
215+
if const #[track_caller] {
217216
$crate::panic!($const_msg)
218-
} else #[track_caller] { // Do not inline this, it makes perf worse
217+
} else #[track_caller] {
219218
$crate::panic!($runtime_msg)
220219
}
221220
)

0 commit comments

Comments
 (0)