Skip to content

Commit 3a8e1b6

Browse files
committed
panic_handler -> begin_panic_handler (and more comments)
1 parent 3c48579 commit 3a8e1b6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/libstd/panicking.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,17 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>,
316316
unsafe { intrinsics::abort() }
317317
}
318318

319+
// Just package everything into a `PanicInfo` and continue like libcore panics.
319320
let (file, line, col) = *file_line_col;
320321
let location = Location::internal_constructor(file, line, col);
321322
let info = PanicInfo::internal_constructor(Some(msg), &location);
322-
panic_handler(&info)
323+
begin_panic_handler(&info)
323324
}
324325

325-
/// Entry point of panic from the libcore crate (`panic_impl` lang item).
326+
/// Entry point of panics from the libcore crate (`panic_impl` lang item).
326327
#[cfg_attr(not(test), panic_handler)]
327328
#[unwind(allowed)]
328-
fn panic_handler(info: &PanicInfo<'_>) -> ! {
329+
pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
329330
struct PanicPayload<'a> {
330331
inner: &'a fmt::Arguments<'a>,
331332
string: Option<String>,
@@ -374,7 +375,9 @@ fn panic_handler(info: &PanicInfo<'_>) -> ! {
374375
&file_line_col);
375376
}
376377

377-
/// This is the entry point of panicking for panic!() and assert!().
378+
/// This is the entry point of panicking for the non-format-string variants of
379+
/// panic!() and assert!(). In particular, this is the only entry point that supports
380+
/// arbitrary payloads, not just format strings.
378381
#[unstable(feature = "libstd_sys_internals",
379382
reason = "used by the panic! macro",
380383
issue = "0")]

0 commit comments

Comments
 (0)