Add c_variadic language feature item

This commit is contained in:
Dan Robertson 2019-02-24 22:40:11 +00:00
parent 58147d486b
commit 210c6071b0
No known key found for this signature in database
GPG Key ID: 4DE6EEF84B5C9783
4 changed files with 28 additions and 0 deletions

View File

@ -471,6 +471,9 @@ declare_features! (
// #[repr(align(X))] on enums
(active, repr_align_enum, "1.34.0", Some(57996), None),
// Allows the use of C-variadics
(active, c_variadic, "1.34.0", Some(44930), None),
);
declare_features! (
@ -1901,6 +1904,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
if header.asyncness.is_async() {
gate_feature_post!(&self, async_await, span, "async fn is unstable");
}
if fn_decl.c_variadic {
gate_feature_post!(&self, c_variadic, span,
"C-varaidic functions are unstable");
}
// Stability of const fn methods are covered in
// `visit_trait_item` and `visit_impl_item` below; this is
// because default methods don't pass through this point.
@ -1929,6 +1937,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
if block.is_none() {
self.check_abi(sig.header.abi, ti.span);
}
if sig.decl.c_variadic {
gate_feature_post!(&self, c_variadic, ti.span,
"C-varaidic functions are unstable");
}
if sig.header.constness.node == ast::Constness::Const {
gate_feature_post!(&self, const_fn, ti.span, "const fn is unstable");
}

View File

@ -1,4 +1,5 @@
#![crate_type="lib"]
#![feature(c_variadic)]
pub unsafe extern "C" fn use_vararg_lifetime(
x: usize,

View File

@ -0,0 +1,4 @@
#![crate_type="lib"]
pub unsafe extern "C" fn test(_: i32, ap: ...) { }
//~^ C-varaidic functions are unstable

View File

@ -0,0 +1,11 @@
error[E0658]: C-varaidic functions are unstable (see issue #44930)
--> $DIR/feature-gate-c_variadic.rs:3:1
|
LL | pub unsafe extern "C" fn test(_: i32, ap: ...) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(c_variadic)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.