|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Announcing Rust 1.12.0" |
| 4 | +author: The Rust Core Team |
| 5 | +--- |
| 6 | + |
| 7 | +The Rust team is happy to announce the latest version of Rust, 1.12.0. Rust is |
| 8 | +a systems programming language with the slogan "fast, reliable, productive: |
| 9 | +pick three." |
| 10 | + |
| 11 | +As always, you can [install Rust 1.12.0][install] from the appropriate page on our |
| 12 | +website, and check out the [detailed release notes for 1.12.0][notes] on GitHub. |
| 13 | +1361 patches were landed in this release. |
| 14 | + |
| 15 | +[install]: https://www.rust-lang.org/install.html |
| 16 | +[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1120-2016-09-29 |
| 17 | + |
| 18 | +### What's in 1.12.0 stable |
| 19 | + |
| 20 | +The release of 1.12 might be one of the most significant Rust releases since |
| 21 | +1.0. We have a lot to cover, but if you don't have time for that, here's a |
| 22 | +summary: |
| 23 | + |
| 24 | +The largest user-facing change in 1.12 stable is the new error message format |
| 25 | +emitted by `rustc`. We've [previously talked] about this format and this is the |
| 26 | +first stable release where they are broadly available. These error messages are |
| 27 | +a result of the effort of many hours of [volunteer effort] to design, test, and |
| 28 | +update every one of `rustc`s errors to the new format. We're excited to see |
| 29 | +what you think of them: |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +The largest internal change in this release is moving to a new compiler backend |
| 34 | +based on the new Rust [MIR]. While this feature does not result in anything |
| 35 | +user-visible today, it paves the way for a number of future compiler |
| 36 | +optimizations, and for some codebases it already results in improvements to |
| 37 | +compile times and reductions in code size. |
| 38 | + |
| 39 | +[previously talked]: https://blog.rust-lang.org/2016/08/10/Shape-of-errors-to-come.html |
| 40 | +[volunteer effort]: https://github.com/rust-lang/rust/issues/35233 |
| 41 | +[MIR]: https://blog.rust-lang.org/2016/04/19/MIR.html |
| 42 | + |
| 43 | +#### Overhauled error messages |
| 44 | + |
| 45 | +With 1.12 we're introducing a new error format which helps to surface a lot of |
| 46 | +the internal knowledge about why an error is occurring to you, the developer. |
| 47 | +It does this by putting your code front and center, highlighting the parts |
| 48 | +relevant to the error with annotations describing what went wrong. |
| 49 | + |
| 50 | +For example, in 1.11 if a implementation of a trait didn't match the trait |
| 51 | +declaration, you would see an error like the one below: |
| 52 | + |
| 53 | + |
| 55 | + |
| 56 | +In the new error format we represent the error by instead showing the points in |
| 57 | +the code that matter the most. Here is the relevant line in the trait |
| 58 | +declaration, and the relevant line in the implementation, using labels to |
| 59 | +describe why they don't match: |
| 60 | + |
| 61 | + |
| 63 | + |
| 64 | +Initially, this error design was built to aid in understanding borrow-checking |
| 65 | +errors, but we found, as with the error above, the format can be broadly |
| 66 | +applied to a wide variety of errors. If you would like to learn more about the |
| 67 | +design, check out the [previous blog post on the subject][err]. |
| 68 | + |
| 69 | +[err]: https://blog.rust-lang.org/2016/08/10/Shape-of-errors-to-come.html |
| 70 | + |
| 71 | +Finally, you can also get these errors as JSON with a flag. Remember that error |
| 72 | +we showed above, at the start of the post? Here's an example of attempting to |
| 73 | +compile that code while passing the `--error-format=json` flag: |
| 74 | + |
| 75 | +```bash |
| 76 | +$ rustc borrowck-assign-comp.rs --error-format=json |
| 77 | +{"message":"cannot assign to `p.x` 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 `p.x` occurs here","suggested_replacement":null,"expansion":null}],"label":"assignment to borrowed `p.x` occurs here","suggested_replacement":null,"expansion":null}],"children":[],"rendered":null} |
| 78 | +{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":null} |
| 79 | +``` |
| 80 | + |
| 81 | +We've actually elided a bit of this for brevity's sake, but you get the idea. |
| 82 | +This output is primarily for tooling; we are continuing to invest in supporting |
| 83 | +IDEs and other useful development tools. This output is a small part of that |
| 84 | +effort. |
| 85 | + |
| 86 | +#### MIR code generation |
| 87 | + |
| 88 | +The new Rust "mid-level IR", usually called "MIR", gives the compiler a simpler |
| 89 | +way to think about Rust code than its previous way of operating entirely on the |
| 90 | +Rust abstract syntax tree. It makes analysis and optimizations possible that |
| 91 | +have historically been difficult to implement correctly. The first of many |
| 92 | +upcoming changes to the compiler enabled by MIR is a rewrite of the pass that |
| 93 | +generates LLVM IR, what `rustc` calls "translation", and after many months of |
| 94 | +effort the MIR-based backend has proved itself ready for prime-time. |
| 95 | + |
| 96 | +MIR exposes perfect information about the program's control flow, so the |
| 97 | +compiler knows exactly whether types are moved or not. This means that it knows |
| 98 | +statically whether or not the value's destructor needs to be run. In cases |
| 99 | +where a value may or may not be moved at the end of a scope, the compiler now |
| 100 | +simply uses a single bitflag on the stack, which is in turn easier for |
| 101 | +optimization passes in LLVM to reason about. The end result is less work for |
| 102 | +the compiler and less bloat at runtime. In addition, because MIR is a simpler |
| 103 | +'language' than the full AST, it's also easier to implement compiler passes on, |
| 104 | +and easier to verify that they are correct. |
| 105 | + |
| 106 | +#### Other improvements |
| 107 | + |
| 108 | +* Many minor improvements to the documentation. |
| 109 | +* [`rustc` supports three new MUSL targets on ARM: `arm-unknown-linux-musleabi`, |
| 110 | + `arm-unknown-linux-musleabihf`, and `armv7-unknown-linux-musleabihf`] |
| 111 | + (https://github.com/rust-lang/rust/pull/35060). |
| 112 | + These targets produce statically-linked binaries. There are no binary release |
| 113 | + builds yet though. |
| 114 | +* In error descriptions, |
| 115 | + [references](https://github.com/rust-lang/rust/pull/35611) and [unknown numeric |
| 116 | + types](https://github.com/rust-lang/rust/pull/35080) have more human-friendly errors. |
| 117 | +* [The compiler can now be built against LLVM 3.9] |
| 118 | + (https://github.com/rust-lang/rust/pull/35594) |
| 119 | +* [Test binaries now support a `--test-threads` argument to specify the number |
| 120 | + of threads used to run tests, and which acts the same as the |
| 121 | + `RUST_TEST_THREADS` environment variable] |
| 122 | + (https://github.com/rust-lang/rust/pull/35414) |
| 123 | +* [The test runner now emits a warning when tests run over 60 seconds] |
| 124 | + (https://github.com/rust-lang/rust/pull/35405) |
| 125 | +* [Rust releases now come with source packages that can be installed by rustup |
| 126 | + via `rustup component add rust-src`] |
| 127 | + (https://github.com/rust-lang/rust/pull/34366). |
| 128 | + The resulting source code can be used by tools and IDES, located in the |
| 129 | + sysroot under `lib/rustlib/src`. |
| 130 | + |
| 131 | +See the [detailed release notes][notes] for more. |
| 132 | + |
| 133 | +#### Library stabilizations |
| 134 | + |
| 135 | +This release sees a number of small quality of life improvements for various |
| 136 | +types in the standard library: |
| 137 | + |
| 138 | +* [`Cell::as_ptr`](https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_ptr) |
| 139 | + and |
| 140 | + [`RefCell::as_ptr`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.as_ptr) |
| 141 | +* `IpAddr`, `Ivp4Addr`, and `Ipv6Addr` have a few new methods. |
| 142 | +* [`LinkedList`](https://doc.rust-lang.org/std/collections/linked_list/struct.LinkedList.html#method.contains) |
| 143 | + and |
| 144 | + [`VecDeque`](https://doc.rust-lang.org/std/collections/vec_deque/struct.VecDeque.html#method.contains) |
| 145 | + have a new `contains` method. |
| 146 | +* [`iter::Product`](https://doc.rust-lang.org/std/iter/trait.Product.html) and |
| 147 | + [`iter::Sum`](https://doc.rust-lang.org/std/iter/trait.Sum.html) |
| 148 | +* [`Option` implements `From` for its contained type] |
| 149 | + (https://github.com/rust-lang/rust/pull/34828) |
| 150 | +* [`Cell`, `RefCell` and `UnsafeCell` implement `From` for their contained type] |
| 151 | + (https://github.com/rust-lang/rust/pull/35392) |
| 152 | +* [`Cow<str>` implements `FromIterator` for `char`, `&str` and `String`] |
| 153 | + (https://github.com/rust-lang/rust/pull/35064) |
| 154 | +* [Sockets on Linux are correctly closed in subprocesses via `SOCK_CLOEXEC`] |
| 155 | + (https://github.com/rust-lang/rust/pull/34946) |
| 156 | +* [`String` implements `AddAssign`] |
| 157 | + (https://github.com/rust-lang/rust/pull/34890) |
| 158 | +* [Unicode definitions have been updated to 9.0] |
| 159 | + (https://github.com/rust-lang/rust/pull/34599) |
| 160 | + |
| 161 | +See the [detailed release notes][notes] for more. |
| 162 | + |
| 163 | +#### Cargo features |
| 164 | + |
| 165 | +The biggest feature added to Cargo this cycle is the ability to [override the |
| 166 | +source of a crate](https://github.com/rust-lang/cargo/pull/2857). Using this |
| 167 | +with tools like [cargo-vendor] and [cargo-local-registry] allow vendoring |
| 168 | +dependencies locally in a robust fashion. Eventually this support will be the |
| 169 | +foundation of supporting mirrors of [crates.io] as well. |
| 170 | + |
| 171 | +[cargo-vendor]: https://github.com/alexcrichton/cargo-vendor |
| 172 | +[cargo-local-registry]: https://github.com/alexcrichton/cargo-local-registry |
| 173 | +[crates.io]: https://crates.io/ |
| 174 | + |
| 175 | +There are some other improvments as well: |
| 176 | + |
| 177 | +* [Speed up noop registry updates](https://github.com/rust-lang/cargo/pull/2974) |
| 178 | +* [Add a `--lib` flag to `cargo new`] |
| 179 | + (https://github.com/rust-lang/cargo/pull/2921) |
| 180 | +* [Indicate the compilation profile after compiling] |
| 181 | + (https://github.com/rust-lang/cargo/pull/2909) |
| 182 | +* [Add `--dry-run` to `cargo publish`] |
| 183 | + (https://github.com/rust-lang/cargo/pull/2849) |
| 184 | + |
| 185 | +See the [detailed release notes][notes] for more. |
| 186 | + |
| 187 | +### Contributors to 1.12.0 |
| 188 | + |
| 189 | +We had 176 individuals contribute to 1.12.0. Thank you so much! |
| 190 | + |
| 191 | +* Aaron Gallagher |
| 192 | +* abhi |
| 193 | +* Adam Medziński |
| 194 | +* Ahmed Charles |
| 195 | +* Alan Somers |
| 196 | +* Alexander Altman |
| 197 | +* Alexander Merritt |
| 198 | +* Alex Burka |
| 199 | +* Alex Crichton |
| 200 | +* Amanieu d'Antras |
| 201 | +* Andrea Pretto |
| 202 | +* Andre Bogus |
| 203 | +* Andrew |
| 204 | +* Andrew Cann |
| 205 | +* Andrew Paseltiner |
| 206 | +* Andrii Dmytrenko |
| 207 | +* Antti Keränen |
| 208 | +* Aravind Gollakota |
| 209 | +* Ariel Ben-Yehuda |
| 210 | +* Bastien Dejean |
| 211 | +* Ben Boeckel |
| 212 | +* Ben Stern |
| 213 | +* bors |
| 214 | +* Brendan Cully |
| 215 | +* Brett Cannon |
| 216 | +* Brian Anderson |
| 217 | +* Bruno Tavares |
| 218 | +* Cameron Hart |
| 219 | +* Camille Roussel |
| 220 | +* Cengiz Can |
| 221 | +* CensoredUsername |
| 222 | +* cgswords |
| 223 | +* Chiu-Hsiang Hsu |
| 224 | +* Chris Stankus |
| 225 | +* Christian Poveda |
| 226 | +* Christophe Vu-Brugier |
| 227 | +* Clement Miao |
| 228 | +* Corey Farwell |
| 229 | +* CrLF0710 |
| 230 | +* crypto-universe |
| 231 | +* Daniel Campbell |
| 232 | +* David |
| 233 | + |
| 234 | +* Diggory Blake |
| 235 | +* Dominik Boehi |
| 236 | +* Doug Goldstein |
| 237 | +* Dridi Boukelmoune |
| 238 | +* Eduard Burtescu |
| 239 | +* Eduard-Mihai Burtescu |
| 240 | +* Evgeny Safronov |
| 241 | +* Federico Ravasio |
| 242 | +* Felix Rath |
| 243 | +* Felix S. Klock II |
| 244 | +* Fran Guijarro |
| 245 | +* Georg Brandl |
| 246 | +* ggomez |
| 247 | +* gnzlbg |
| 248 | +* Guillaume Gomez |
| 249 | +* hank-der-hafenarbeiter |
| 250 | +* Hariharan R |
| 251 | +* Isaac Andrade |
| 252 | +* Ivan Nejgebauer |
| 253 | +* Ivan Ukhov |
| 254 | +* Jack O'Connor |
| 255 | +* Jake Goulding |
| 256 | +* Jakub Hlusička |
| 257 | +* James Miller |
| 258 | +* Jan-Erik Rediger |
| 259 | +* Jared Manning |
| 260 | +* Jared Wyles |
| 261 | +* Jeffrey Seyfried |
| 262 | +* Jethro Beekman |
| 263 | +* Jonas Schievink |
| 264 | +* Jonathan A. Kollasch |
| 265 | +* Jonathan Creekmore |
| 266 | +* Jonathan Giddy |
| 267 | +* Jonathan Turner |
| 268 | +* Jorge Aparicio |
| 269 | +* José manuel Barroso Galindo |
| 270 | +* Josh Stone |
| 271 | +* Jupp Müller |
| 272 | +* Kaivo Anastetiks |
| 273 | +* kc1212 |
| 274 | +* Keith Yeung |
| 275 | +* Knight |
| 276 | +* Krzysztof Garczynski |
| 277 | +* Loïc Damien |
| 278 | +* Luke Hinds |
| 279 | +* Luqman Aden |
| 280 | +* m4b |
| 281 | +* Manish Goregaokar |
| 282 | +* Marco A L Barbosa |
| 283 | +* Mark Buer |
| 284 | +* Mark-Simulacrum |
| 285 | +* Martin Pool |
| 286 | +* Masood Malekghassemi |
| 287 | +* Matthew Piziak |
| 288 | +* Matthias Rabault |
| 289 | +* Matt Horn |
| 290 | +* mcarton |
| 291 | +* M Farkas-Dyck |
| 292 | +* Michael Gattozzi |
| 293 | +* Michael Neumann |
| 294 | +* Michael Rosenberg |
| 295 | +* Michael Woerister |
| 296 | +* Mike Hommey |
| 297 | +* Mikhail Modin |
| 298 | +* mitchmindtree |
| 299 | +* mLuby |
| 300 | +* Moritz Ulrich |
| 301 | +* Murarth |
| 302 | +* Nick Cameron |
| 303 | +* Nick Massey |
| 304 | +* Nikhil Shagrithaya |
| 305 | +* Niko Matsakis |
| 306 | +* Novotnik, Petr |
| 307 | +* Oliver Forral |
| 308 | +* Oliver Middleton |
| 309 | +* Oliver Schneider |
| 310 | +* Omer Sheikh |
| 311 | +* Panashe M. Fundira |
| 312 | +* Patrick McCann |
| 313 | +* Paul Woolcock |
| 314 | +* Peter C. Norton |
| 315 | +* Phlogistic Fugu |
| 316 | +* Pietro Albini |
| 317 | +* Rahiel Kasim |
| 318 | +* Rahul Sharma |
| 319 | +* Robert Williamson |
| 320 | +* Roy Brunton |
| 321 | +* Ryan Scheel |
| 322 | +* Ryan Scott |
| 323 | +* saml |
| 324 | +* Sam Payson |
| 325 | +* Samuel Cormier-Iijima |
| 326 | +* Scott A Carr |
| 327 | +* Sean McArthur |
| 328 | +* Sebastian Thiel |
| 329 | +* Seo Sanghyeon |
| 330 | +* Shantanu Raj |
| 331 | +* ShyamSundarB |
| 332 | +* silenuss |
| 333 | +* Simonas Kazlauskas |
| 334 | +* srdja |
| 335 | +* Srinivas Reddy Thatiparthy |
| 336 | +* Stefan Schindler |
| 337 | +* Stephen Lazaro |
| 338 | +* Steve Klabnik |
| 339 | +* Steven Fackler |
| 340 | +* Steven Walter |
| 341 | +* Sylvestre Ledru |
| 342 | +* Tamir Duberstein |
| 343 | +* Terry Sun |
| 344 | +* TheZoq2 |
| 345 | +* Thomas Garcia |
| 346 | +* Tim Neumann |
| 347 | +* Timon Van Overveldt |
| 348 | +* Tobias Bucher |
| 349 | +* Tomasz Miąsko |
| 350 | +* trixnz |
| 351 | +* Tshepang Lekhonkhobe |
| 352 | +* ubsan |
| 353 | +* Ulrik Sverdrup |
| 354 | +* Vadim Chugunov |
| 355 | +* Vadim Petrochenkov |
| 356 | +* Vincent Prouillet |
| 357 | +* Vladimir Vukicevic |
| 358 | +* Wang Xuerui |
| 359 | +* Wesley Wiser |
| 360 | +* William Lee |
| 361 | +* Ximin Luo |
| 362 | +* Yojan Shrestha |
| 363 | +* Yossi Konstantinovsky |
| 364 | +* Zack M. Davis |
| 365 | +* Zhen Zhang |
| 366 | +* 吴冉波 |
0 commit comments