about summary refs log tree commit diff
path: root/library/core/src/panic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/core/src/panic.rs')
-rw-r--r--library/core/src/panic.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/library/core/src/panic.rs b/library/core/src/panic.rs
index 7a8b04d6f3c..0be3f06ff6c 100644
--- a/library/core/src/panic.rs
+++ b/library/core/src/panic.rs
@@ -58,6 +58,39 @@ pub macro panic_2021 {
     ),
 }
 
+#[doc(hidden)]
+#[unstable(feature = "edition_panic", issue = "none", reason = "use unreachable!() instead")]
+#[allow_internal_unstable(core_panic)]
+#[rustc_diagnostic_item = "unreachable_2015_macro"]
+#[rustc_macro_transparency = "semitransparent"]
+pub macro unreachable_2015 {
+    () => (
+        $crate::panicking::panic("internal error: entered unreachable code")
+    ),
+    // Use of `unreachable_display` for non_fmt_panic lint.
+    // NOTE: the message ("internal error ...") is embeded directly in unreachable_display
+    ($msg:expr $(,)?) => (
+        $crate::panicking::unreachable_display(&$msg)
+    ),
+    ($fmt:expr, $($arg:tt)*) => (
+        $crate::panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
+    ),
+}
+
+#[doc(hidden)]
+#[unstable(feature = "edition_panic", issue = "none", reason = "use unreachable!() instead")]
+#[allow_internal_unstable(core_panic)]
+#[rustc_diagnostic_item = "unreachable_2021_macro"]
+#[rustc_macro_transparency = "semitransparent"]
+pub macro unreachable_2021 {
+    () => (
+        $crate::panicking::panic("internal error: entered unreachable code")
+    ),
+    ($($t:tt)+) => (
+        $crate::panic!("internal error: entered unreachable code: {}", $crate::format_args!($($t)+))
+    ),
+}
+
 /// An internal trait used by libstd to pass data from libstd to `panic_unwind`
 /// and other panic runtimes. Not intended to be stabilized any time soon, do
 /// not use.