📜 ⬆️ ⬇️

Announcement Rust 1.9

We are pleased to introduce the new version of Rust 1.9. Rust is a system programming language aimed at safe work with memory, speed and parallel code execution.


As usual, you can install Rust 1.9 from the corresponding page of the official site, and also get acquainted with the detailed list of changes in this version on GitHub. This release included about 1400 patches.


What is included in the stable version 1.9


Managed Stack Unwind


The biggest change in Rust 1.9 is the stabilization of the std::panic module, which provides methods for stopping the process of unwinding a stack triggered by panic:


 use std::panic; let result = panic::catch_unwind(|| { println!("!"); }); assert!(result.is_ok()); let result = panic::catch_unwind(|| { panic!(" !"); }); assert!(result.is_err()); 

This interface was defined in RFC 1236 .


In general, Rust distinguishes between two types of error situations:



Expected problems usually occur due to circumstances that the program cannot control; reliable code must be ready for any trouble arising in its environment. Expected problems are handled in Rust using the Result type , which allows the function to return the problem information to the caller, and the caller can already handle the error. This is a fairly accurate way to handle errors.


Unexpected problems are bugs : they occur because of a breach of contract or assertion. Since their occurrence is unexpected, there is not much point in accurately processing such errors. Instead, Rust uses the "fail fast" approach — such errors cause panic, which by default starts unwinding the stack of a thread that has encountered an error. In this case, only destructors are executed - no other code is executed. Other threads will continue to run, but they will find a panic when trying to exchange data with a panic stream (through channels or through shared memory). Thus, panic interrupts execution, down to some kind of "isolation boundary". The code on the other side of the border can continue to work, and if desired, restore the program from a state of panic, in a "rude" way. For example, the server does not necessarily fall due to a failed assert in one of its threads.


The new catch_unwind interface provides a way to introduce additional isolation boundaries within the stream . There are a couple of examples where this is useful:



The first case was a potentially undefined behavior. In practice, unwinding to another language often leads to segfault. By allowing us to catch a panic, we simplify exporting a code to Rust as an API C - now we can catch a panic on the border of the transition to C and convert it into a return code.


The second case is motivated by thread pool libraries. If a thread in a pool is panicking, it’s usually not necessary to kill the thread itself. Instead, you need to catch a panic and report it to the client pool. The catch_unwind interface has a resume_unwind function resume_unwind , which can be used to restart the panic process on the client side of the pool, to which it belongs.


In both cases, we introduce an additional isolation boundary within the stream, and then convert the panic into another kind of error.


catch_unwind final note: why is catch_unwind , not catch_panic ? Work is underway to add another strategy for panicking: interrupting the entire process (abort). In this case, it is possible that a common hook will be executed. For some applications, this is the most reasonable way to handle programming errors, and preventing stack unwinding can provide improved performance and smaller code size.


Obsolete interface warnings (deprecation warnings)


A new attribute has become available for authors of libraries: #[deprecated] . This attribute allows you to mark an outdated interface, and library users will receive a warning when using it. In this case, you can specify a new recommended replacement interface. Obsolete interface warnings have long been used in the standard library, and now, thanks to RFC 1270 , they can be used throughout the entire Rust ecosystem.


New compilation platforms


Now compiled standard libraries for several new platforms are published:



The first two platforms are particularly interesting in terms of cross-compiling; See the recent publication for rustup for rustup .


Compile acceleration


The time complexity of checking variables for equivalence during type unification is reduced from O (n!) To O (n). As a result, some code samples are compiled much faster.


We roll out the use of specialization


In this release, specialization is first used in the standard library. Currently specialization is only available at nightly . It allows you to specialize generic code for more specific types.


One example where this happens in the standard library is the conversion from the string slice ( &str ) to the owned string ( String ). The to_string method is taken from a generic interface, which was previously slower than the special to_owned method. Now these functions are equivalent .


By implementing this simple case, we will proceed to other places where you can improve performance with the help of specialization.


