Rust 1.99.0 Released: C-ABI Variadics and Layout Info from Raw Pointers
Translated by a model; the original is in Russian.
The Rust team has announced a new release of the language — 1.99.0. You can upgrade with rustup update stable; if you don't have rustup yet, it's available on the project's website. The team also invites developers to help test future releases via the beta and nightly channels.
C-ABI variadic functions
The flagship addition is stabilized support for defining variadic functions with the "C" and "C-unwind" ABIs. Such functions accept an arbitrary number of arguments through the ... list. Rust could already call externally defined variadic functions (such as libc::printf); now they can be written in Rust itself.
The type of ... is VaList, which is ABI-compatible with the C va_list type across targets. Which types can be read from a VaList is governed by the VaArgSafe trait. The release also stabilizes naked variadic functions with non-"C" ABIs, which must be written via inline assembly.
Layout information from raw pointers
The release settles the safety requirements for retrieving size and alignment from raw pointers — both for Sized types (already possible on stable) and for non-Sized ones. This is done by stabilizing Layout::for_value_raw, mem::size_of_val_raw and mem::align_of_val_raw.
A caution around Box::leak
There are no language semantics changes in 1.99, but the documentation for Box::leak has been updated to recommend against patterns that later deallocate the leaked memory. Such code was found to interact poorly with current and potential future compiler optimizations, and is especially problematic ahead of the upcoming stabilization of custom allocators. Box::into_non_null should be preferred instead; the same guidance applies to other leak functions in the standard library.
Stabilized APIs
Among other things, the stable channel gains IntoIterator implementations for Box<[T; N]> and references to it, VecDeque::retain_back, core::ffi::VaList, the Box::into_non_null/Box::from_non_null and Vec::into_parts/Vec::from_parts pairs, String::from_utf8_lossy_owned, and std::fs::set_times along with set_times_nofollow.
The full list of changes across Rust, Cargo and Clippy is available in the release notes. Many community members contributed to version 1.99.0.
Source: Lobsters
Comments
Sign in, to comment.