@@ -30,11 +30,11 @@ use rustc_data_structures::fx::FxIndexMap;
3030use rustc_errors:: { DiagCtxtHandle , Diagnostic , LintBuffer } ;
3131use rustc_feature:: Features ;
3232use rustc_session:: Session ;
33+ use rustc_session:: errors:: feature_err;
3334use rustc_session:: lint:: builtin:: {
3435 DEPRECATED_WHERE_CLAUSE_LOCATION , MISSING_ABI , MISSING_UNSAFE_ON_EXTERN ,
3536 PATTERNS_IN_FNS_WITHOUT_BODY , UNUSED_VISIBILITIES ,
3637} ;
37- use rustc_session:: parse:: feature_err;
3838use rustc_span:: { Ident , Span , kw, sym} ;
3939use rustc_target:: spec:: { AbiMap , AbiMapping } ;
4040use thin_vec:: thin_vec;
@@ -762,12 +762,23 @@ impl<'a> AstValidator<'a> {
762762 match fn_ctxt {
763763 FnCtxt :: Foreign => return ,
764764 FnCtxt :: Free | FnCtxt :: Assoc ( _) => {
765- if !self . sess . target . supports_c_variadic_definitions ( ) {
766- self . dcx ( ) . emit_err ( errors:: CVariadicNotSupported {
767- variadic_span : variadic_param. span ,
768- target : & * self . sess . target . llvm_target ,
769- } ) ;
770- return ;
765+ match self . sess . target . supports_c_variadic_definitions ( ) {
766+ CVariadicStatus :: NotSupported => {
767+ self . dcx ( ) . emit_err ( errors:: CVariadicNotSupported {
768+ variadic_span : variadic_param. span ,
769+ target : & * self . sess . target . llvm_target ,
770+ } ) ;
771+ return ;
772+ }
773+ CVariadicStatus :: Unstable { feature } if !self . features . enabled ( feature) => {
774+ let msg =
775+ format ! ( "C-variadic function definitions on this target are unstable" ) ;
776+ feature_err ( & self . sess , feature, variadic_param. span , msg) . emit ( ) ;
777+ return ;
778+ }
779+ CVariadicStatus :: Unstable { .. } | CVariadicStatus :: Stable => {
780+ /* fall through */
781+ }
771782 }
772783
773784 match sig. header . ext {
0 commit comments