about summary refs log tree commit diff
path: root/library/std/src/panic.rs
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2024-01-31 10:27:29 +0100
committerMara Bos <m-ou.se@m-ou.se>2024-06-11 15:47:00 +0200
commit64e56db72aa2b1f112504504a7dceba63881cdef (patch)
tree15442a2c1fe1609d903a1d3630c1650f907c1e89 /library/std/src/panic.rs
parentb6180a918538b3afa04bbc1c5515c0be2154e1b6 (diff)
downloadrust-64e56db72aa2b1f112504504a7dceba63881cdef.tar.gz
rust-64e56db72aa2b1f112504504a7dceba63881cdef.zip
Rename std::panic::PanicInfo to PanicHookInfo.
Diffstat (limited to 'library/std/src/panic.rs')
-rw-r--r--library/std/src/panic.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs
index ca0ec12a600..77defe14b70 100644
--- a/library/std/src/panic.rs
+++ b/library/std/src/panic.rs
@@ -10,15 +10,21 @@ use crate::sync::atomic::{AtomicU8, Ordering};
 use crate::sync::{Condvar, Mutex, RwLock};
 use crate::thread::Result;
 
+#[stable(feature = "panic_hooks", since = "1.10.0")]
+#[deprecated(
+    since = "1.77.0",
+    note = "use `PanicHookInfo` instead",
+    suggestion = "std::panic::PanicHookInfo"
+)]
 /// A struct providing information about a panic.
 ///
-/// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] function.
-///
-/// There two `PanicInfo` types:
-/// - [`core::panic::PanicInfo`], which is used as an argument to a `#[panic_handler]` in `#![no_std]` programs.
-/// - `std::panic::PanicInfo`, which is used as an argument to a panic hook set by [`set_hook`].
+/// `PanicInfo` has been renamed to [`PanicHookInfo`] to avoid confusion with
+/// [`core::panic::PanicInfo`].
+pub type PanicInfo<'a> = PanicHookInfo<'a>;
+
+/// A struct providing information about a panic.
 ///
-/// This is the second one.
+/// `PanicHookInfo` structure is passed to a panic hook set by the [`set_hook`] function.
 ///
 /// # Examples
 ///
@@ -32,18 +38,17 @@ use crate::thread::Result;
 /// panic!("critical system failure");
 /// ```
 ///
-/// [`core::panic::PanicInfo`]: ../../core/panic/struct.PanicInfo.html
 /// [`set_hook`]: ../../std/panic/fn.set_hook.html
-#[stable(feature = "panic_hooks", since = "1.10.0")]
+#[stable(feature = "panic_hook_info", since = "CURRENT_RUSTC_VERSION")]
 #[derive(Debug)]
-pub struct PanicInfo<'a> {
+pub struct PanicHookInfo<'a> {
     payload: &'a (dyn Any + Send),
     location: &'a Location<'a>,
     can_unwind: bool,
     force_no_backtrace: bool,
 }
 
-impl<'a> PanicInfo<'a> {
+impl<'a> PanicHookInfo<'a> {
     #[inline]
     pub(crate) fn new(
         location: &'a Location<'a>,
@@ -51,7 +56,7 @@ impl<'a> PanicInfo<'a> {
         can_unwind: bool,
         force_no_backtrace: bool,
     ) -> Self {
-        PanicInfo { payload, location, can_unwind, force_no_backtrace }
+        PanicHookInfo { payload, location, can_unwind, force_no_backtrace }
     }
 
     /// Returns the payload associated with the panic.
@@ -145,7 +150,7 @@ impl<'a> PanicInfo<'a> {
 }
 
 #[stable(feature = "panic_hook_display", since = "1.26.0")]
-impl fmt::Display for PanicInfo<'_> {
+impl fmt::Display for PanicHookInfo<'_> {
     fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         formatter.write_str("panicked at ")?;
         self.location.fmt(formatter)?;
@@ -204,7 +209,7 @@ pub use core::panic::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe};
 /// The message can be of any (`Any + Send`) type, not just strings.
 ///
 /// The message is wrapped in a `Box<'static + Any + Send>`, which can be
-/// accessed later using [`PanicInfo::payload`].
+/// accessed later using [`PanicHookInfo::payload`].
 ///
 /// See the [`panic!`] macro for more information about panicking.
 #[stable(feature = "panic_any", since = "1.51.0")]