Rust 1.53 release. Google will fund adding Rust support to the Linux kernel

The release of the system programming language Rust 1.53, founded by the Mozilla project, but now developed under the auspices of the independent non-profit organization Rust Foundation, 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:

  • For arrays, the IntoIterator trait has been implemented, which allows you to organize the iteration of array elements by values: for i in [1, 2, 3] { .. }

    It is also possible to pass arrays to methods that accept iterators, for example: let set = BTreeSet::from_iter([1, 2, 3]); for (a, b) in some_iterator.chain([1]).zip([1, 2, 3]) { .. }

    Previously, IntoIterator was only implemented for array references, i.e. to iterate over values ​​required the use of references (“&[1, 2, 3]”) or “[1, 2, 3].iter()”. The implementation of IntoIterator for arrays was hampered by compatibility issues caused by an earlier compiler conversion from array.into_iter() to (&array).into_iter(). These problems were solved with a workaround - the compiler will continue to convert array.into_iter() to (&array).into_iter() as if there was no implementation of the IntoIterator trait, but only when calling the method using the ".into_iter()" syntax and without touching the calls in the form "in [1, 2, 3]", "iter.zip([1, 2, 3])", "IntoIterator::into_iter([1, 2, 3])".

  • It is possible to specify expressions “|” (logical OR operation) in any part of the template, for example, instead of “Some(1) | Some(2)" you can now write "Some(1 | 2)": match result { Ok(Some(1 | 2)) => { .. } Err(MyError { kind: FileNotFound | PermissionDenied, .. }) = > { .. } _ => { .. } }
  • The use of non-ASCII characters in identifiers is permitted, including any national characters defined in the Unicode UAX 31 specification, but excluding emoji characters. If you use different but similar characters, the compiler will issue a warning. const BLÅHAJ: &str = "🦈"; struct 人 { 名字: String, } let α = 1; letsos = 2; warning: identifier pair considered confusable between 's' and 's'
  • A new portion of the API has been transferred to the category of stable, including stabilized:
    • array::from_ref
    • array::from_mut
    • AtomicBool::fetch_update
    • AtomicPtr::fetch_update
    • BTreeSet::retain
    • BTreeMap::retain
    • BufReader::seek_relative
    • cmp::min_by
    • cmp::min_by_key
    • cmp::max_by
    • cmp::max_by_key
    • DebugStruct::finish_non_exhaustive
    • Duration::ZERO
    • Duration::MAX
    • Duration::is_zero
    • Duration::saturating_add
    • Duration::saturating_sub
    • Duration::saturating_mul
    • f32::is_subnormal
    • f64::is_subnormal
    • IntoIterator for arrays
    • {integer}::BITS
    • io::Error::Unsupported
    • NonZero*::leading_zeros
    • NonZero*::trailing_zeros
    • Option::insert
    • Ordering::is_eq
    • Ordering::is_ne
    • Ordering::is_lt
    • Ordering::is_gt
    • Ordering::is_le
    • Ordering::is_ge
    • OsStr::make_ascii_lowercase
    • OsStr::make_ascii_uppercase
    • OsStr::to_ascii_lowercase
    • OsStr::to_ascii_uppercase
    • OsStr::is_ascii
    • OsStr::eq_ignore_ascii_case
    • Peekable::peek_mut
    • Rc::increment_strong_count
    • Rc::decrement_strong_count
    • slice::IterMut::as_slice
    • AsRef<[T]> for slice::IterMut
    • impl SliceIndex for (Bound , Bound )
    • Vec::extend_from_within
  • The third level of support for the wasm64-unknown-unknown platform has been implemented. The third level involves basic support, but without automated testing, publishing official builds, or checking whether the code can be built.
  • The Cargo package manager has been moved to use the name "main" for the main branch of the Git repository (HEAD) by default. Dependencies hosted in repositories that use the name main instead of master no longer require branch = "main" to be configured.
  • In the compiler, the requirements for the minimum version of LLVM are raised to LLVM 10.

Additionally, we can note the provision of funding for the development of integration into the Linux kernel of tools for developing components in the Rust language. The work will be carried out within the framework of the Prossimo project under the auspices of the ISRG organization (Internet Security Research Group), which is the founder of the Let's Encrypt project and promotes HTTPS and the development of technologies to increase the security of the Internet. The funds will be provided by Google, which will pay for the work of Miguel Ojeda, the author of the Rust-for-Linux project. Previously, ISRG and Google have already funded the creation of an alternative HTTP backend for the curl utility and the development of a new TLS module for the Apache http server.

According to Microsoft and Google, about 70% of vulnerabilities are caused by unsafe memory handling. It is expected that using the Rust language to develop kernel components such as device drivers will reduce the risk of vulnerabilities caused by unsafe memory handling and eliminate errors such as accessing a memory region after it has been freed and overrunning buffer bounds.

Memory-safe handling is provided in Rust at compile time through reference checking, keeping track of object ownership and object lifetime (scope), as well as through evaluation of 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.

Source: opennet.ru

Add a comment