Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ca0bfeb

Browse filesBrowse files
committed
Document difference between core and std's PanicInfo.
1 parent 702405e commit ca0bfeb
Copy full SHA for ca0bfeb

File tree

Expand file treeCollapse file tree

2 files changed

+18
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-2
lines changed

‎core/src/panic/panic_info.rs

Copy file name to clipboardExpand all lines: core/src/panic/panic_info.rs
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ use crate::panic::Location;
44
/// A struct providing information about a panic.
55
///
66
/// A `PanicInfo` structure is passed to the panic handler defined by `#[panic_handler]`.
7+
///
8+
/// There two `PanicInfo` types:
9+
/// - `core::panic::PanicInfo`, which is used as an argument to a `#[panic_handler]` in `#![no_std]` programs.
10+
/// - [`std::panic::PanicInfo`], which is used as an argument to a panic hook set by [`std::panic::set_hook`].
11+
///
12+
/// This is the first one.
13+
///
14+
/// [`std::panic::set_hook`]: ../../std/panic/fn.set_hook.html
15+
/// [`std::panic::PanicInfo`]: ../../std/panic/struct.PanicInfo.html
716
#[lang = "panic_info"]
817
#[stable(feature = "panic_hooks", since = "1.10.0")]
918
#[derive(Debug)]

‎std/src/panic.rs

Copy file name to clipboardExpand all lines: std/src/panic.rs
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ use crate::thread::Result;
1212

1313
/// A struct providing information about a panic.
1414
///
15-
/// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`]
16-
/// function.
15+
/// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] function.
1716
///
1817
/// [`set_hook`]: ../../std/panic/fn.set_hook.html
1918
///
19+
/// There two `PanicInfo` types:
20+
/// - [`core::panic::PanicInfo`], which is used as an argument to a `#[panic_handler]` in `#![no_std]` programs.
21+
/// - `std::panic::PanicInfo`, which is used as an argument to a panic hook set by [`std::panic::set_hook`].
22+
///
23+
/// This is the second one.
24+
///
2025
/// # Examples
2126
///
2227
/// ```should_panic
@@ -28,6 +33,8 @@ use crate::thread::Result;
2833
///
2934
/// panic!("critical system failure");
3035
/// ```
36+
///
37+
/// [`core::panic::PanicInfo`]: ../../core/panic/struct.PanicInfo.html
3138
#[stable(feature = "panic_hooks", since = "1.10.0")]
3239
#[derive(Debug)]
3340
pub struct PanicInfo<'a> {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.