Skip to content

Commit fad2a35

Browse files
Rollup merge of rust-lang#154133 - bjorn3:va_list_drop_defer_codegen, r=nnethercote
Defer codegen for the VaList Drop impl to actual uses This allows compiling libcore with codegen backends that don't actually implement VaList like cg_clif.
2 parents f02eaf6 + 366cf88 commit fad2a35

2 files changed

Lines changed: 3 additions & 27 deletions

File tree

compiler/rustc_codegen_cranelift/patches/0028-stdlib-Ensure-va_end-doesn-t-get-emitted-unless-VaList-is-a.patch

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

library/core/src/ffi/va_list.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl VaList<'_> {
244244

245245
#[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")]
246246
impl<'f> const Clone for VaList<'f> {
247-
#[inline]
247+
#[inline] // Avoid codegen when not used to help backends that don't support VaList.
248248
fn clone(&self) -> Self {
249249
// We only implement Clone and not Copy because some future target might not be able to
250250
// implement Copy (e.g. because it allocates). For the same reason we use an intrinsic
@@ -256,6 +256,7 @@ impl<'f> const Clone for VaList<'f> {
256256

257257
#[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")]
258258
impl<'f> const Drop for VaList<'f> {
259+
#[inline] // Avoid codegen when not used to help backends that don't support VaList.
259260
fn drop(&mut self) {
260261
// SAFETY: this variable argument list is being dropped, so won't be read from again.
261262
unsafe { va_end(self) }
@@ -326,7 +327,7 @@ impl<'f> VaList<'f> {
326327
///
327328
/// Calling this function with an incompatible type, an invalid value, or when there
328329
/// are no more variable arguments, is unsound.
329-
#[inline]
330+
#[inline] // Avoid codegen when not used to help backends that don't support VaList.
330331
#[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")]
331332
pub const unsafe fn arg<T: VaArgSafe>(&mut self) -> T {
332333
// SAFETY: the caller must uphold the safety contract for `va_arg`.

0 commit comments

Comments
 (0)