diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-10-20 04:35:14 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-20 04:35:14 +0900 |
| commit | f7024998c7eae5b582de680effaca105198aa95c (patch) | |
| tree | f7c885e3f6f4c58f6ceac87779f2d4e3c0c3fac0 /library/std/src | |
| parent | 84fe598f0094c8d6a1dddcdc38ac0fa28df32f44 (diff) | |
| parent | 7bd93dfeefac34a440ff011786d28e7b821add31 (diff) | |
| download | rust-f7024998c7eae5b582de680effaca105198aa95c.tar.gz rust-f7024998c7eae5b582de680effaca105198aa95c.zip | |
Rollup merge of #88860 - nbdd0121:panic, r=m-ou-se
Deduplicate panic_fmt std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/panic.rs | 2 | ||||
| -rw-r--r-- | library/std/src/panicking.rs | 26 | ||||
| -rw-r--r-- | library/std/src/rt.rs | 4 |
3 files changed, 5 insertions, 27 deletions
diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 21e9669c110..c0605b2f412 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -25,7 +25,7 @@ pub macro panic_2015 { $crate::rt::panic_display(&$arg) }), ($fmt:expr, $($arg:tt)+) => ({ - $crate::rt::begin_panic_fmt(&$crate::const_format_args!($fmt, $($arg)+)) + $crate::rt::panic_fmt($crate::const_format_args!($fmt, $($arg)+)) }), } diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 231c9fc19c0..56646b72dd5 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -437,31 +437,9 @@ pub fn panicking() -> bool { !panic_count::count_is_zero() } -/// The entry point for panicking with a formatted message. -/// -/// This is designed to reduce the amount of code required at the call -/// site as much as possible (so that `panic!()` has as low an impact -/// on (e.g.) the inlining of other functions as possible), by moving -/// the actual formatting into this shared place. -#[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "none")] -#[cold] -// If panic_immediate_abort, inline the abort call, -// otherwise avoid inlining because of it is cold path. -#[cfg_attr(not(feature = "panic_immediate_abort"), track_caller)] -#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] -#[cfg_attr(feature = "panic_immediate_abort", inline)] -#[cfg_attr(not(test), lang = "begin_panic_fmt")] -pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>) -> ! { - if cfg!(feature = "panic_immediate_abort") { - intrinsics::abort() - } - - let info = PanicInfo::internal_constructor(Some(msg), Location::caller()); - begin_panic_handler(&info) -} - /// Entry point of panics from the libcore crate (`panic_impl` lang item). -#[cfg_attr(not(test), panic_handler)] +#[cfg(not(test))] +#[panic_handler] pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! { struct PanicPayload<'a> { inner: &'a fmt::Arguments<'a>, diff --git a/library/std/src/rt.rs b/library/std/src/rt.rs index 4d72aff0116..121c214780d 100644 --- a/library/std/src/rt.rs +++ b/library/std/src/rt.rs @@ -19,8 +19,8 @@ use crate::ffi::CString; // Re-export some of our utilities which are expected by other crates. -pub use crate::panicking::{begin_panic, begin_panic_fmt, panic_count}; -pub use core::panicking::panic_display; +pub use crate::panicking::{begin_panic, panic_count}; +pub use core::panicking::{panic_display, panic_fmt}; use crate::sync::Once; use crate::sys; |
