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
This commit is contained in:
Matthias Krüger 2025-04-17 00:16:20 +02:00 committed by GitHub
commit bb3e156f62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 334 additions and 21 deletions

View file

@ -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
```