From 01b0aff1df1dd5ee7c60e8fbeff15cc3edaa3208 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 22 Jul 2020 12:17:36 +0200 Subject: [PATCH 1/4] Add std::panic::panic_box. --- library/std/src/panic.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 4281867314cca..06ce66c10f7ea 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -23,6 +23,20 @@ pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use core::panic::{Location, PanicInfo}; +/// Panic the current thread, with the given payload as the panic message. +/// +/// This supports an arbitrary panic payload, instead of just (formatted) strings. +/// +/// The message is attached as a `Box<'static + Any + Send>`, which can be +/// accessed using [`PanicInfo::payload`]. +/// +/// See the [`panic!`] macro for more information about panicking. +#[unstable(feature = "panic_box", issue = "none")] +#[inline] +pub fn panic_box(msg: M) -> ! { + crate::panicking::begin_panic(msg); +} + /// A marker trait which represents "panic safe" types in Rust. /// /// This trait is implemented by default for many types and behaves similarly in From 16201da6a4ff613d00ca3680c43cbb1b52f60cf1 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 18 Oct 2020 12:29:13 +0200 Subject: [PATCH 2/4] Rename panic_box to panic_any. --- library/std/src/panic.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 06ce66c10f7ea..9a756e4bbb4d4 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -23,17 +23,17 @@ pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use core::panic::{Location, PanicInfo}; -/// Panic the current thread, with the given payload as the panic message. +/// Panic the current thread with the given message as the panic payload. /// -/// This supports an arbitrary panic payload, instead of just (formatted) strings. +/// The message can be of any (`Any + Send`) type, not just strings. /// -/// The message is attached as a `Box<'static + Any + Send>`, which can be -/// accessed using [`PanicInfo::payload`]. +/// The message is wrapped in a `Box<'static + Any + Send>`, which can be +/// accessed later using [`PanicInfo::payload`]. /// /// See the [`panic!`] macro for more information about panicking. #[unstable(feature = "panic_box", issue = "none")] #[inline] -pub fn panic_box(msg: M) -> ! { +pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg); } From a9d334d386e5abf79d8ee60f94bf32147b755c4c Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 28 Oct 2020 21:21:41 +0100 Subject: [PATCH 3/4] Update panic_any feature name. Co-authored-by: Camelid --- library/std/src/panic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 9a756e4bbb4d4..ad91933d65102 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -31,7 +31,7 @@ pub use core::panic::{Location, PanicInfo}; /// accessed later using [`PanicInfo::payload`]. /// /// See the [`panic!`] macro for more information about panicking. -#[unstable(feature = "panic_box", issue = "none")] +#[unstable(feature = "panic_any", issue = "none")] #[inline] pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg); From b48fee010c92dde304154ba45c0e41d396e60568 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 28 Oct 2020 21:23:45 +0100 Subject: [PATCH 4/4] Add tracking issue number for panic_any. --- library/std/src/panic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index ad91933d65102..d18b94b6c1aef 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -31,7 +31,7 @@ pub use core::panic::{Location, PanicInfo}; /// accessed later using [`PanicInfo::payload`]. /// /// See the [`panic!`] macro for more information about panicking. -#[unstable(feature = "panic_any", issue = "none")] +#[unstable(feature = "panic_any", issue = "78500")] #[inline] pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg);