about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-07-09 17:29:41 +0200
committerMara Bos <m-ou.se@m-ou.se>2021-07-28 16:12:30 +0200
commitb48274fd98b74c1fb28842d899aa0ee377d9f923 (patch)
treeec733afb19808b2eda22a59ad68226dc395109a5
parentb64c4f9560e370eb718dfd266d9251d0394e6857 (diff)
downloadrust-b48274fd98b74c1fb28842d899aa0ee377d9f923.tar.gz
rust-b48274fd98b74c1fb28842d899aa0ee377d9f923.zip
Use unreachable_unchecked in const_panic_fmt.
-rw-r--r--library/core/src/panicking.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs
index 03398869466..65267a417cb 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() };
     }
 }