Skip to content

Commit d7ccbf8

Browse files
committed
Stabilize c_variadic
1 parent 827651f commit d7ccbf8

94 files changed

Lines changed: 331 additions & 462 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
1+
use rustc_ast::visit::{self, AssocCtxt, FnKind, Visitor};
22
use rustc_ast::{self as ast, AttrVec, GenericBound, NodeId, PatKind, attr, token};
33
use rustc_attr_parsing::AttributeParser;
44
use rustc_errors::msg;
@@ -388,7 +388,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
388388
visit::walk_poly_trait_ref(self, t);
389389
}
390390

391-
fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: &AttrVec, span: Span, _: NodeId) {
391+
fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: &AttrVec, _: Span, _: NodeId) {
392392
if let Some(_header) = fn_kind.header() {
393393
// Stability of const fn methods are covered in `visit_assoc_item` below.
394394
}
@@ -397,10 +397,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
397397
self.check_late_bound_lifetime_defs(generic_params);
398398
}
399399

400-
if fn_kind.ctxt() != Some(FnCtxt::Foreign) && fn_kind.decl().c_variadic() {
401-
gate!(self, c_variadic, span, "C-variadic functions are unstable");
402-
}
403-
404400
visit::walk_fn(self, fn_kind)
405401
}
406402

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ declare_features! (
9494
(accepted, c_str_literals, "1.77.0", Some(105723)),
9595
/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries and treat `extern "C" fn` as nounwind.
9696
(accepted, c_unwind, "1.81.0", Some(74990)),
97+
/// Allows using C-variadics.
98+
(accepted, c_variadic, "CURRENT_RUSTC_VERSION", Some(44930)),
9799
/// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`.
98100
(accepted, cfg_attr_multi, "1.33.0", Some(54881)),
99101
/// Allows the use of `#[cfg(<true/false>)]`.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ declare_features! (
391391
(unstable, avx10_target_feature, "1.88.0", Some(138843)),
392392
/// Target features on bpf.
393393
(unstable, bpf_target_feature, "1.54.0", Some(150247)),
394-
/// Allows using C-variadics.
395-
(unstable, c_variadic, "1.34.0", Some(44930)),
396394
/// Allows defining c-variadic naked functions with any extern ABI that is allowed
397395
/// on c-variadic foreign functions.
398396
(unstable, c_variadic_naked_functions, "1.93.0", Some(148767)),

library/core/src/ffi/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,10 @@ use crate::fmt;
2323
#[stable(feature = "c_str_module", since = "1.88.0")]
2424
pub mod c_str;
2525

26-
#[unstable(
27-
feature = "c_variadic",
28-
issue = "44930",
29-
reason = "the `c_variadic` feature has not been properly tested on all supported platforms"
30-
)]
26+
mod va_list;
27+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
3128
pub use self::va_list::{VaArgSafe, VaList};
3229

33-
#[unstable(
34-
feature = "c_variadic",
35-
issue = "44930",
36-
reason = "the `c_variadic` feature has not been properly tested on all supported platforms"
37-
)]
38-
pub mod va_list;
39-
4030
mod primitives;
4131
#[stable(feature = "core_ffi_c", since = "1.64.0")]
4232
pub use self::primitives::{

library/core/src/ffi/va_list.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ crate::cfg_select! {
189189
/// is automatically initialized (equivalent to calling `va_start` in C).
190190
///
191191
/// ```
192-
/// #![feature(c_variadic)]
193-
///
194192
/// use std::ffi::VaList;
195193
///
196194
/// /// # Safety
@@ -224,11 +222,13 @@ crate::cfg_select! {
224222
/// terms of layout and ABI.
225223
#[repr(transparent)]
226224
#[lang = "va_list"]
225+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
227226
pub struct VaList<'a> {
228227
inner: VaListInner,
229228
_marker: PhantomCovariantLifetime<'a>,
230229
}
231230

231+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
232232
impl fmt::Debug for VaList<'_> {
233233
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
234234
// No need to include `_marker` in debug output.
@@ -243,6 +243,7 @@ impl VaList<'_> {
243243
}
244244
}
245245

246+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
246247
#[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")]
247248
impl<'f> const Clone for VaList<'f> {
248249
#[inline] // Avoid codegen when not used to help backends that don't support VaList.
@@ -255,6 +256,7 @@ impl<'f> const Clone for VaList<'f> {
255256
}
256257
}
257258

