]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/panicking.rs
Re-add track_caller to panic_no_unwind in bootstrap
[rust.git] / library / core / src / panicking.rs
index 5078eea07a15c5499daff9c0fa50d9982407c83b..89cebaa653f4ba9ebee10cba5958555c1ec7f9ab 100644 (file)
@@ -50,12 +50,19 @@ pub const fn panic(expr: &'static str) -> ! {
 
 #[inline]
 #[track_caller]
-#[lang = "panic_str"] // needed for `non-fmt-panics` lint
+#[rustc_diagnostic_item = "panic_str"]
 #[rustc_const_unstable(feature = "core_panic", issue = "none")]
 pub const fn panic_str(expr: &str) -> ! {
     panic_display(&expr);
 }
 
+#[inline]
+#[track_caller]
+#[rustc_diagnostic_item = "unreachable_display"] // needed for `non-fmt-panics` lint
+pub fn unreachable_display<T: fmt::Display>(x: &T) -> ! {
+    panic_fmt(format_args!("internal error: entered unreachable code: {}", *x));
+}
+
 #[inline]
 #[track_caller]
 #[lang = "panic_display"] // needed for const-evaluated panics
@@ -77,10 +84,11 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
     panic!("index out of bounds: the len is {} but the index is {}", len, index)
 }
 
-#[cfg(not(bootstrap))]
+// This function is called directly by the codegen backend, and must not have
+// any extra arguments (including those synthesized by track_caller).
 #[cold]
-#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
-#[track_caller]
+#[inline(never)]
+#[cfg_attr(bootstrap, track_caller)]
 #[lang = "panic_no_unwind"] // needed by codegen for panic in nounwind function
 fn panic_no_unwind() -> ! {
     if cfg!(feature = "panic_immediate_abort") {