The release of the general-purpose programming language Rust 1.84 has been published. Originally developed by Mozilla, it is now maintained by the independent non-profit organization Rust Foundation. The language focuses on safe memory usage and provides means for achieving high concurrency of tasks, all while avoiding the use of garbage collection and runtime (runtime is limited to basic initialization and the support of 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:
- In the Cargo package manager, a mechanism for handling dependencies has been stabilized that selects versions of dependent components considering compatibility with the Rust compiler versions declared as the minimally supported versions by the project (MSRV, Minimum Supported Rust Version). This new feature allows maintainers to avoid manually selecting old versions of each dependency in projects that retain compatibility with older Rust tool versions. The new dependency resolution mode will be enabled by default in the Rust 1.85 release, but is currently available as an option by specifying ‘incompatible-rust-versions = "fallback"‘ in the ‘[resolver]’ section of the ‘.cargo/config.toml’ file.
- Work has begun on translating the compiler to a new trait solver designed for checking the applicability boundaries of traits, normalizing types, and assessing type compatibility. In version 1.84, the new solver is utilized to verify the consistency of trait implementations, i.e., to evaluate the existence of no more than one trait for the considered type, taking into account code from other crate packages. This check has resolved issues in the old type handler implementation that could potentially lead to conflicts due to overlapping different trait implementations.
- A new API "Strict Provenance" has been proposed, which can be used to cast a pointer to an integer and back, taking into account the metadata attached to the pointer that contains information about its origin and usage context (in addition to the address, a "provenance" value is attached to the pointer with information about the relationship to other pointers, allowing to determine where and when the pointer can reference memory). Casting a pointer to an integer and back results in undefined behavior due to the difficulty of tracking the provenance of the resulting pointer. The new API allows low-level operations with pointers, such as storing additional information in the lower bits of the pointer, without casting the pointer to an integer.
- A new batch of APIs has been promoted to stable, including stabilized methods and trait implementations:
- Ipv6Addr::is_unique_local
- Ipv6Addr::is_unicast_link_local
- core::ptr::with_exposed_provenance
- core::ptr::with_exposed_provenance_mut
- ::addr
- ::expose_provenance
- ::with_addr
- ::map_addr
- ::isqrt
- ::checked_isqrt
- ::isqrt
- NonZero::isqrt
- core::ptr::without_provenance
- core::ptr::without_provenance_mut
- core::ptr::dangling
- core::ptr::dangling_mut
- Pin::as_deref_mut
- The ‘const’ attribute has been applied in the functions:
- AtomicBool::from_ptr
- AtomicPtr::from_ptr
- AtomicU8::from_ptr
- AtomicU16::from_ptr
- AtomicU32::from_ptr
- AtomicU64::from_ptr
- AtomicUsize::from_ptr
- AtomicI8::from_ptr
- AtomicI16::from_ptr
- AtomicI32::from_ptr
- AtomicI64::from_ptr
- AtomicIsize::from_ptr
- ::is_null
- ::as_ref
- ::as_mut
- Pin::new
- Pin::new_unchecked
- Pin::get_ref
- Pin::into_ref
- Pin::get_mut
- Pin::get_unchecked_mut
- Pin::static_ref
- Pin::static_mut
- Stabilized support for inline assembly inserts for the s390x and Arm64EC architectures.
- For the target platform WebAssembly, support for multivalue, reference-types, and tail-call functionality has been stabilized.
- Implemented the second level of support for the wasm32v1-none platform. The second level of support implies a build guarantee.
Additionally, several projects related to Rust can be noted:
- The release of the Tock 2.2 operating system, written in Rust and designed for use in microcontrollers, has been announced. The system allows for the simultaneous execution of several untrusted applications on embedded devices with limited RAM, such as sensors, TPMs (Trusted Platform Modules), authentication keys, and wearable devices. It supports platforms with microcontrollers based on ARM Cortex-M and RISC-V architectures. A key feature of Tock is the isolation of application, kernel, and driver layers, as well as the isolation of each application and driver separately. This isolation utilizes both Rust's capabilities and memory protection level separation.
- The VEKOS (Verified Experimental Kernel OS) project develops a kernel operating system in Rust that provides verification of executed components. For every operation with the file system, process creation, and memory allocation, a cryptographic confirmation is generated, allowing the operation to be verified during execution (this implementation is comparable to using blockchain for verifying actions within the operating system). In the VKFS file system, a Merkle Tree structure is used to ensure integrity and protection against retroactive tampering, where each branch verifies all lower-level branches and nodes through tree hashing. Memory allocation is performed in COW (Copy-On-Write) mode.
- A group of researchers from Microsoft and Inria is developing a subset of the C language — Mini-C, designed for the automatic translation of C programs into Rust representations. Unlike the c2rust compiler, the new project allows the generation of Rust code without using unsafe, but is primarily aimed at transforming C projects that have formal reliability proofs. It is expected to be simpler to first translate a C project into a Mini-C representation, which disallows arithmetic operations with pointers, than to rewrite unsafe blocks after directly compiling from C to Rust.
The implementation of the compiler is based on the KaRaMeL toolkit. Mini-C was developed and tested within the framework of a project to rewrite the HACL* cryptographic library in Rust, for which formal proof of reliability has been provided. This proof was used to demonstrate the ability to generate safe Rust code from Mini-C.
- Daniel Stenberg, the author of the curl utility, announced the cessation of development and support for the Curl alternative HTTP backend, written in Rust using the Hyper library. The reason given is a lack of interest from developers and users.
- The beta release of Fish shell 4.0 has been announced, rewritten in Rust. It is noted that after two years of development, the Fish codebase was fully transitioned from C++ to Rust. The shift to Rust allowed for solving multithreading issues, acquiring modern tooling that detects errors at compile time, improving memory safety, and making the project more attractive to new developers.
- The Tor project has released Arti 1.3.2, an alternative implementation of the Tor client in Rust. Arti provides an embeddable library that various applications can use. In creating Arti, past experience with Tor development was taken into account to avoid known architectural issues, making the project more modular and efficient. The 1.x branch is marked as suitable for regular users and provides the same level of privacy, usability, and stability as the main implementation in C. The new version continues RPC development, prepares relay support, and adds protection against DoS attacks on Onion services.
- The Bevy 0.15 game engine has been released, written in Rust. The engine employs a data-driven model for defining game logic, built on top of a set of ready-made Bevy ECS (Entity Component System) components that can be executed in parallel. It supports 2D and 3D rendering, skeletal animation, a rendering graph definition, a scene building system, a framework for creating user interfaces, and making changes to scenes and resources without the need for a restart.
- The Helix 25.01 console text editor has been released, developed in Rust, expanding on the ideas laid out in vim and neovim. It supports integration with LSP servers and Tree-sitter, simultaneous selection of multiple blocks, and the use of multiple cursors during editing, along with theming and the Debug Adapter Protocol (DAP).
- The Servo browser engine, written in Rust, has added support for dark mode. The size of the ServoShell browser has been reduced by 20%. Support for web specifications has been enhanced to allow logging in and reading messages on Discord (sending messages is still not possible).
- Mozilla has introduced the Uniffi for React Native toolkit for creating modules for React Native in Rust.
- Performance testing of image encoders in PNG format has been conducted. Rust decoders (png, zune-png, wuffs) proved to be faster than C decoders (libpng, spng, stb_image). For instance, the png crate (image-rs) outperformed libpng by 1.8 times on x86 systems and by 1.5 times on ARM systems. image-rs: 375.401 MP/s (average) 318.632 MP/s (geomean) zune-png: 376.649 MP/s (average) 302.529 MP/s (geomean) wuffs: 376.205 MP/s (average) 287.181 MP/s (geomean) libpng: 208.906 MP/s (average) 173.034 MP/s (geomean) spng: 299.515 MP/s (average) 235.495 MP/s (geomean) stb_image: 234.353 MP/s (average) 171.505 MP/s (geomean)
Source: opennet.ru
