Skip to content

Commit 685f189

Browse files
committed
Stabilize extended_varargs_abi_support
1 parent f5d1857 commit 685f189

File tree

16 files changed

+12
-124
lines changed

16 files changed

+12
-124
lines changed

compiler/rustc_feature/src/accepted.rs

+3
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ declare_features! (
193193
(accepted, expr_fragment_specifier_2024, "1.83.0", Some(123742)),
194194
/// Allows arbitrary expressions in key-value attributes at parse time.
195195
(accepted, extended_key_value_attributes, "1.54.0", Some(78835)),
196+
/// Allows using `efiapi`, `aapcs`, `sysv64` and `win64` as calling
197+
/// convention for functions with varargs.
198+
(accepted, extended_varargs_abi_support, "CURRENT_RUSTC_VERSION", Some(100189)),
196199
/// Allows resolving absolute paths as paths from other crates.
197200
(accepted, extern_absolute_paths, "1.30.0", Some(44660)),
198201
/// 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
@@ -471,9 +471,6 @@ declare_features! (
471471
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
472472
/// Allows explicit tail calls via `become` expression.
473473
(incomplete, explicit_tail_calls, "1.72.0", Some(112788)),
474-
/// Allows using `efiapi`, `sysv64` and `win64` as calling convention
475-
/// for functions with varargs.
476-
(unstable, extended_varargs_abi_support, "1.65.0", Some(100189)),
477474
/// Allows defining `extern type`s.
478475
(unstable, extern_types, "1.23.0", Some(43467)),
479476
/// 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
@@ -587,7 +587,7 @@ hir_analysis_value_of_associated_struct_already_specified =
587587
.label = re-bound here
588588
.previous_bound_label = `{$item_name}` bound here first
589589
590-
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
590+
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
591591
.label = C-variadic function must have a compatible calling convention
592592
593593
hir_analysis_variances_of = {$variances}

compiler/rustc_hir_analysis/src/errors.rs

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

673673
#[derive(Diagnostic)]
674674
#[diag(hir_analysis_variadic_function_compatible_convention, code = E0045)]
675-
pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
675+
pub(crate) struct VariadicFunctionCompatibleConvention {
676676
#[primary_span]
677677
#[label]
678678
pub span: Span,
679-
pub conventions: &'a str,
680679
}
681680

682681
#[derive(Diagnostic)]

compiler/rustc_hir_analysis/src/lib.rs

+2-29
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ use rustc_middle::middle;
9898
use rustc_middle::mir::interpret::GlobalId;
9999
use rustc_middle::query::Providers;
100100
use rustc_middle::ty::{self, Const, Ty, TyCtxt};
101-
use rustc_session::parse::feature_err;
102101
use rustc_span::Span;
103-
use rustc_span::symbol::sym;
104102
use rustc_trait_selection::traits;
105103

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

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

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@
295295
#![feature(doc_masked)]
296296
#![feature(doc_notable_trait)]
297297
#![feature(dropck_eyepatch)]
298-
#![feature(extended_varargs_abi_support)]
299298
#![feature(f128)]
300299
#![feature(f16)]
301300
#![feature(if_let_guard)]

src/doc/unstable-book/src/language-features/extended-varargs-abi-support.md

-10
This file was deleted.

tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs

-19
This file was deleted.

tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr

-52
This file was deleted.

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` or `cdecl`
1+
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
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,6 +1,5 @@
11
//@ only-arm
22
//@ build-pass
3-
#![feature(extended_varargs_abi_support)]
43

54
fn aapcs(f: extern "aapcs" fn(usize, ...)) {
65
f(22, 44);

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

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

43
#[allow(unsupported_fn_ptr_calling_conventions)]
54
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:5:11
2+
--> $DIR/variadic-ffi-2.rs:4: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` or `cdecl` [E0045]
42+
//~^ ERROR C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi` [E0045]

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

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

71-
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
71+
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
7272
--> $DIR/generics.rs:41:20
7373
|
7474
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` or `cdecl`
1+
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
22
--> $DIR/E0045.rs:1:17
33
|
44
LL | extern "Rust" { fn foo(x: u8, ...); }

0 commit comments

Comments
 (0)