Skip to content

Commit 72c7f4c

Browse files
committed
Auto merge of rust-lang#145304 - m-ou-se:simplify-panic, r=oli-obk
Revert "Partially outline code inside the panic! macro". This reverts rust-lang#115670 Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect. (And if it did, whether that effect is still achieved today.)
2 parents b6249f1 + c686675 commit 72c7f4c

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

core/src/panic.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub macro panic_2015 {
4848
#[allow_internal_unstable(panic_internals, const_format_args)]
4949
#[rustc_diagnostic_item = "core_panic_2021_macro"]
5050
#[rustc_macro_transparency = "semitransparent"]
51-
#[cfg(feature = "panic_immediate_abort")]
5251
pub macro panic_2021 {
5352
() => (
5453
$crate::panicking::panic("explicit panic")
@@ -64,50 +63,6 @@ pub macro panic_2021 {
6463
}),
6564
}
6665

67-
#[doc(hidden)]
68-
#[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")]
69-
#[allow_internal_unstable(
70-
panic_internals,
71-
core_intrinsics,
72-
const_dispatch,
73-
const_eval_select,
74-
const_format_args,
75-
rustc_attrs
76-
)]
77-
#[rustc_diagnostic_item = "core_panic_2021_macro"]
78-
#[rustc_macro_transparency = "semitransparent"]
79-
#[cfg(not(feature = "panic_immediate_abort"))]
80-
pub macro panic_2021 {
81-
() => ({
82-
// Create a function so that the argument for `track_caller`
83-
// can be moved inside if possible.
84-
#[cold]
85-
#[track_caller]
86-
#[inline(never)]
87-
const fn panic_cold_explicit() -> ! {
88-
$crate::panicking::panic_explicit()
89-
}
90-
panic_cold_explicit();
91-
}),
92-
// Special-case the single-argument case for const_panic.
93-
("{}", $arg:expr $(,)?) => ({
94-
#[cold]
95-
#[track_caller]
96-
#[inline(never)]
97-
#[rustc_const_panic_str] // enforce a &&str argument in const-check and hook this by const-eval
98-
#[rustc_do_not_const_check] // hooked by const-eval
99-
const fn panic_cold_display<T: $crate::fmt::Display>(arg: &T) -> ! {
100-
$crate::panicking::panic_display(arg)
101-
}
102-
panic_cold_display(&$arg);
103-
}),
104-
($($t:tt)+) => ({
105-
// Semicolon to prevent temporaries inside the formatting machinery from
106-
// being considered alive in the caller after the panic_fmt call.
107-
$crate::panicking::panic_fmt($crate::const_format_args!($($t)+));
108-
}),
109-
}
110-
11166
#[doc(hidden)]
11267
#[unstable(feature = "edition_panic", issue = "none", reason = "use unreachable!() instead")]
11368
#[allow_internal_unstable(panic_internals)]

core/src/panicking.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,6 @@ pub fn panic_nounwind_nobacktrace(expr: &'static str) -> ! {
233233
panic_nounwind_fmt(fmt::Arguments::new_const(&[expr]), /* force_no_backtrace */ true);
234234
}
235235

236-
#[track_caller]
237-
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]
238-
#[cfg_attr(feature = "panic_immediate_abort", inline)]
239-
#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable
240-
pub const fn panic_explicit() -> ! {
241-
panic_display(&"explicit panic");
242-
}
243-
244236
#[inline]
245237
#[track_caller]
246238
#[rustc_diagnostic_item = "unreachable_display"] // needed for `non-fmt-panics` lint
@@ -260,9 +252,8 @@ pub const fn panic_str_2015(expr: &str) -> ! {
260252

261253
#[inline]
262254
#[track_caller]
255+
#[lang = "panic_display"] // needed for const-evaluated panics
263256
#[rustc_do_not_const_check] // hooked by const-eval
264-
// enforce a &&str argument in const-check and hook this by const-eval
265-
#[rustc_const_panic_str]
266257
#[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable
267258
pub const fn panic_display<T: fmt::Display>(x: &T) -> ! {
268259
panic_fmt(format_args!("{}", *x));

0 commit comments

Comments
 (0)