Rust programming language 1.60 release

The general-purpose programming language Rust 1.60, 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:

  • The rustc compiler has stabilized the LLVM-based system for generating coverage data used to evaluate code coverage in testing. To include coverage data when building, you must use the "-Instrument-coverage" flag, for example, by starting the build with the command "RUSTFLAGS="-C instrument-coverage "cargo build". After running the executable file built in this way, the default.profraw file will be saved in the current directory, for processing which you can use the llvm-profdata utility from the llvm-tools-preview component. The output processed by the llvm-profdata utility can then be passed to the llvm-cov program to generate an annotated code coverage report. Information about binding to source code is taken from the executable file under investigation, which includes the necessary data on the connection of coverage counters with the code. 1| 1|fn main() { 2| 1| println!("Hello, world!"); 3| 1|}
  • Support for the "-timings" flag has been stabilized in the cargo package manager, which includes the formation of a detailed report on the progress of the build and the time it took to complete each step. The report can be useful for optimizing the performance of the assembly process.
  • The cargo package manager offers a new syntax for a conditional compilation mechanism and optional dependency selection, configured in the Cargo.toml file by enumerating a list of named features in the [features] section and activated by including features at package build time using the "-features" flag. The new version adds support for dependencies in separate namespaces and weak dependencies.

    In the first case, it is possible to use elements with the β€œdep:” prefix inside the β€œ[features]” section to explicitly bind to an optional dependency without implicitly representing this dependency as a feature. In the second case, support for marking with the sign "?" ("package-name?/feature-name") of optional dependencies, which should only be included if some other property includes the given optional dependency. For example, in the example below, including the serde property will enable the "serde" dependency, as well as the "serde" property for the "rgb" dependency, but only if the "rgb" dependency is enabled somewhere else: [dependencies] serde = { version = " 1.0.133", optional = true } rgb = { version = "0.8.25", optional = true } [features] serde = ["dep:serde", "rgb?/serde"]

  • Support for incremental compilation, which was disabled in the previous release, has been returned. The bug in the compiler that caused the feature to be disabled has been fixed.
  • Fixed some issues with providing Instant timers with a monotonic timing guarantee that takes into account the time the system has been asleep. Previously, when possible, the timer used the OS API, which did not take into account problematic situations that break the monotony of time, such as hardware problems, virtualization, or errors in the operating system.
  • A new portion of the API has been moved to the category of stable, including the methods and implementations of traits have been stabilized:
    • Arc::new_cyclic
    • Rc::new_cyclic
    • slice::EscapeAscii
    • <[u8]>::escape_ascii
    • u8::escape_ascii
    • Vec::spare_capacity_mut
    • MaybeUninit::assume_init_drop
    • MaybeUninit::assume_init_read
    • i8::abs_diff
    • i16::abs_diff
    • i32::abs_diff
    • i64::abs_diff
    • i128::abs_diff
    • isize::abs_diff
    • u8::abs_diff
    • u16::abs_diff
    • u32::abs_diff
    • u64::abs_diff
    • u128::abs_diff
    • usize::abs_diff
    • Display for io::ErrorKind
    • From for ExitCode
    • Not for! (type "never")
    • _Op_Assign<$t>
    • arch::is_aarch64_feature_detected!
  • Implemented third level support for mips64-openwrt-linux-musl* and armv7-unknown-linux-uclibceabi (softfloat) platforms. The third level implies basic support, but without automated testing, publishing official builds and checking the ability to build the code.
  • The compiler has been switched to use LLVM 14.

Additionally, you can note:

  • Added support for bootstrapping the rustc compiler using the rustc_codegen_gcc backend, which allows using the libgccjit library from the GCC project as a code generator in rustc, which allows rustc to support architectures and optimizations available in GCC. Compiler spin-up refers to the ability of rustc to use a GCC-based code generator to build the rustc compiler itself. On the practical side, this feature allows you to build rust-programs for architectures not previously supported in rustc.
  • The release of the uutils coreutils 0.0.13 toolkit is available, within which an analogue of the GNU Coreutils package, rewritten in the Rust language, is being developed. Coreutils comes with over a hundred utilities, including sort, cat, chmod, chown, chroot, cp, date, dd, echo, hostname, id, ln, and ls. The goal of the project is to create a cross-platform alternative implementation of Coreutils, capable of running on Windows, Redox and Fuchsia platforms, as well as distributing under the MIT permissive license instead of the GPL copyleft license.

    The implementation of many utilities has been improved in the new version, including significantly improved compatibility of the cp, dd, df, split and tr utilities with their counterparts from the GNU project. Provided online documentation. The clap parser is used to parse command line arguments, which improved the output for the "--help" flag and added support for long command abbreviations (for example, you can specify "ls -col" instead of "ls -color").

Source: opennet.ru

Add a comment