The release of the programming language Rust 1.97 has been published, originally developed by Mozilla, now furthered under the auspices of the independent nonprofit organization Rust Foundation. The language is focused on safe memory management and provides tools to achieve high parallelism in task execution while avoiding the use of a garbage collector and runtime (the runtime is limited to basic initialization and support of the standard library).
Memory handling methods in Rust aim to eliminate 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, etc. To facilitate library distribution, ensure compilation, and manage project dependencies, the package manager Cargo is being developed. A repository, crates.io, is supported for hosting libraries.
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:
- A new name mangling scheme for functions, global variables, and data structures in generated object and executable files is enabled by default (-Csymbol-mangling-version=v0). Names are mangled to prevent conflicts during linking of different programs by attaching specific context, such as the module path and crate package name.
The previously used name decoration scheme based on the Itanium ABI had drawbacks, such as replacing generic parameters with unreadable hashes and having parts of the compiler that did not utilize the Itanium ABI, necessitating the use of Rust-specific name decoders. In Rust 1.97, a name decoration scheme developed specifically for Rust is employed by default, free from the noted shortcomings. The old scheme is planned to be removed in one of the upcoming releases.
- The cargo package manager has built-in functionality to manage responses to warnings generated by the compiler during builds. An environment variable CARGO_BUILD_WARNINGS has been added, which can take three values: warn (default) — displays warnings on the screen; allow — hides warning output; deny — treats warnings as errors, halting the build.
In previous versions, to complete a build after a warning was output, it was necessary to specify '-Dwarnings' in RUSTFLAGS for the compiler. However, when RUSTFLAGS was changed, the cargo package manager considered the build new, ignoring cache data and rebuilding the entire project from scratch. Moving the setting to the cargo side eliminated the cache reset and the need for a full recompilation when changing the warning handling mode, as well as simplifying the inclusion of treating warnings as errors in continuous integration systems.
- Message display from the linker is enabled by default during builds. Messages are output as warnings through a special lint rule 'linker_messages', which is not part of the standard 'warnings' group. At the same time, rustc filters out messages that are typical false positives or normal behavior, leaving warnings that may indicate problems, such as warnings about deprecated options and undesirable settings. Previously, information from the linker was only shown if there was a failure; otherwise, all messages were hidden. To revert to the old behavior, you can add the following to Cargo.toml: [lints.rust] linker_messages = 'allow'
- A new batch of APIs has been promoted to stable, including stabilized methods and trait implementations:
- Default for RepeatN
- Copy for ffi::FromBytesUntilNulError
- Send for std::fs::File for UEFI
- ::isolate_highest_one
- ::isolate_lowest_one
- ::highest_one
- ::lowest_one
- ::bit_width
- NonZero::isolate_highest_one
- NonZero::isolate_lowest_one
- NonZero::highest_one
- NonZero::lowest_one
- NonZero::bit_width
- The 'const' qualifier is applied in the char::is_control method.
Additionally, recent announced projects and events related to Rust can be noted:
- The zinnia project develops a modular Unix-like kernel, written in Rust and distributed under the GPLv2 license. The kernel supports POSIX interfaces and some extensions from BSD and Linux, such as epoll and timerfd. Drivers for DRM (Direct Rendering Manager) and evdev are available for rendering and input organization. The implemented functionality is sufficient to run the Xfce desktop environment under the X server and the Weston compositor based on Wayland. Booting is supported in both QEMU emulator and on actual hardware, such as the ThinkPad E14 G7 laptop. server The release of the iroh 1.0 communication library has been introduced, allowing network connections between applications on different hosts using cryptographic keys instead of
- IP addresses (the key to connect to is specified, and iroh finds the associated host and establishes an encrypted connection using the QUIC protocol). Direct P2P connections are established whenever possible, but if not, it falls back to using relays, which are also employed for host discovery by keys. You can run your own relay or connect to public relays supported by the community. Among the advanced features: support for Multipath QUIC for delivering packets simultaneously over multiple routes, operation behind NAT, static configuration mode for connecting to local devices without internet access, the ability to compile to WASM intermediate code for execution inside the browser, and support for building custom transports, for example, for connections via Bluetooth, WiFi Aware, or LoRa. The code is written in Rust and distributed under the Apache-2.0 and MIT licenses. Bindings for Python, Node.js, Kotlin, and Swift are available.
The code is written in Rust and is distributed under the Apache-2.0 and MIT licenses. Bindings for Python, Node.js, Kotlin, and Swift are available.
- The author of the server-side JavaScript platform Bun has published an article discussing the project's rewrite from Zig to Rust using the AI model Claude Fable. It is noted that Bun version 1.3.14 will be the last release in Zig, and the next version, Bun 1.4.0, will be in Rust. Tests indicate that the Rust version consumes significantly less memory and is 2-5% faster than the Zig version. The executable file size in the Rust version has decreased by 20%.
Source: opennet.ru
