Skip to content

Commit 3c48579

Browse files
committed
more panicking comments
1 parent 08f779c commit 3c48579

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/libcore/panicking.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
//! ```
1212
//!
1313
//! This definition allows for panicking with any general message, but it does not
14-
//! allow for failing with a `Box<Any>` value. The reason for this is that libcore
15-
//! is not allowed to allocate.
14+
//! allow for failing with a `Box<Any>` value. (`PanicInfo` just contains a `&(dyn Any + Send)`,
15+
//! for which we fill in a dummy value in `PanicInfo::internal_constructor`.)
16+
//! The reason for this is that libcore is not allowed to allocate.
1617
//!
1718
//! This module contains a few other panicking functions, but these are just the
1819
//! necessary lang items for the compiler. All panics are funneled through this
19-
//! one function. Currently, the actual symbol is declared in the standard
20-
//! library, but the location of this may change over time.
20+
//! one function. The actual symbol is declared through the `#[panic_handler]` attribute.
2121
2222
// ignore-tidy-undocumented-unsafe
2323

@@ -72,6 +72,7 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, location: &Location<'_>) -> ! {
7272
}
7373

7474
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
75+
// that gets resolved to the `#[panic_handler]` function.
7576
extern "Rust" {
7677
#[lang = "panic_impl"]
7778
fn panic_impl(pi: &PanicInfo<'_>) -> !;

src/libstd/panicking.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,9 @@ fn rust_panic_with_hook(payload: &mut dyn BoxMeUp,
455455
match HOOK {
456456
// Some platforms know that printing to stderr won't ever actually
457457
// print anything, and if that's the case we can skip the default
458-
// hook.
458+
// hook. Since string formatting happens lazily when calling `payload`
459+
// methods, this means that with libpanic_abort, we don't format
460+
// the string at all!
459461
Hook::Default if panic_output().is_none() => {}
460462
Hook::Default => {
461463
info.set_payload(payload.get());

0 commit comments

Comments
 (0)