📜 ⬆️ ⬇️

Announcement Rust 1.12

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


As usual, you can install Rust 1.12 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 includes 1361 patches.


What is included in the stable version 1.12


Release 1.12 is possibly the most significant since release 1.0. We have something to tell, but if you have little time, here is a brief summary.


The most noticeable change for users in 1.12 is the new error format issued by rustc . We talked about it before and this is the first stable release, where the new format is available to all. These error messages are the result of numerous efforts by volunteers who designed, tested and updated every rustc error in accordance with the new format. We are interested to know what you think about new bugs:


New borrowing error


The biggest internal change is the transition to the use of a new compiler backend based on Rust MIR ( English Medium Intermediate Representation). Although this feature currently does not give us anything visible to users, it paves the way for several future compiler optimizations, and for some code bases it already provides an increase in compilation speed and a decrease in the size of the generated code.


Recycled error messages


At 1.12, we present a new error message format. It details the reasons why the compiler refuses to compile your code. To do this, we put your code in the spotlight and highlight the parts that are important in each case. We also annotate every erroneous place and describe in detail what went wrong.


For example, if the type implementation did not match its declaration in 1.11, you saw the following error:


Mismatch


In the new format, we first show the most important parts of the code. In this case, it is the type declaration line, its definition line, and labels indicating a mismatch:
')


New error on the type mismatch


Initially, we developed this type of error to help in understanding the problems reported by the borrowing analyzer. But along the way, we realized that this format can be applied to a variety of different errors - for example, as in the example above. If you would like to learn more about the new system errors, see the previous blog post on this topic .


