about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2025-03-04 16:38:07 -0800
committerJubilee Young <workingjubilee@gmail.com>2025-03-04 18:21:36 -0800
commit1f32f7bd78e26d673162a168cac01943b544090d (patch)
tree11ccc80cfded0a0be2655db77dd936f7c162ceca
parentf9e0239a7bc813b4aceffc7f069f4797cde3175c (diff)
downloadrust-1f32f7bd78e26d673162a168cac01943b544090d.tar.gz
rust-1f32f7bd78e26d673162a168cac01943b544090d.zip
compiler: add `ExternAbi::is_rustic_abi`
-rw-r--r--compiler/rustc_abi/src/extern_abi.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs
index 543c2f8ab12..4d70afd4e0b 100644
--- a/compiler/rustc_abi/src/extern_abi.rs
+++ b/compiler/rustc_abi/src/extern_abi.rs
@@ -191,6 +191,17 @@ impl StableOrd for ExternAbi {
 }
 
 impl ExternAbi {
+    /// An ABI "like Rust"
+    ///
+    /// These ABIs are fully controlled by the Rust compiler, which means they
+    /// - support unwinding with `-Cpanic=unwind`, unlike `extern "C"`
+    /// - often diverge from the C ABI
+    /// - are subject to change between compiler versions
+    pub fn is_rustic_abi(self) -> bool {
+        use ExternAbi::*;
+        matches!(self, Rust | RustCall | RustIntrinsic | RustCold)
+    }
+
     pub fn supports_varargs(self) -> bool {
         // * C and Cdecl obviously support varargs.
         // * C can be based on Aapcs, SysV64 or Win64, so they must support varargs.