Rust programming language 1.47 release

Published release 1.47 of the systems programming language Rustfounded by the Mozilla project. The language focuses on safe memory management, provides automatic memory management, and provides the means to achieve high job parallelism while avoiding the use of garbage collector ΠΈ runtime (runtime is reduced to basic initialization and maintenance of the standard library).

Rust's automatic memory management saves the developer from errors when manipulating pointers and protects against problems that arise due to low-level memory manipulation, such as accessing a memory area after it has been freed, dereferencing null pointers, buffer overruns, etc. To distribute libraries, ensure assembly and manage dependencies, the project develops a package manager Job. A repository is supported to host libraries crates.io.

All innovations:

  • Implemented support for traits for arrays arbitrary size. Previously, due to the impossibility of defining generic functions for all integer values, the standard library provided built-in trait support only for arrays up to 32 elements in size (the traits for each size were defined statically). Thanks to the creation of the functionality of const generics, it became possible to define generic functions for any array size, but they are not yet included in the stable features of the language, although they are implemented in the compiler now involved in the standard library for array traits of any size.

    For example, the following construct in Rust 1.47 will print the contents of an array, although it would have previously resulted in an error:

    fnmain() {
    let xs = [0; 34];

    println!("{:?}", xs);
    }

  • The output of shorter traces (backtrace) output in emergency situations is provided. Items that are not of interest in most situations, but clutter up the output and divert attention from the primary causes of the problem, are excluded from the trace. To return a full trace, you can use the "RUST_BACKTRACE=full" environment variable. For example, for code

    fnmain() {
    panic!();
    }

    previously the trace was displayed in 23 stages, and now it will be reduced to
    3 stages that allow you to immediately capture the essence:

    thread 'main' panicked at 'explicit panic', src/main.rs:2:5
    stack backtrace:
    0: std::panicking::begin_panic
    at /rustc/d…d75a/library/std/src/panicking.rs:497
    1: playground::main
    at ./src/main.rs:2
    2: core::ops::function::FnOnce::call_once
    at /rustc/d…d75a/library/core/src/ops/function.rs:227

  • rustc compiler updated to build using LLVM 11 (rust uses LLVM as a backend for code generation). At the same time, the ability to build with old LLVM, up to version 8, is preserved, but by default (in rust-lang/llvm-project) is now using LLVM 11. LLVM 11 is expected to be released in the coming days.
  • On the Windows platform, the rustc compiler provides support for enabling Control Flow Guard checks, activated with the "-C control-flow-guard" flag. On other platforms, this flag is ignored for now.
  • A new portion of the API has been transferred to the category of stable, including stabilized
    Ident::new_raw,
    Range::is_empty
    RangeInclusive::is_empty,
    Result::as_deref,
    Result::as_deref_mut,
    Vec::leak,
    pointer::offset_from,
    f32::TAU and
    f64::TAU.

  • The "const" attribute, which determines the possibility of using it in any context instead of constants, is used in methods:
    • new for all nonzero integers;
    • checked_add, checked_sub, checked_mul, checked_neg, checked_shl, checked_shr, saturating_add, saturating_sub, and saturating_mul for all integers;
    • is_ascii_alphabetic, is_ascii_uppercase, is_ascii_lowercase, is_ascii_alphanumeric, is_ascii_digit, is_ascii_hexdigit, is_ascii_punctuation, is_ascii_graphic, is_ascii_whitespace and is_ascii_control for char and u8 types.
  • For FreeBSD involved toolkit from FreeBSD 11.4 (FreeBSD 10 does not support LLVM 11).

Source: opennet.ru

Add a comment