Library stabilization


In 1.9 about 80 library functions are stabilized. The most noticeable change is the std::panic module described earlier. Besides him there are several other things.


Work with network



Collections



Encodings



Pointers



Finally, many types in libcore did not have the Debug type implementation. This is fixed in release 1.9.


See here for more details .


Cargo features


Cargo has two big changes.


First, now several Cargo processes can work simultaneously .


Secondly, a new flag has been added - RUSTFLAGS . This flag allows you to specify arbitrary flags that will be passed to rustc through the environment. This is useful, for example, for packers.


See here for more details .


Developers version 1.9


127 people participated in the release of version 1.9. Thank you very much!


Developer List
  • Aaron turon
  • Abhishek chanda
  • Adolfo ochagavía
  • Aidan hobson sayers
  • Alan somers
  • Alejandro wainzinger
  • Aleksey Kladov
  • Alex Burka
  • Alex Crichton
  • Amanieu d'anthras
  • Andrea Canciani
  • Andreas Linz
  • Andrew Cantino
  • Andrew horton
  • Andrew Paseltiner
  • Andrey Cherkashin
  • Angus lees
  • Ariel Ben-Yehuda
  • Benjamin herr
  • Björn steinbrink
  • Brian anderson
  • Brian bowman
  • Christian wesselhoeft
  • Christopher Serr
  • Corey farwell
  • Craig M. Brandenburg
  • Cyryl Płotnicki-Chudyk
  • Daniel J Rollins
  • Dave huseby
  • David Ao Lozano
  • David Henningsson
  • Devon hollowood
  • Dirk gadsden
  • Doug goldstein
  • Eduard burtescu
  • Eduard-Mihai Burtescu
  • Eli friedman
  • Emanuel czirai
  • Erick tryzelaar
  • Evan
  • Felix S. Klock II
  • Florian berger
  • Geoff catlin
  • Guillaume gomez
  • Gökhan Karabulut
  • JP Sugarbroad
  • James miller
  • Jeffrey seyfried
  • John talling
  • Jonas schievink
  • Jonathan s
  • Jorge aparicio
  • Joshua holmer
  • Kai noda
  • Kamal Marhubi
  • Katze
  • Kevin brothaler
  • Kevin butler
  • Manish goregaokar
  • Markus westerlind
  • Marvin lobel
  • Masood Malekghassemi
  • Matt brubeck
  • Michael Huynh
  • Michael Neumann
  • Michael Woerister
  • Ms2ger
  • NODA, Kai
  • Nathan Kleyn
  • Nick cameron
  • Niko Matsakis
  • Noah
  • Novotnik, Petr
  • Oliver middleton
  • Oliver schneider
  • Philipp Oppermann
  • Piotr czarnecki
  • Pyfisch
  • Richo healey
  • Ruud van Asseldonk
  • Scott olson
  • Sean McArthur
  • Sebastian wicki
  • Seo sanghyeon
  • Simon sapin
  • Simonas kazlauskas
  • Steve klabnik
  • Steven allen
  • Steven fackler
  • Stu black
  • Sebastien marie
  • Tang chenglong
  • Ted horst
  • Ticki
  • Tim Montague
  • Tim neumann
  • Timon van overveldt
  • Tobias bucher
  • Tobias müller
  • Todd lucas
  • Tom Tromey
  • Tshepang Lekhonkhobe
  • Ulrik sverdrup
  • Vadim Petrochenkov
  • Valentin lorentz
  • Varun vats
  • Wang xuerui
  • Wangshan Lu
  • York xiang
  • arcnmx
  • ashleysommer
  • bors
  • ggomez
  • gohyda
  • ituxbag
  • mitaa
  • nicholasf
  • petevine
  • pierzchalski
  • pravic
  • srinivasreddy
  • tiehuis
  • ubsan
  • vagrant
  • vegai
  • vlastachu
  • Valery Lashmanov

')

Source: https://habr.com/ru/post/301994/


All Articles