From b48274fd98b74c1fb28842d899aa0ee377d9f923 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Fri, 9 Jul 2021 17:29:41 +0200 Subject: [PATCH] Use unreachable_unchecked in const_panic_fmt. --- library/core/src/panicking.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 03398869466c..65267a417cb4 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -100,7 +100,10 @@ pub const fn const_panic_fmt(fmt: fmt::Arguments<'_>) -> ! { if let Some(msg) = fmt.as_str() { panic_str(msg); } else { - panic_str("???"); + // SAFETY: This is only evaluated at compile time, which handles this + // fine (in case it turns out this branch turns out to be reachable + // somehow). + unsafe { crate::hint::unreachable_unchecked() }; } }