Skip to content

Commit ee53c26

Browse files
committed
Add explicit_extern_abis unstable feature
also add `explicit-extern-abis` feature section to the unstable book.
1 parent c580c49 commit ee53c26

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Diff for: compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ declare_features! (
477477
(incomplete, ergonomic_clones, "1.87.0", Some(132290)),
478478
/// Allows exhaustive pattern matching on types that contain uninhabited types.
479479
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
480+
/// Disallows `extern` without an explicit ABI.
481+
(unstable, explicit_extern_abis, "CURRENT_RUSTC_VERSION", Some(134986)),
480482
/// Allows explicit tail calls via `become` expression.
481483
(incomplete, explicit_tail_calls, "1.72.0", Some(112788)),
482484
/// Allows using `aapcs`, `efiapi`, `sysv64` and `win64` as calling conventions

Diff for: compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ symbols! {
916916
expf16,
917917
expf32,
918918
expf64,
919+
explicit_extern_abis,
919920
explicit_generic_args_with_impl_trait,
920921
explicit_tail_calls,
921922
export_name,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# `explicit_extern_abis`
2+
3+
The tracking issue for this feature is: #134986
4+
5+
------
6+
7+
Disallow `extern` without an explicit ABI. We should write `extern "C"`
8+
(or another ABI) instead of just `extern`.
9+
10+
By making the ABI explicit, it becomes much clearer that "C" is just one of the
11+
possible choices, rather than the "standard" way for external functions.
12+
Removing the default makes it easier to add a new ABI on equal footing as "C".
13+
14+
```rust,editionfuture,compile_fail
15+
#![feature(explicit_extern_abis)]
16+
17+
extern fn function1() {} // ERROR `extern` declarations without an explicit ABI
18+
// are disallowed
19+
20+
extern "C" fn function2() {} // compiles
21+
22+
extern "aapcs" fn function3() {} // compiles
23+
```

0 commit comments

Comments
 (0)