Finally, you can also get these errors in JSON using the flag. Remember that mistake that we showed at the beginning of the post? This is how an attempt to compile that code looks like, passing it the flag --error-format=json :


 $ rustc borrowck-assign-comp.rs --error-format=json {"message":"cannot assign to `px` because it is borrowed","level":"error","spans":[{"file_name":"borrowck-assign-comp.rs","byte_start":562,"byte_end":563,"line_start":15,"line_end":15,"column_start":14,"column_end":15,"is_primary":false,"text":[{"text":" let q = &p;","highlight_start":14,"highlight_end":15}],"label":"borrow of `px` occurs here","suggested_replacement":null,"expansion":null}],"label":"assignment to borrowed `px` occurs here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":null} {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":null} 

In fact, we omitted some details for the sake of brevity, but the idea is clear. This output is mainly for tools; we continue to work on supporting IDE and other useful developer tools. This kind of error output is a small part of this work.


Code Generation via MIR


A new intermediate representation of the intermediate level (mid-level IR), which we usually call "MIR", makes it easier for the compiler to work with the code on Rust than it was before - when it processed the abstract syntax tree Rust. MIR makes it possible to test and optimize, which were previously considered impossible. The first of the upcoming changes to the compiler, which became available through MIR - rewriting the pass, generating LLVM IR - what rustc calls "translation". After many months of work, the MIR backend is finally ready to perform on the big stage.


MIR contains accurate information about the program’s control flow, so the compiler knows for certain whether the types have been moved or not. This means that he statically knows whether to destructor values. In cases where a value can be moved or not moved at the end of a block, the compiler uses a flag from just one bit on the stack, which is much better optimized by LLVM. The end result is less work for the compiler and less bloated code at runtime. It is also easier for MIR to implement new compiler passes and verify that they work correctly - because MIR is a simpler “language” than full AST.


Other improvements



See the release notes for details.


Library stabilization


In this issue, many types have become a bit more convenient to use.



See the release notes for details.


Cargo features


The most interesting feature added to Cargo in this series is " workspaces ." They are defined in RFC 1525 , and allow a group of packages to share the same Cargo.lock file. If you are engaged in a project that is divided into several packages, workspaces greatly simplify fixing a single version of common dependencies. In most projects, the inclusion of this feature will require the addition of a single line top level in Cargo.toml , [workspace] . More complex projects may require more tricky customization.


Another significant possibility is to overload the path to the source code of the container . You can easily distribute dependencies locally (vendoring), using it in conjunction with tools like cargo-vendor and cargo-local-registry . Over time, the crates.io mirror infrastructure will be built based on this.


There are some minor improvements:



See the release notes for details.


Developers version 1.12


176 people participated in the release of version 1.12. Thank you very much!


List of participants
  • Aaron gallagher
  • abhi
  • Adam Medziński
  • Ahmed charles
  • Alan somers
  • Alexander Altman
  • Alexander Merritt
  • Alex Burka
  • Alex Crichton
  • Amanieu d'anthras
  • Andrea Pretto
  • Andre Bogus
  • Andrew
  • Andrew cann
  • Andrew Paseltiner
  • Andrii dmytrenko
  • Antti keränen
  • Aravind Gollakota
  • Ariel Ben-Yehuda
  • Bastien dejean
  • Ben boeckel
  • Ben stern
  • bors
  • Brendan cully
  • Brett cannon
  • Brian anderson
  • Bruno tavares
  • Cameron hart
  • Camille Roussel
  • Cengiz can
  • CensoredUsername
  • cgswords
  • Chiu-Hsiang Hsu
  • Chris Stankus
  • Christian poveda
  • Christophe Vu-Brugier
  • Clement miao
  • Corey farwell
  • CrLF0710
  • crypto-universe
  • Daniel Campbell
  • David
  • decauwsemaecker.glen@gmail.com
  • Diggory blake
  • Dominik boehi
  • Doug goldstein
  • Dridi boukelmoune
  • Eduard burtescu
  • Eduard-Mihai Burtescu
  • Evgeny safronov
  • Federico Ravasio
  • Felix rath
  • Felix S. Klock II
  • Fran guijarro
  • Georg Brandl
  • ggomez
  • gnzlbg
  • Guillaume gomez
  • hank-der-hafenarbeiter
  • Hariharan r
  • Isaac andrade
  • Ivan Nejgebauer
  • Ivan Ukhov
  • Jack o'connor
  • Jake goulding
  • Jakub Hlusička
  • James miller
  • Jan-Erik Rediger
  • Jared manning
  • Jared wyles
  • Jeffrey seyfried
  • Jethro beekman
  • Jonas schievink
  • Jonathan A. Kollasch
  • Jonathan creekmore
  • Jonathan giddy
  • Jonathan turner
  • Jorge aparicio
  • José manuel Barroso Galindo
  • Josh stone
  • Jupp muler
  • Kaivo Anastetiks
  • kc1212
  • Keith yeung
  • Knight
  • Krzysztof Garczynski
  • Loïc damien
  • Luke Hinds
  • Luqman Aden
  • m4b
  • Manish goregaokar
  • Marco al barosa
  • Mark buer
  • Mark-simulacrum
  • Martin pool
  • Masood Malekghassemi
  • Matthew piziak
  • Matthias rabault
  • Matt horn
  • mcarton
  • M Farkas-Dyck
  • Michael Gattozzi
  • Michael Neumann
  • Michael Rosenberg
  • Michael Woerister
  • Mike hommey
  • Mikhail Modin
  • mitchmindtree
  • mLuby
  • Moritz ulrich
  • Murath
  • Nick cameron
  • Nick massey
  • Nikhil Shagrithaya
  • Niko Matsakis
  • Novotnik, Petr
  • Oliver forral
  • Oliver middleton
  • Oliver schneider
  • Omer sheikh
  • Panashe M. Fundira
  • Patrick McCann
  • Paul Woolcock
  • Peter C. Norton
  • Phlogistic fugu
  • Pietro albini
  • Rahiel Kasim
  • Rahul sharma
  • Robert Williamson
  • Roy brunton
  • Ryan Scheel
  • Ryan scott
  • saml
  • Sam payson
  • Samuel Cormier-Iijima
  • Scott a carr
  • Sean McArthur
  • Sebastian thiel
  • Seo sanghyeon
  • Shantanu raj
  • ShyamSundarB
  • silenuss
  • Simonas kazlauskas
  • srdja
  • Srinivas reddy thatiparthy
  • Stefan schindler
  • Stephen lazaro
  • Steve klabnik
  • Steven fackler
  • Steven walter
  • Sylvestre ledru
  • Tamir duberstein
  • Terry sun
  • TheZoq2
  • Thomas garcia
  • Tim neumann
  • Timon van overveldt
  • Tobias bucher
  • Tomasz Miąsko
  • trixnz
  • Tshepang Lekhonkhobe
  • ubsan
  • Ulrik sverdrup
  • Vadim chugunov
  • Vadim Petrochenkov
  • Vincent prouillet
  • Vladimir Vukicevic
  • Wang xuerui
  • Wesley wiser
  • William Lee
  • Ximin luo
  • Yojan shrestha
  • Yossi Konstantinovsky
  • Zack M. Davis
  • Zhen zhang
  • 吴 冉波

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


All Articles