From 0d07b4c2ce5bd677735dc8d2265395d52041636f Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 20 Sep 2023 18:59:12 +0200 Subject: [PATCH 1/2] Call panic_display directly in const_panic_fmt. --- library/core/src/panicking.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 281f8c1e1663c..1f4c7c376bda9 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -234,7 +234,8 @@ fn panic_in_cleanup() -> ! { #[rustc_const_unstable(feature = "core_panic", issue = "none")] pub const fn const_panic_fmt(fmt: fmt::Arguments<'_>) -> ! { if let Some(msg) = fmt.as_str() { - panic_str(msg); + // The panic_display function is hooked by conost eval. + panic_display(&msg); } else { // SAFETY: This is only evaluated at compile time, which reliably // handles this UB (in case this branch turns out to be reachable From 667bba46b0dc1ed5f481431c48c24b8326e099a1 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 20 Sep 2023 22:37:39 +0200 Subject: [PATCH 2/2] Fix typo. --- library/core/src/panicking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 1f4c7c376bda9..e6cdffd96afbc 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -234,7 +234,7 @@ fn panic_in_cleanup() -> ! { #[rustc_const_unstable(feature = "core_panic", issue = "none")] pub const fn const_panic_fmt(fmt: fmt::Arguments<'_>) -> ! { if let Some(msg) = fmt.as_str() { - // The panic_display function is hooked by conost eval. + // The panic_display function is hooked by const eval. panic_display(&msg); } else { // SAFETY: This is only evaluated at compile time, which reliably