Skip to content

Commit 021fb9c

Browse files
committed
Auto merge of #136897 - workingjubilee:revert-unfcped-stab, r=WaffleLapkin
Revert "Stabilize `extended_varargs_abi_support`" I cannot find an FCP for this, despite it being a stabilization PR which normally means we do an FCP of some kind? It would seem reasonable for _either_ compiler or lang to have FCPed it? I am thus opening a revert PR, which mostly-cleanly applies, so that we can later actually land this properly with a stability report and FCP. - #136896 - #116161 - #100189
2 parents 33d92df + cafa646 commit 021fb9c

File tree

16 files changed

+126
-12
lines changed

16 files changed

+126
-12
lines changed

compiler/rustc_feature/src/accepted.rs

-3
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ declare_features! (
197197
(accepted, expr_fragment_specifier_2024, "1.83.0", Some(123742)),
198198
/// Allows arbitrary expressions in key-value attributes at parse time.
199199
(accepted, extended_key_value_attributes, "1.54.0", Some(78835)),
200-
/// Allows using `efiapi`, `aapcs`, `sysv64` and `win64` as calling
201-
/// convention for functions with varargs.
202-
(accepted, extended_varargs_abi_support, "1.85.0", Some(100189)),
203200
/// Allows resolving absolute paths as paths from other crates.
204201
(accepted, extern_absolute_paths, "1.30.0", Some(44660)),
205202
/// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude.

compiler/rustc_feature/src/unstable.rs

+3
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ declare_features! (
487487
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
488488
/// Allows explicit tail calls via `become` expression.
489489
(incomplete, explicit_tail_calls, "1.72.0", Some(112788)),
490+
/// Allows using `efiapi`, `sysv64` and `win64` as calling convention
491+
/// for functions with varargs.
492+
(unstable, extended_varargs_abi_support, "1.65.0", Some(100189)),
490493
/// Allows defining `extern type`s.
491494
(unstable, extern_types, "1.23.0", Some(43467)),
492495
/// Allow using 128-bit (quad precision) floating point numbers.

compiler/rustc_hir_analysis/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ hir_analysis_value_of_associated_struct_already_specified =
602602
.label = re-bound here
603603
.previous_bound_label = `{$item_name}` bound here first
604604
605-
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
605+
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
606606
.label = C-variadic function must have a compatible calling convention
607607
608608
hir_analysis_variances_of = {$variances}

compiler/rustc_hir_analysis/src/errors.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,11 @@ pub(crate) struct MainFunctionGenericParameters {
646646

647647
#[derive(Diagnostic)]
648648
#[diag(hir_analysis_variadic_function_compatible_convention, code = E0045)]
649-
pub(crate) struct VariadicFunctionCompatibleConvention {
649+
pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
650650
#[primary_span]
651651
#[label]
652652
pub span: Span,
653+
pub conventions: &'a str,
653654
}
654655

655656
#[derive(Diagnostic)]

compiler/rustc_hir_analysis/src/lib.rs

+29-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ use rustc_middle::middle;
100100
use rustc_middle::mir::interpret::GlobalId;
101101
use rustc_middle::query::Providers;
102102
use rustc_middle::ty::{self, Const, Ty, TyCtxt};
103+
use rustc_session::parse::feature_err;
104+
use rustc_span::symbol::sym;
103105
use rustc_span::{ErrorGuaranteed, Span};
104106
use rustc_trait_selection::traits;
105107

@@ -114,9 +116,34 @@ fn require_c_abi_if_c_variadic(
114116
abi: ExternAbi,
115117
span: Span,
116118
) {
117-
if decl.c_variadic && !abi.supports_varargs() {
118-
tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span });
119+
const CONVENTIONS_UNSTABLE: &str =
120+
"`C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`";
121+
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
122+
const UNSTABLE_EXPLAIN: &str =
123+
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";
124+
125+
if !decl.c_variadic || matches!(abi, ExternAbi::C { .. } | ExternAbi::Cdecl { .. }) {
126+
return;
119127
}
128+
129+
let extended_abi_support = tcx.features().extended_varargs_abi_support();
130+
let conventions = match (extended_abi_support, abi.supports_varargs()) {
131+
// User enabled additional ABI support for varargs and function ABI matches those ones.
132+
(true, true) => return,
133+
134+
// Using this ABI would be ok, if the feature for additional ABI support was enabled.
135+
// Return CONVENTIONS_STABLE, because we want the other error to look the same.
136+
(false, true) => {
137+
feature_err(&tcx.sess, sym::extended_varargs_abi_support, span, UNSTABLE_EXPLAIN)
138+
.emit();
139+
CONVENTIONS_STABLE
140+
}
141+
142+
(false, false) => CONVENTIONS_STABLE,
143+
(true, false) => CONVENTIONS_UNSTABLE,
144+
};
145+
146+
tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
120147
}
121148

122149
pub fn provide(providers: &mut Providers) {

library/std/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@
272272
//
273273
// Language features:
274274
// tidy-alphabetical-start
275+
276+
// stabilization was reverted after it hit beta
277+
#![cfg_attr(not(bootstrap), feature(extended_varargs_abi_support))]
275278
#![feature(alloc_error_handler)]
276279
#![feature(allocator_internals)]
277280
#![feature(allow_internal_unsafe)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `extended_varargs_abi_support`
2+
3+
The tracking issue for this feature is: [#100189]
4+
5+
[#100189]: https://github.com/rust-lang/rust/issues/100189
6+
7+
------------------------
8+
9+
This feature adds the possibility of using `sysv64`, `win64` or `efiapi` calling
10+
conventions on functions with varargs.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ only-x86_64
2+
3+
fn efiapi(f: extern "efiapi" fn(usize, ...)) {
4+
//~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
5+
//~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
6+
f(22, 44);
7+
}
8+
fn sysv(f: extern "sysv64" fn(usize, ...)) {
9+
//~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
10+
//~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
11+
f(22, 44);
12+
}
13+
fn win(f: extern "win64" fn(usize, ...)) {
14+
//~^ ERROR: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
15+
//~^^ ERROR: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
16+
f(22, 44);
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
2+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14
3+
|
4+
LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information
8+
= help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
12+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14
13+
|
14+
LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) {
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
16+
17+
error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
18+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12
19+
|
20+
LL | fn sysv(f: extern "sysv64" fn(usize, ...)) {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
|
23+
= note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information
24+
= help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable
25+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
26+
27+
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
28+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:8:12
29+
|
30+
LL | fn sysv(f: extern "sysv64" fn(usize, ...)) {
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
32+
33+
error[E0658]: using calling conventions other than `C` or `cdecl` for varargs functions is unstable
34+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11
35+
|
36+
LL | fn win(f: extern "win64" fn(usize, ...)) {
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
|
39+
= note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information
40+
= help: add `#![feature(extended_varargs_abi_support)]` to the crate attributes to enable
41+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
42+
43+
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
44+
--> $DIR/feature-gate-extended_varargs_abi_support.rs:13:11
45+
|
46+
LL | fn win(f: extern "win64" fn(usize, ...)) {
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
48+
49+
error: aborting due to 6 previous errors
50+
51+
Some errors have detailed explanations: E0045, E0658.
52+
For more information about an error, try `rustc --explain E0045`.

tests/ui/c-variadic/variadic-ffi-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
1+
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
22
--> $DIR/variadic-ffi-1.rs:9:5
33
|
44
LL | fn printf(_: *const u8, ...);

tests/ui/c-variadic/variadic-ffi-2-arm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ only-arm
22
//@ build-pass
3+
#![feature(extended_varargs_abi_support)]
34

45
fn aapcs(f: extern "aapcs" fn(usize, ...)) {
56
f(22, 44);

tests/ui/c-variadic/variadic-ffi-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ ignore-arm stdcall isn't supported
2+
#![feature(extended_varargs_abi_support)]
23

34
#[allow(unsupported_fn_ptr_calling_conventions)]
45
fn baz(f: extern "stdcall" fn(usize, ...)) {

tests/ui/c-variadic/variadic-ffi-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
2-
--> $DIR/variadic-ffi-2.rs:4:11
2+
--> $DIR/variadic-ffi-2.rs:5:11
33
|
44
LL | fn baz(f: extern "stdcall" fn(usize, ...)) {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention

tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ type WithTransparentTraitObject =
3939
//~^ ERROR return value of `"C-cmse-nonsecure-call"` function too large to pass via registers [E0798]
4040

4141
type WithVarArgs = extern "C-cmse-nonsecure-call" fn(u32, ...);
42-
//~^ ERROR C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi` [E0045]
42+
//~^ ERROR C-variadic function must have a compatible calling convention, like `C` or `cdecl` [E0045]

tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ LL | extern "C-cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTranspa
6969
= note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers
7070
= note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size
7171

72-
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
72+
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
7373
--> $DIR/generics.rs:41:20
7474
|
7575
LL | type WithVarArgs = extern "C-cmse-nonsecure-call" fn(u32, ...);

tests/ui/error-codes/E0045.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
1+
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
22
--> $DIR/E0045.rs:1:17
33
|
44
LL | extern "Rust" { fn foo(x: u8, ...); }

0 commit comments

Comments
 (0)