about summary refs log tree commit diff
path: root/library/std/src/ffi
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-05-21 22:14:58 +0200
committerGitHub <noreply@github.com>2025-05-21 22:14:58 +0200
commitb9c6b337cec34c71369d3d0df6f91f2032383f20 (patch)
tree1776f4808afde99841cd73ab342d8d6838f1217b /library/std/src/ffi
parentb5edec2811221a3939cac034516e8cd7c24b8271 (diff)
parentd8a22a281cc20dc58f1da62be02048622392da05 (diff)
downloadrust-b9c6b337cec34c71369d3d0df6f91f2032383f20.tar.gz
rust-b9c6b337cec34c71369d3d0df6f91f2032383f20.zip
Rollup merge of #141341 - folkertdev:limit-VaArgSafe-impls, r=workingjubilee
limit impls of `VaArgSafe` to just types that are actually safe

tracking issue: https://github.com/rust-lang/rust/issues/44930

Retrieving 8- or 16-bit integer arguments from a `VaList` is not safe, because such types are subject to upcasting. See https://github.com/rust-lang/rust/issues/61275#issuecomment-2193942535 for more detail.

This PR also makes the instances of `VaArgSafe` visible in the documentation, and uses a private sealed trait to make sure users cannot create additional impls of `VaArgSafe`, which would almost certainly cause UB.

r? `@workingjubilee`
Diffstat (limited to 'library/std/src/ffi')
-rw-r--r--library/std/src/ffi/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs
index 56791609910..024cb71b915 100644
--- a/library/std/src/ffi/mod.rs
+++ b/library/std/src/ffi/mod.rs
@@ -172,7 +172,7 @@ pub use core::ffi::c_void;
               all supported platforms",
     issue = "44930"
 )]
-pub use core::ffi::{VaList, VaListImpl};
+pub use core::ffi::{VaArgSafe, VaList, VaListImpl};
 #[stable(feature = "core_ffi_c", since = "1.64.0")]
 pub use core::ffi::{
     c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint,