@@ -98,8 +98,6 @@ use rustc_middle::middle;
9898use rustc_middle:: mir:: interpret:: GlobalId ;
9999use rustc_middle:: query:: Providers ;
100100use rustc_middle:: ty:: { self , Const , Ty , TyCtxt } ;
101- use rustc_session:: parse:: feature_err;
102- use rustc_span:: symbol:: sym;
103101use rustc_span:: { ErrorGuaranteed , Span } ;
104102use rustc_trait_selection:: traits;
105103
@@ -108,46 +106,23 @@ use crate::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
108106
109107rustc_fluent_macro:: fluent_messages! { "../messages.ftl" }
110108
111- fn require_c_abi_if_c_variadic (
112- tcx : TyCtxt < ' _ > ,
113- decl : & hir:: FnDecl < ' _ > ,
114- abi : ExternAbi ,
115- span : Span ,
116- ) {
117- // ABIs which can stably use varargs
118- if !decl. c_variadic || matches ! ( abi, ExternAbi :: C { .. } | ExternAbi :: Cdecl { .. } ) {
109+ fn check_c_variadic_abi ( tcx : TyCtxt < ' _ > , decl : & hir:: FnDecl < ' _ > , abi : ExternAbi , span : Span ) {
110+ if !decl. c_variadic {
111+ // Not even a variadic function.
119112 return ;
120113 }
121-
122- // ABIs with feature-gated stability
123- let extended_abi_support = tcx. features ( ) . extended_varargs_abi_support ( ) ;
124- let extern_system_varargs = tcx. features ( ) . extern_system_varargs ( ) ;
125-
126- // If the feature gate has been enabled, we can stop here
127- if extern_system_varargs && let ExternAbi :: System { .. } = abi {
114+ if abi. supports_c_variadic ( ) {
115+ // Variadics are stable.
128116 return ;
129- } ;
130- if extended_abi_support && abi. supports_varargs ( ) {
131- return ;
132- } ;
117+ }
133118
134- // Looks like we need to pick an error to emit.
135- // Is there any feature which we could have enabled to make this work?
136- let unstable_explain =
137- format ! ( "C-variadic functions with the {abi} calling convention are unstable" ) ;
138- match abi {
139- ExternAbi :: System { .. } => {
140- feature_err ( & tcx. sess , sym:: extern_system_varargs, span, unstable_explain)
141- }
142- abi if abi. supports_varargs ( ) => {
143- feature_err ( & tcx. sess , sym:: extended_varargs_abi_support, span, unstable_explain)
144- }
145- _ => tcx. dcx ( ) . create_err ( errors:: VariadicFunctionCompatibleConvention {
119+ // Everything else is unstable.
120+ tcx. dcx ( )
121+ . create_err ( errors:: VariadicFunctionCompatibleConvention {
146122 span,
147123 convention : & format ! ( "{abi}" ) ,
148- } ) ,
149- }
150- . emit ( ) ;
124+ } )
125+ . emit ( ) ;
151126}
152127
153128/// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`]
0 commit comments