Rust 1.99.0 stabilizes C-variadic functions written in Rust and raw-pointer layout queries
The release lets Rust code define extern C variadic functions and updates Box::leak guidance ahead of custom allocators.
Rust 1.99.0 is now available. The headline change is that Rust code can define C-ABI variadic functions, using the C and C-unwind ABIs. Until now Rust could call variadic functions such as printf from C libraries, but could not implement one itself.
The release also settles the safety rules for reading size and alignment through raw pointers, including to unsized types, by stabilizing Layout::for_value_raw, mem::size_of_val_raw and mem::align_of_val_raw. Several other APIs become stable, among them Box::into_non_null, Vec::into_parts and std::fs::set_times.
The documentation for Box::leak now advises against patterns that later free the leaked memory, because they interact badly with compiler optimizations and with the coming custom allocator work. Box::into_raw or Box::into_non_null are the suggested alternatives.
Developers on rustup can update with rustup update stable. Teams that write FFI layers or low-level allocation code should review any code that reclaims memory after Box::leak.
Sources
- Announcing Rust 1.99.0official