The release of the Rust programming language 1.89 has been published, originally developed by Mozilla, and now maintained by the independent non-profit organization Rust Foundation. The language focuses on safe memory handling and provides tools to achieve high parallelism in task execution, all while avoiding the use of a garbage collector and minimal runtime (runtime involves basic initialization and supporting the standard library).
The memory management methods in Rust relieve developers from errors when manipulating pointers and protect against issues arising from low-level memory operations, such as accessing memory after it has been freed, dereferencing null pointers, buffer overflows, and so on. For distributing libraries, ensuring builds, and managing project dependencies, the package manager Cargo is being developed. A repository at crates.io supports library hosting.
Safe memory handling in Rust is ensured at compile time through reference checking, ownership tracking of objects, lifetime consideration (scope) of objects, and assessment of memory access correctness during code execution. Rust also provides means to protect against integer overflows, mandates the initialization of variable values before use, improved error handling in the standard library, employs the concept of immutability for references and variables by default, and offers strong static typing to minimize logical errors.
Key innovations:
- The use of the '_' character as an argument for generic parameters marked 'const' has been enabled to derive values for these parameters based on the surrounding context. pub fn all_false() -> [bool; LEN] { [false; _] }
- A new lint warning 'mismatched_lifetime_syntaxes' has been added to address the issue of non-obvious lifetime definitions in function signatures when using the 'lifetime elision' mechanism (which automatically infers the lifetimes of references, allowing for the omission of explicit lifetime annotations). The warning checks that the function's input and output parameters belong to the same group of types. These groups are formed based on whether explicit lifetime annotations are supported and whether the compiler can automatically infer lifetimes (for instance, in types '&’a T' and 'ContainsLifetime', lifetimes can be explicitly stated, but the compiler cannot automatically infer them, whereas in types '&T', '&’_ T', and 'ContainsLifetime' both explicit annotations and automatic inference are allowed).
- In the 'target_feature' attribute for x86 systems, the ability to check support for extended instruction sets sha512, sm3, sm4, kl, and widekl, as well as specific avx512 functions, has been implemented. #[target_feature(enable = 'avx512bw')] pub fn cool_simd_code(/* .. */) -> /* … */ { /* … */ }
- Doctest (tests embedded in documentation) can now be executed not only for the current target platform but also for other platforms specified when running the 'cargo' package manager ('cargo test --doc --target other_target').
- For 'extern 'C'' functions when building for the target platform 'wasm32-unknown-unknown', the standard C ABI for WebAssembly has been implemented.
- With some qualifications regarding type compatibility, the use of types i128 and u128 is allowed in external C functions (extern "C"), for which a lint warning "improper_ctypes_definitions" was previously shown.
- A new batch of APIs has been promoted to stable, including stabilized methods and trait implementations:
- Many compiler intrinsic functions for x86 processors, including functions for AVX512, SHA512, SM3, and SM4.
- NonZero
- File::lock
- File::lock_shared
- File::try_lock
- File::try_lock_shared
- File::unlock
- NonNull::from_ref
- NonNull::from_mut
- NonNull::without_provenance
- NonNull::with_exposed_provenance
- NonNull::expose_provenance
- OsString::leak
- PathBuf::leak
- Result::flatten
- std::os::linux::net::TcpStreamExt::quickack
- std::os::linux::net::TcpStreamExt::set_quickack
The ‘const’ attribute has been applied in the functions:
- ::as_mut_slice
- ::eq_ignore_ascii_case
- str::eq_ignore_ascii_case
- The process of transitioning the target platform "x86_64-apple-darwin" from first-level support to second-level has begun (Apple plans to discontinue support for the x86_64 architecture). First-level support implies producing binary builds, conducting thorough testing, and providing the highest guarantee of platform support — every change in the compiler is verified by running the full test suite. Second-level support implies a guarantee of builds, but no guarantees during the test suite.
- A third level of support has been implemented for the platforms "loongarch32-unknown-none" and "loongarch32-unknown-none-softfloat". The third level implies basic support, but without automated testing, publication of official builds, and verification of code build capability.
Additionally, it is worth noting related events and projects concerning Rust:
- A report on the status of Rust packages in Debian has been published. It is noted that in the Debian Unstable (Sid) branch, about 8% of src packages in the main repository have build dependencies related to at least one package "librust-*". In Debian 12, similar packages accounted for 4.5%. It is also noted that over 3,000 packages include Rust code that has been moved to librust-..-dev packages, and 150 src packages provide compiled executables or Rust libraries.
Of interest to Debian packages mentioned are sudo-rs, ntpd-rs, uutils, Sequoia, rpgp, hickory (DNS), Rustls, rav1d, and fish. Optional Rust support is implemented in APT, QEMU (virtiofsd), the Linux kernel, and Mesa, and is also expected in LibreOffice. Tooling debcargo has been implemented to convert crate packages into Debian src packages.
- The tmux-rs project has been introduced, developing a clone of the terminal multiplexer tmux (console window manager), rewritten from C to Rust.
- The driver developer Tyr from Collabora published an article about kernel-level devices for GPU drivers and the principles of developing such drivers in Rust.
- A universal application was demonstrated in Rust, capable of running on both CPU and various GPU platforms: CUDA for NVIDIA, SPIR-V for Vulkan-compatible GPUs, Metal for Apple, DirectX 12 for Windows, and WebGPU for browsers.
Source: opennet.ru
