Skip to content

Commit 0ece12c

Browse files
committed
Stabilize extended_varargs_abi_support
1 parent 0ff8610 commit 0ece12c

File tree

12 files changed

+11
-119
lines changed

12 files changed

+11
-119
lines changed

compiler/rustc_feature/src/accepted.rs

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ declare_features! (
159159
(accepted, explicit_generic_args_with_impl_trait, "1.63.0", Some(83701), None),
160160
/// Allows arbitrary expressions in key-value attributes at parse time.
161161
(accepted, extended_key_value_attributes, "1.54.0", Some(78835), None),
162+
/// Allows using `efiapi`, `aapcs`, `sysv64` and `win64` as calling
163+
/// convention for functions with varargs.
164+
(accepted, extended_varargs_abi_support, "1.74.0", Some(100189), None),
162165
/// Allows resolving absolute paths as paths from other crates.
163166
(accepted, extern_absolute_paths, "1.30.0", Some(44660), None),
164167
/// 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
@@ -443,9 +443,6 @@ declare_features! (
443443
(unstable, exhaustive_patterns, "1.13.0", Some(51085), None),
444444
/// Allows explicit tail calls via `become` expression.
445445
(incomplete, explicit_tail_calls, "1.72.0", Some(112788), None),
446-
/// Allows using `efiapi`, `sysv64` and `win64` as calling convention
447-
/// for functions with varargs.
448-
(unstable, extended_varargs_abi_support, "1.65.0", Some(100189), None),
449446
/// Allows defining `extern type`s.
450447
(unstable, extern_types, "1.23.0", Some(43467), None),
451448
/// Allows the use of `#[ffi_const]` on foreign functions.

compiler/rustc_hir_analysis/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ hir_analysis_value_of_associated_struct_already_specified =
408408
.label = re-bound here
409409
.previous_bound_label = `{$item_name}` bound here first
410410
411-
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
411+
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `aapcs`, `win64`, `sysv64` or `efiapi`
412412
.label = C-variadic function must have a compatible calling convention
413413
414414
hir_analysis_variances_of = {$variances_of}

compiler/rustc_hir_analysis/src/errors.rs

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

425425
#[derive(Diagnostic)]
426426
#[diag(hir_analysis_variadic_function_compatible_convention, code = "E0045")]
427-
pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
427+
pub(crate) struct VariadicFunctionCompatibleConvention {
428428
#[primary_span]
429429
#[label]
430430
pub span: Span,
431-
pub conventions: &'a str,
432431
}
433432

434433
#[derive(Diagnostic)]

compiler/rustc_hir_analysis/src/lib.rs

+3-33
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ use rustc_middle::middle;
106106
use rustc_middle::query::Providers;
107107
use rustc_middle::ty::{self, Ty, TyCtxt};
108108
use rustc_middle::util;
109-
use rustc_session::parse::feature_err;
110-
use rustc_span::{symbol::sym, Span, DUMMY_SP};
109+
use rustc_span::{Span, DUMMY_SP};
111110
use rustc_target::spec::abi::Abi;
112111
use rustc_trait_selection::traits;
113112

@@ -118,38 +117,9 @@ use rustc_hir::def::DefKind;
118117
fluent_messages! { "../messages.ftl" }
119118

120119
fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) {
121-
const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `aapcs`, `win64`, `sysv64` or `efiapi`";
122-
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
123-
const UNSTABLE_EXPLAIN: &str =
124-
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";
125-
126-
if !decl.c_variadic || matches!(abi, Abi::C { .. } | Abi::Cdecl { .. }) {
127-
return;
120+
if decl.c_variadic && !abi.supports_varargs() {
121+
tcx.sess.emit_err(errors::VariadicFunctionCompatibleConvention { span });
128122
}
129-
130-
let extended_abi_support = tcx.features().extended_varargs_abi_support;
131-
let conventions = match (extended_abi_support, abi.supports_varargs()) {
132-
// User enabled additional ABI support for varargs and function ABI matches those ones.
133-
(true, true) => return,
134-
135-
// Using this ABI would be ok, if the feature for additional ABI support was enabled.
136-
// Return CONVENTIONS_STABLE, because we want the other error to look the same.
137-
(false, true) => {
138-
feature_err(
139-
&tcx.sess.parse_sess,
140-
sym::extended_varargs_abi_support,
141-
span,
142-
UNSTABLE_EXPLAIN,
143-
)
144-
.emit();
145-
CONVENTIONS_STABLE
146-
}
147-
148-
(false, false) => CONVENTIONS_STABLE,
149-
(true, false) => CONVENTIONS_UNSTABLE,
150-
};
151-
152-
tcx.sess.emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
153123
}
154124

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

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

-17
This file was deleted.

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

-49
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`, `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.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
fn baz(f: extern "stdcall" fn(usize, ...)) {
54
//~^ ERROR: C-variadic function must have a compatible calling convention,

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`, `aapcs`, `win64`, `sysv64` or `efiapi`
2-
--> $DIR/variadic-ffi-2.rs:4:11
2+
--> $DIR/variadic-ffi-2.rs:3:11
33
|
44
LL | fn baz(f: extern "stdcall" fn(usize, ...)) {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention

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`, `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)