diff options
| author | Ralf Jung <post@ralfj.de> | 2019-11-25 12:24:39 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-11-25 23:55:54 +0100 |
| commit | 3c485795517d1f5a6ebfff6368dfae7a7cd85b85 (patch) | |
| tree | a82b02113c7c47a5c7945a20f361bedc978cd2d4 /src | |
| parent | 08f779cb4b481be58eeb5ecc421f69503780e8b1 (diff) | |
| download | rust-3c485795517d1f5a6ebfff6368dfae7a7cd85b85.tar.gz rust-3c485795517d1f5a6ebfff6368dfae7a7cd85b85.zip | |
more panicking comments
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/panicking.rs | 9 | ||||
| -rw-r--r-- | src/libstd/panicking.rs | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 4833194be37..5a8d647396d 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -11,13 +11,13 @@ //! ``` //! //! This definition allows for panicking with any general message, but it does not -//! allow for failing with a `Box<Any>` value. The reason for this is that libcore -//! is not allowed to allocate. +//! allow for failing with a `Box<Any>` value. (`PanicInfo` just contains a `&(dyn Any + Send)`, +//! for which we fill in a dummy value in `PanicInfo::internal_constructor`.) +//! The reason for this is that libcore is not allowed to allocate. //! //! This module contains a few other panicking functions, but these are just the //! necessary lang items for the compiler. All panics are funneled through this -//! one function. Currently, the actual symbol is declared in the standard -//! library, but the location of this may change over time. +//! one function. The actual symbol is declared through the `#[panic_handler]` attribute. // ignore-tidy-undocumented-unsafe @@ -72,6 +72,7 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, location: &Location<'_>) -> ! { } // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call + // that gets resolved to the `#[panic_handler]` function. extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index a16eec45b9a..cb035f48d90 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -455,7 +455,9 @@ fn rust_panic_with_hook(payload: &mut dyn BoxMeUp, match HOOK { // Some platforms know that printing to stderr won't ever actually // print anything, and if that's the case we can skip the default - // hook. + // hook. Since string formatting happens lazily when calling `payload` + // methods, this means that with libpanic_abort, we don't format + // the string at all! Hook::Default if panic_output().is_none() => {} Hook::Default => { info.set_payload(payload.get()); |
