Rust programming language 1.47 release

Release 1.47 of the system programming language Rust, founded by the Mozilla project, has been published. 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 a garbage collector and 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, provide builds and manage dependencies, the project develops the Cargo package manager. The crates.io repository is supported for hosting libraries.

Main innovations:

  • Implemented support for traits for arrays of 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 and are now used 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, allowing 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

  • The rustc compiler has been 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 LLVMs up to version 8 is preserved, but by default (in rust-lang/llvm-project) LLVM 11 is now used. 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 moved to the stable category, including the stabilization of 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.
  • FreeBSD uses the toolkit from FreeBSD 11.4 (FreeBSD 10 does not support LLVM 11).

Taken from opennet.ru

Source: linux.org.ru

Add a comment