Repository: rust-lang/rust-bindgen (rust)

Issue:
The `c_unwind` ABI is stable in 1.71
Now that [`c_unwind` has been stabilized](https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html#c-unwind-abi) we can put it under the right Rust version instead of just using nightly.

Pull request:
C unwind is stable
Closes #2581 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7727787a..8befcb7a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -175,6 +175,9 @@
 ## Changed
 - The `Clone` implementation for `_BindgenUnionField` has been changed to pass
   the `incorrect_clone_impl_on_copy_type` Clippy lint.
+- The `c_unwind` ABI can be used without a feature gate for any Rust target version
+  equal to or greater than 1.71.
+  This comes as a result of the ABI being stabilised (in Rust 1.71).
 ## Removed
 ## Fixed
 - Bindgen no longer panics when parsing an objective-C header that includes a
diff --git a/bindgen/features.rs b/bindgen/features.rs
index bee0e859..12e78db4 100644
--- a/bindgen/features.rs
+++ b/bindgen/features.rs
@@ -137,10 +137,12 @@ macro_rules! rust_target_base {
             /// Rust stable 1.68
             ///  * `abi_efiapi` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/65815))
             => Stable_1_68 => 1.68;
+            /// Rust stable 1.71
+            ///  * `c_unwind` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/74990))
+            => Stable_1_71 => 1.71;
             /// Nightly rust
             ///  * `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202))
             ///  * `vectorcall` calling convention (no tracking issue)
-            ///  * `c_unwind` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/74990))
             => Nightly => nightly;
         );
     }
@@ -150,7 +152,7 @@ rust_target_base!(rust_target_def);
 rust_target_base!(rust_target_values_def);
 
 /// Latest stable release of Rust
-pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_68;
+pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_71;
 
 /// Create RustFeatures struct definition, new(), and a getter for each field
 macro_rules! rust_feature_def {
@@ -253,10 +255,12 @@ rust_feature_def!(
     Stable_1_68 {
         => abi_efiapi;
     }
+    Stable_1_71 {
+        => c_unwind_abi;
+    }
     Nightly {
         => thiscall_abi;
         => vectorcall_abi;
-        => c_unwind_abi;
     }
 );
 
@@ -296,6 +300,12 @@ mod test {
                 !f_1_21.thiscall_abi &&
                 !f_1_21.vectorcall_abi
         );
+        let features = RustFeatures::from(RustTarget::Stable_1_71);
+        assert!(
+            features.c_unwind_abi &&
+                features.abi_efiapi &&
+                !features.thiscall_abi
+        );
         let f_nightly = RustFeatures::from(RustTarget::Nightly);
         assert!(
             f_nightly.static_lifetime_elision &&
@@ -306,8 +316,7 @@ mod test {
                 f_nightly.maybe_uninit &&
                 f_nightly.repr_align &&
                 f_nightly.thiscall_abi &&
-                f_nightly.vectorcall_abi &&
-                f_nightly.c_unwind_abi
+                f_nightly.vectorcall_abi
         );
     }
 
@@ -324,6 +333,7 @@ mod test {
         test_target("1.19", RustTarget::Stable_1_19);
         test_target("1.21", RustTarget::Stable_1_21);
         test_target("1.25", RustTarget::Stable_1_25);
+        test_target("1.71", RustTarget::Stable_1_71);
         test_target("nightly", RustTarget::Nightly);
     }
 }


Test patch:
diff --git a/bindgen-tests/tests/expectations/tests/c-unwind-abi-override-nightly.rs b/bindgen-tests/tests/expectations/tests/c-unwind-abi-override.rs
similarity index 78%
rename from bindgen-tests/tests/expectations/tests/c-unwind-abi-override-nightly.rs
rename to bindgen-tests/tests/expectations/tests/c-unwind-abi-override.rs
index 8511b30f..25fd333c 100644
--- a/bindgen-tests/tests/expectations/tests/c-unwind-abi-override-nightly.rs
+++ b/bindgen-tests/tests/expectations/tests/c-unwind-abi-override.rs
@@ -1,6 +1,4 @@
 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#![cfg(feature = "nightly")]
-#![feature(abi_thiscall)]
 extern "C-unwind" {
     pub fn foo();
 }
diff --git a/bindgen-tests/tests/headers/c-unwind-abi-override-nightly.h b/bindgen-tests/tests/headers/c-unwind-abi-override-nightly.h
deleted file mode 100644
index ac79a420..00000000
--- a/bindgen-tests/tests/headers/c-unwind-abi-override-nightly.h
+++ /dev/null
@@ -1,5 +0,0 @@
-// bindgen-flags: --override-abi="foo|bar=C-unwind" --rust-target=nightly --raw-line '#![cfg(feature = "nightly")]' --raw-line '#![feature(abi_thiscall)]'
-
-void foo();
-void bar();
-void baz();
diff --git a/bindgen-tests/tests/headers/c-unwind-abi-override.h b/bindgen-tests/tests/headers/c-unwind-abi-override.h
new file mode 100644
index 00000000..591f4b84
--- /dev/null
+++ b/bindgen-tests/tests/headers/c-unwind-abi-override.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --override-abi="foo|bar=C-unwind"
+
+void foo();
+void bar();
+void baz();