about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-24 01:22:04 +0100
committerGitHub <noreply@github.com>2023-03-24 01:22:04 +0100
commitd9c05b853d7745ea36bc54b0c5b7b00b3737d706 (patch)
tree15a9efb4f98cf8774b45f6e3ecacf8a7d679b6ed
parenteb46afb21683bc54f86c556bacff7c9bd82f9933 (diff)
parent7c75e39790a6cfd5f4f8e90a2554286d3d9eabea (diff)
Rollup merge of #108924 - tmiasko:panic-immediate-abort, r=thomcc
panic_immediate_abort requires abort as a panic strategy

Guide `panic_immediate_abort` users away from `-Cpanic=unwind` and towards `-Cpanic=abort` to avoid an accidental use of the feature with the unwind strategy, e.g., on a targets where unwind is the default.

The `-Cpanic=unwind` combination doesn't offer the same benefits, since the code would still be generated under the assumption that functions implemented in Rust can unwind.
-rw-r--r--library/core/src/panicking.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs
index dd0105c0eb4..35da9151b6f 100644
--- a/library/core/src/panicking.rs
+++ b/library/core/src/panicking.rs
@@ -29,6 +29,9 @@
 use crate::fmt;
 use crate::panic::{Location, PanicInfo};
 
+#[cfg(feature = "panic_immediate_abort")]
+const _: () = assert!(cfg!(panic = "abort"), "panic_immediate_abort requires -C panic=abort");
+
 // First we define the two main entry points that all panics go through.
 // In the end both are just convenience wrappers around `panic_impl`.