Rust programming language 1.66 release

The general-purpose programming language Rust 1.66, founded by the Mozilla project but now developed under the auspices of the independent non-profit organization Rust Foundation, has been released. The language focuses on memory safety and provides the means to achieve high job parallelism while avoiding the use of a garbage collector and runtime (runtime is reduced to basic initialization and maintenance of the standard library).

Rust's memory handling methods save the developer from errors when manipulating pointers and protect against problems that arise due to low-level memory handling, such as accessing a memory area after it has been freed, dereferencing null pointers, buffer overruns, etc. To distribute libraries, provide builds and manage dependencies, the project develops the Cargo package manager. The crates.io repository is supported for hosting libraries.

Memory safety is provided in Rust at compile time through reference checking, keeping track of object ownership, keeping track of object lifetimes (scopes), and assessing the correctness of memory access during code execution. Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better in the standard library, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors.

Main innovations:

  • In enumerations with integer representations (the "#[repr(Int)]" attribute), explicit indication of the discriminant (variant number in the enumeration) is allowed, even if the enumeration contains fields. #[repr(u8)] enum Foo { A(u8), # discriminant 0 B(i8), # discriminant 1 C(bool) = 42, # discriminant 42 }
  • Added function core::hint::black_box which simply returns the received value. Since the compiler thinks that this function is doing something, the black_box function can be used to disable compiler optimizations for loops when performing code performance testing or when examining generated machine code (so that the compiler does not consider the code unused and remove it). For example, in the example below, black_box(v.as_ptr()) prevents the compiler from thinking that the vector v is not being used. use std::hint::black_box; fn push_cap(v: &mut Vec) { for i in 0..4 { v.push(i); black_box(v.as_ptr()); } }
  • The "cargo" package manager offers the "remove" command, which allows you to remove dependencies from the Cargo.toml manifest from the command line.
  • A new portion of the API has been moved to the category of stable, including the methods and implementations of traits have been stabilized:
    • proc_macro::Span::source_text
    • u*::{checked_add_signed, overflowing_add_signed, saturating_add_signed, wrapping_add_signed}
    • i*::{checked_add_unsigned, overflowing_add_unsigned, saturating_add_unsigned, wrapping_add_unsigned}
    • i*::{checked_sub_unsigned, overflowing_sub_unsigned, saturating_sub_unsigned, wrapping_sub_unsigned}
    • BTreeSet::{first, last, pop_first, pop_last}
    • BTreeMap::{first_key_value, last_key_value, first_entry, last_entry, pop_first, pop_last}
    • Add AsFd implementations for stdio lock types when using WASI.
    • impl TryFrom > for Box<[T; N]>
    • core::hint::black_box
    • Duration::try_from_secs_{f32,f64}
    • Option::unzip
    • std::os::fd
  • The ranges "..X" and "..=X" are allowed in templates.
  • When building the front end of the rustc compiler and the LLVM backend, LTO (Link Time Optimization) and BOLT (Binary Optimization and Layout Tool) optimization modes are used to increase the performance of the resulting code and reduce memory consumption.
  • Implemented level 5 support for armv5te-none-eabi and thumbvXNUMXte-none-eabi platforms. The third level implies basic support, but without automated testing, publishing official builds and checking the ability to build the code.
  • Added support for linking to macOS Generic Libraries.

Additionally, we can note the inclusion in the GCC codebase of the front-end compiler of the Rust language (gccrs). The frontend is included in the GCC 13 branch, which will be released in May 2023. Starting with GCC 13, the standard GCC toolkit can be used to compile Rust programs without the need to install the rustc compiler built using LLVM developments. The Rust implementation in GCC 13 will be in beta status, not enabled by default.

Source: opennet.ru

Add a comment