Use unreachable_unchecked in const_panic_fmt.

This commit is contained in:
Mara Bos 2021-07-09 17:29:41 +02:00
parent b64c4f9560
commit b48274fd98

View File

@ -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() };
}
}