@@ -1,7 +1,14 @@ |
|
|
1 |
1 |
//! Panic support for core |
2 |
2 |
//! |
3 |
|
-//! The core library cannot define panicking, but it does *declare* panicking. This |
4 |
|
-//! means that the functions inside of core are allowed to panic, but to be |
|
3 |
+//! In core, panicking is always done with a message, resulting in a core::panic::PanicInfo |
|
4 |
+//! containing a fmt::Arguments. In std, however, panicking can be done with panic_any, which throws |
|
5 |
+//! a Box containing any type of value. Because of this, std::panic::PanicInfo is a |
|
6 |
+//! different type, which contains a &dyn Any instead of a fmt::Arguments. |
|
7 |
+//! std's panic handler will convert the fmt::Arguments to a &dyn Any containing either a |
|
8 |
+//! &'static str or String containing the formatted message. |
|
9 |
+//! |
|
10 |
+//! The core library cannot define any panic handler, but it can invoke it. |
|
11 |
+//! This means that the functions inside of core are allowed to panic, but to be |
5 |
12 |
//! useful an upstream crate must define panicking for core to use. The current |
6 |
13 |
//! interface for panicking is: |
7 |
14 |
//! |
@@ -10,11 +17,6 @@ |
|
|
10 |
17 |
//! # { loop {} } |
11 |
18 |
//! ``` |
12 |
19 |
//! |
13 |
|
-//! This definition allows for panicking with any general message, but it does not |
14 |
|
-//! allow for failing with a `Box` 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 core is not allowed to allocate. |
17 |
|
-//! |
18 |
20 |
//! This module contains a few other panicking functions, but these are just the |
19 |
21 |
//! necessary lang items for the compiler. All panics are funneled through this |
20 |
22 |
//! one function. The actual symbol is declared through the `#[panic_handler]` attribute. |