📜 ⬆️ ⬇️

Release Rust 1.24

The Rust team is pleased to announce the new version of Rust: 1.24.0. Rust is a system programming language aimed at security, speed, and parallel code execution.


If you have a previous version of Rust installed, just update it with:


$ rustup update stable 

If you have not yet installed rustup, you can install it from the corresponding page of our website. Detailed notes for the release of Rust 1.24.0 can be found on GitHub.


What is included in the stable version 1.24.0


This release contains two very interesting new features: rustfmt and incremental compilation!



rustfmt


For many years, we needed a tool that could automatically format the Rust code in some kind of "standard" style. In this issue we are pleased to announce a preview of rustfmt , which can be used with a stable version 1.24. To try, run the following commands:


 $ rustup component add rustfmt-preview 

There are two important points: first, you use rustup component add instead of cargo install . If you have previously used rustfmt installed through the cargo install you should remove it first. Secondly, it is a preview, as stated in the title. rustfmt has not yet reached version 1.0 and some things are still being configured, and bugs are fixed. As soon as rustfmt reaches version 1.0, we will release the rustfmt component, and the rustfmt-preview will be considered obsolete.


In the near future we plan to write a post about this release strategy, there will be a lot of information and it goes beyond the post of this release.


For more information you can visit rustfmt on github .


Incremental compilation


Back in September 2016, we wrote about incremental compilation . This post went into details about how it works, but the key idea is this: when you work on a project, you often have to compile it, changing small sections of code and compiling it again. Historically, all your code was compiled no matter how small your changes were. The idea of ​​incremental compilation is to compile only the code that has really changed, which means that subsequent compilations will be faster.


Starting with version 1.24, it will be enabled by default . This means your builds will be faster. Do not forget also about the cargo check command, which will allow you to get the minimum build time (note: this command does not build a binary, only checks the correctness of the code, but still leads to acceleration of the build in debug mode since the incremental compilation cache is as far as I understand they have ). This is not the end of compiler performance and incremental compilation. In the future we are planning a lot more work on this. For example, one more change affecting the performance is stabilized in this release: codegen-units now set to 16 by default . A quick note about this change: it makes the build faster, but the final code will be a bit slower. For maximum performance of the resulting code, you must set the codegen-units to 1 in the Cargo.toml your project.


Other changes included in the release


There is another change that we wanted to mention here: UB. Rust seeks to minimize UB without having one in a safe code and as little as possible in an unsafe. One area where you could meet UB is panic! called from FFI. For example:


 extern "C" fn panic_in_ffi() { panic!("Test"); } 

This cannot work, because the exact mechanism of the panic operation must be coordinated with how C ABI works, in this example, or any other ABI in other examples.


In Rust 1.24, this code is now broken , and does not create undefined behavior.


Library stabilization


If you are a fan of the str::find function, which is used to find the required char in &str you should be happy to see this pool request: now it is 10 times faster ! This is thanks to memchr . [u8]::contains also uses it , but does not receive such extreme acceleration.


Also in this release several new APIs were stabilized:



Now the following functions can be used in constant expressions, for example, to initialize static :



Developers 1.24


A lot of people participated in the development of Rust 1.24. We could not achieve this without the participation of each of you. Thank!


')

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


All Articles