about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-17 00:16:20 +0200
committerGitHub <noreply@github.com>2025-04-17 00:16:20 +0200
commitbb3e156f62c8a7f2f88ff70d513f35e9c1ddc40f (patch)
treea20e5870572e82c1d870be7a858f19d187138636 /src
parent78f2104e334068d5a892a170d50193c0025c690e (diff)
parentd17c04e4a220d6f7bf170eeb0f90498e215555fa (diff)
downloadrust-bb3e156f62c8a7f2f88ff70d513f35e9c1ddc40f.tar.gz
rust-bb3e156f62c8a7f2f88ff70d513f35e9c1ddc40f.zip
Rollup merge of #135340 - obeis:explicit-extern-abis, r=traviscross,nadrieril
Add `explicit_extern_abis` Feature and Enforce Explicit ABIs

The unstable `explicit_extern_abis` feature is introduced, requiring explicit ABIs in `extern` blocks. Hard errors will be enforced with this feature enabled in a future edition.

RFC rust-lang/rfcs#3722

Update #134986
Diffstat (limited to 'src')
-rw-r--r--src/doc/unstable-book/src/language-features/explicit-extern-abis.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/explicit-extern-abis.md b/src/doc/unstable-book/src/language-features/explicit-extern-abis.md
new file mode 100644
index 00000000000..ba622466ba7
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/explicit-extern-abis.md
@@ -0,0 +1,23 @@
+# `explicit_extern_abis`
+
+The tracking issue for this feature is: #134986
+
+------
+
+Disallow `extern` without an explicit ABI. We should write `extern "C"`
+(or another ABI) instead of just `extern`.
+
+By making the ABI explicit, it becomes much clearer that "C" is just one of the
+possible choices, rather than the "standard" way for external functions.
+Removing the default makes it easier to add a new ABI on equal footing as "C".
+
+```rust,editionfuture,compile_fail
+#![feature(explicit_extern_abis)]
+
+extern fn function1() {}  // ERROR `extern` declarations without an explicit ABI
+                          // are disallowed
+
+extern "C" fn function2() {} // compiles
+
+extern "aapcs" fn function3() {} // compiles
+```