Skip to content

Commit 210c607

Browse files
committed
Add c_variadic language feature item
1 parent 58147d4 commit 210c607

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ declare_features! (
471471

472472
// #[repr(align(X))] on enums
473473
(active, repr_align_enum, "1.34.0", Some(57996), None),
474+
475+
// Allows the use of C-variadics
476+
(active, c_variadic, "1.34.0", Some(44930), None),
474477
);
475478

476479
declare_features! (
@@ -1901,6 +1904,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
19011904
if header.asyncness.is_async() {
19021905
gate_feature_post!(&self, async_await, span, "async fn is unstable");
19031906
}
1907+
1908+
if fn_decl.c_variadic {
1909+
gate_feature_post!(&self, c_variadic, span,
1910+
"C-varaidic functions are unstable");
1911+
}
19041912
// Stability of const fn methods are covered in
19051913
// `visit_trait_item` and `visit_impl_item` below; this is
19061914
// because default methods don't pass through this point.
@@ -1929,6 +1937,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
19291937
if block.is_none() {
19301938
self.check_abi(sig.header.abi, ti.span);
19311939
}
1940+
if sig.decl.c_variadic {
1941+
gate_feature_post!(&self, c_variadic, ti.span,
1942+
"C-varaidic functions are unstable");
1943+
}
19321944
if sig.header.constness.node == ast::Constness::Const {
19331945
gate_feature_post!(&self, const_fn, ti.span, "const fn is unstable");
19341946
}

src/test/ui/c-variadic/variadic-ffi-6.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![crate_type="lib"]
2+
#![feature(c_variadic)]
23

34
pub unsafe extern "C" fn use_vararg_lifetime(
45
x: usize,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![crate_type="lib"]
2+
3+
pub unsafe extern "C" fn test(_: i32, ap: ...) { }
4+
//~^ C-varaidic functions are unstable
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0658]: C-varaidic functions are unstable (see issue #44930)
2+
--> $DIR/feature-gate-c_variadic.rs:3:1
3+
|
4+
LL | pub unsafe extern "C" fn test(_: i32, ap: ...) { }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add #![feature(c_variadic)] to the crate attributes to enable
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)