diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 5a44323a0b755..57fa6310b2bac 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -290,8 +290,8 @@ impl ExternAbi { } /// Returns whether the ABI supports C variadics. This only controls whether we allow *imports* - /// of such functions via `extern` blocks; there's a separate check during AST construction - /// guarding *definitions* of variadic functions. + /// of such functions via `extern` blocks and definition via naked functions; there's a + /// separate check during AST construction guarding *definitions* of variadic functions. #[cfg(feature = "nightly")] pub fn supports_c_variadic(self) -> CVariadicStatus { // * C and Cdecl obviously support varargs. diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index fe1da820cf74f..0a35e6846749b 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -957,29 +957,14 @@ impl<'a> AstValidator<'a> { dotdotdot_span: Span, sig: &FnSig, ) { - // For naked functions we accept any ABI that is accepted on c-variadic - // foreign functions, if the c_variadic_naked_functions feature is enabled. if attr::contains_name(attrs, sym::naked) { match abi.supports_c_variadic() { - CVariadicStatus::Stable if let ExternAbi::C { .. } = abi => { - // With `c_variadic` naked c-variadic `extern "C"` functions are allowed. - } CVariadicStatus::Stable => { - // For e.g. aapcs or sysv64 `c_variadic_naked_functions` must also be enabled. - if !self.features.enabled(sym::c_variadic_naked_functions) { - let msg = format!("Naked c-variadic `extern {abi}` functions are unstable"); - feature_err(&self.sess, sym::c_variadic_naked_functions, sig.span, msg) - .emit(); - } + // For naked functions we accept any ABI that is accepted + // on c-variadic foreign functions. } CVariadicStatus::Unstable { feature } => { - // Some ABIs need additional features. - if !self.features.enabled(sym::c_variadic_naked_functions) { - let msg = format!("Naked c-variadic `extern {abi}` functions are unstable"); - feature_err(&self.sess, sym::c_variadic_naked_functions, sig.span, msg) - .emit(); - } - + // Some ABIs need additional features to be enabled. if !self.features.enabled(feature) { let msg = format!( "C-variadic functions with the {abi} calling convention are unstable" diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 9f42c5c1e7f0b..c71fecf046c9b 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -96,6 +96,9 @@ declare_features! ( (accepted, c_unwind, "1.81.0", Some(74990)), /// Allows using C-variadics. (accepted, c_variadic, "CURRENT_RUSTC_VERSION", Some(44930)), + /// Allows defining c-variadic naked functions with any extern ABI that is allowed + /// on c-variadic foreign functions. + (accepted, c_variadic_naked_functions, "CURRENT_RUSTC_VERSION", Some(148767)), /// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`. (accepted, cfg_attr_multi, "1.33.0", Some(54881)), /// Allows the use of `#[cfg()]`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 3649cf24ea822..c6120f7cb6c8d 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -427,9 +427,6 @@ declare_features! ( /// Allows defining c-variadic functions on targets where this feature has not yet /// undergone sufficient testing for stabilization. (unstable, c_variadic_experimental_arch, "1.97.0", Some(155973)), - /// Allows defining c-variadic naked functions with any extern ABI that is allowed - /// on c-variadic foreign functions. - (unstable, c_variadic_naked_functions, "1.93.0", Some(148767)), /// Allows the use of `#[cfg(contract_checks)` to check if contract checks are enabled. (unstable, cfg_contract_checks, "1.86.0", Some(128044)), /// Allows the use of `#[cfg(overflow_checks)` to check if integer overflow behaviour. diff --git a/tests/ui/c-variadic/naked-invalid.rs b/tests/ui/c-variadic/naked-invalid.rs index 2aeb400c9853e..e0f06dad5c93b 100644 --- a/tests/ui/c-variadic/naked-invalid.rs +++ b/tests/ui/c-variadic/naked-invalid.rs @@ -4,7 +4,7 @@ //@ ignore-backends: gcc #![feature(no_core, lang_items, rustc_attrs)] -#![feature(c_variadic_naked_functions, abi_x86_interrupt, naked_functions_rustic_abi)] +#![feature(abi_x86_interrupt, naked_functions_rustic_abi)] #![crate_type = "rlib"] #![no_core] diff --git a/tests/ui/c-variadic/naked.rs b/tests/ui/c-variadic/naked.rs index cda6a67d04681..db34ce5755c6e 100644 --- a/tests/ui/c-variadic/naked.rs +++ b/tests/ui/c-variadic/naked.rs @@ -1,7 +1,6 @@ //@ run-pass //@ only-x86_64 //@ only-linux -#![feature(c_variadic_naked_functions)] #[repr(C)] #[derive(Debug, PartialEq)] diff --git a/tests/ui/c-variadic/same-program-multiple-abis-arm.rs b/tests/ui/c-variadic/same-program-multiple-abis-arm.rs index 62a701c942d38..d8209ec0165f4 100644 --- a/tests/ui/c-variadic/same-program-multiple-abis-arm.rs +++ b/tests/ui/c-variadic/same-program-multiple-abis-arm.rs @@ -2,7 +2,6 @@ //@ only-arm //@ ignore-thumb (this test uses arm assembly) //@ only-eabihf (the assembly below requires float hardware support) -#![feature(c_variadic_naked_functions)] // Check that multiple c-variadic calling conventions can be used in the same program. // diff --git a/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs b/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs index 78f574667bc0d..440007925b18d 100644 --- a/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs +++ b/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs @@ -1,6 +1,5 @@ //@ run-pass //@ only-x86_64 -#![feature(c_variadic_naked_functions)] // Check that multiple c-variadic calling conventions can be used in the same program. // diff --git a/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.rs b/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.rs deleted file mode 100644 index 1fc0ac4198937..0000000000000 --- a/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ add-minicore -//@ compile-flags: --target x86_64-unknown-linux-gnu -//@ needs-llvm-components: x86 -//@ ignore-backends: gcc - -#![feature(no_core, lang_items, rustc_attrs)] -#![feature(abi_x86_interrupt, naked_functions_rustic_abi)] -#![crate_type = "rlib"] -#![no_core] - -extern crate minicore; -use minicore::*; - -#[repr(C)] -#[lang = "va_list"] -pub struct VaList; - -#[unsafe(naked)] -unsafe extern "sysv64" fn c_variadic_sysv64(_: ...) { - //~^ ERROR Naked c-variadic `extern "sysv64"` functions are unstable - naked_asm!("ret") -} - -#[unsafe(naked)] -unsafe extern "C" fn c_variadic_c(_: ...) { - naked_asm!("ret") -} diff --git a/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.stderr b/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.stderr deleted file mode 100644 index fc44747a4fadb..0000000000000 --- a/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: Naked c-variadic `extern "sysv64"` functions are unstable - --> $DIR/feature-gate-c_variadic-naked-functions.rs:19:1 - | -LL | unsafe extern "sysv64" fn c_variadic_sysv64(_: ...) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #148767 for more information - = help: add `#![feature(c_variadic_naked_functions)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`.