259+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
258260
#[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")]
259261
impl<'f> const Drop for VaList<'f> {
260262
#[inline] // Avoid codegen when not used to help backends that don't support VaList.
@@ -264,6 +266,7 @@ impl<'f> const Drop for VaList<'f> {
264266
}
265267
}
266268

269+
#[unstable(feature = "c_variadic_internals", issue = "none")]
267270
mod sealed {
268271
pub trait Sealed {}
269272

@@ -318,6 +321,7 @@ mod sealed {
318321
// types with an alignment larger than 8, or with a non-scalar layout. Inline assembly can be used
319322
// to accept unsupported types in the meantime.
320323
#[lang = "va_arg_safe"]
324+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
321325
pub unsafe trait VaArgSafe: sealed::Sealed {}
322326

323327
crate::cfg_select! {
@@ -326,7 +330,9 @@ crate::cfg_select! {
326330
//
327331
// - i8 is implicitly promoted to c_int in C, and cannot implement `VaArgSafe`.
328332
// - u8 is implicitly promoted to c_uint in C, and cannot implement `VaArgSafe`.
333+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
329334
unsafe impl VaArgSafe for i16 {}
335+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
330336
unsafe impl VaArgSafe for u16 {}
331337
}
332338
_ => {
@@ -340,6 +346,7 @@ crate::cfg_select! {
340346
crate::cfg_select! {
341347
target_arch = "avr" => {
342348
// c_double is f32 on this target.
349+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
343350
unsafe impl VaArgSafe for f32 {}
344351
}
345352
_ => {
@@ -349,17 +356,26 @@ crate::cfg_select! {
349356
}
350357
}
351358

359+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
352360
unsafe impl VaArgSafe for i32 {}
361+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
353362
unsafe impl VaArgSafe for i64 {}
363+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
354364
unsafe impl VaArgSafe for isize {}
355365

366+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
356367
unsafe impl VaArgSafe for u32 {}
368+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
357369
unsafe impl VaArgSafe for u64 {}
370+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
358371
unsafe impl VaArgSafe for usize {}
359372

373+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
360374
unsafe impl VaArgSafe for f64 {}
361375

376+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
362377
unsafe impl<T> VaArgSafe for *mut T {}
378+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
363379
unsafe impl<T> VaArgSafe for *const T {}
364380

365381
// Check that relevant `core::ffi` types implement `VaArgSafe`.
@@ -390,6 +406,7 @@ impl<'f> VaList<'f> {
390406
/// Calling this function with an incompatible type, an invalid value, or when there
391407
/// are no more variable arguments, is unsound.
392408
#[inline] // Avoid codegen when not used to help backends that don't support VaList.
409+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
393410
#[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")]
394411
pub const unsafe fn next_arg<T: VaArgSafe>(&mut self) -> T {
395412
// SAFETY: the caller must uphold the safety contract for `va_arg`.

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
issue = "none"
5454
)]
5555

56-
use crate::ffi::va_list::{VaArgSafe, VaList};
56+
use crate::ffi::{VaArgSafe, VaList};
5757
use crate::marker::{ConstParamTy, DiscriminantKind, PointeeSized, Tuple};
5858
use crate::{mem, ptr};
5959

library/std/src/ffi/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,7 @@ pub mod c_str;
166166

167167
#[stable(feature = "core_c_void", since = "1.30.0")]
168168
pub use core::ffi::c_void;
169-
#[unstable(
170-
feature = "c_variadic",
171-
reason = "the `c_variadic` feature has not been properly tested on \
172-
all supported platforms",
173-
issue = "44930"
174-
)]
169+
#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")]
175170
pub use core::ffi::{VaArgSafe, VaList};
176171
#[stable(feature = "core_ffi_c", since = "1.64.0")]
177172
pub use core::ffi::{

library/std/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@
403403
// Only for re-exporting:
404404
// tidy-alphabetical-start
405405
#![feature(async_iterator)]
406-
#![feature(c_variadic)]
407406
#![feature(cfg_accessible)]
408407
#![feature(cfg_eval)]
409408
#![feature(concat_bytes)]

src/doc/unstable-book/src/language-features/c-variadic.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/tools/miri/tests/fail/c-variadic-mismatch-count.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(c_variadic)]
2-
31
unsafe extern "C" fn helper(_: i32, _: ...) {}
42

53
fn main() {

0 commit comments

Comments
 (0)