From 9860ce48d93113b58e147e13aebdd12cd0a535b5 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Mon, 5 Jun 2017 16:46:26 -0400 Subject: [PATCH 1/3] initial draft of 1.18.0 announcement --- _posts/2017-06-08-Rust-1.18.md | 200 +++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 _posts/2017-06-08-Rust-1.18.md diff --git a/_posts/2017-06-08-Rust-1.18.md b/_posts/2017-06-08-Rust-1.18.md new file mode 100644 index 000000000..2925f561c --- /dev/null +++ b/_posts/2017-06-08-Rust-1.18.md @@ -0,0 +1,200 @@ +--- +layout: post +title: "Announcing Rust 1.18" +author: The Rust Core Team +--- + +The Rust team is happy to announce the latest version of Rust, 1.18.0. Rust is a +systems programming language focused on safety, speed, and concurrency. + +If you have a previous version of Rust installed, getting Rust 1.18 is as easy as: + +```bash +$ rustup update stable +``` + +If you don't have it already, you can [get `rustup`][install] from the +appropriate page on our website, and check out the [detailed release notes for +1.18.0][notes] on GitHub. + +[install]: https://www.rust-lang.org/install.html +[notes]: https://github.com/rust-lang/rust/blob/rust-1.17-relnotes/RELEASES.md#version-1180-2017-06-08 + +### What's in 1.18.0 stable + +Rust 1.18.0 is similar to many of our releases: no big bombshells, just a number +of improvements, cleanups, and new features. + +One of the largest changes is a long time coming: core team members Carol +Nichols and Steve Klabnik have been writing a new edition of "The Rust +Programming Language", the official book about Rust. It's being [written openly +on GitHub](https://github.com/rust-lang/book), and has over a hundred +contributors in total. This release [includes the first draft of the second +edition in our online documentation](https://doc.rust-lang.org/stable/book/). +19 out of 20 chapters have a draft; the draft of chapter 20 will land in the +Rust 1.19. When the book is done, a print version will be made available through +[No Starch Press](https://www.nostarch.com/Rust), if you'd like a paper copy. +While first drafts of the chapters are available, we're still working with the +editors at No Starch to improve the text, so there's more to do, but we wanted +to start getting a wider audience now. The new edition is a complete re-write +from the ground up, using the last two years of knowledge we've gained from +teaching people Rust. You'll find brand-new explanations for a lot of Rust's +core concepts, new projects to build, and all kinds of other good stuff. Please +check it out and let us know what you think! + +As for the language itself, an old feature has learned some new tricks: the +`pub` keyword has been expanded a bit. Experienced Rustaceans will know that +items are private by default in Rust, and you can use the `pub` keyword to make +them public. In Rust 1.18.0, `pub` has [gained a new +form](https://github.com/rust-lang/rust/pull/40556): + +```rust +pub(crate) bar; +``` + +The bit inside of `()` is a 'restriction', which refines the notion of how this +is made public. Using the `crate` keyword like the example above means that +`bar` would be public to the entire crate, but not outside of it. This makes it +easier to declare APIs that are "public to your crate", but not exposed to your +users. This was *possible* with the current module system, but often very awkward. + +You can also specify a path, like this: + +```rust +pub(a::b::c) foo; +``` + +This means "usable within the hierarchy of `a::b::c`, but not elsewhere." This +feature was defined in [RFC +1422](https://github.com/rust-lang/rfcs/blob/master/text/1422-pub-restricted.md) + +For our Windows users, Rust 1.18.0 has [a new attribute, +`#![windows_subsystem]`](https://github.com/rust-lang/rust/pull/40870). It +works like this: + +```rust +#![windows_subsystem(console)] +#![windows_subsystem(windows)] +``` + +These control the [`/SUBSYSTEM` flag](https://msdn.microsoft.com/en-us/library/fcc1zstk.aspx) +in the linker. For now, only `console` and `windows` are supported. + +When is this useful? In the simplest terms, if you're developing a graphical +application, and do not specify `windows`, a console window would flash up upon +your application's start. With this flag, it won't. + +Finally, Rust's tuples, enum variant fields, and structs (without `#[repr]`) have +always had an undefined layout. [We've turned on automatic re-ordering](https://github.com/rust-lang/rust/pull/40377), which can result in smaller sizes +through reducing padding. Consider a struct like this: + +```rust +struct Suboptimal(u8, u16, u8); +``` + +In previous versions of Rust on the x86_64 platform, this struct would have the +size of six bytes. But looking at the source, you'd expect it to have four. The +extra two bytes come from padding; given that we have a `u16` here, it should be +aligned to two bytes. But in this case, it's at offset one. To move it to offset +two, another byte of padding is placed after the first `u8`. To give the whole struct +a proper alignment, another byte is added after the second `u8` as well, giving us +`1 + 1 (padding) + 2 + 1 + 1 (padding) = 6 bytes`. + +But what if our struct looked like this? + +```rust +struct Optimal(u8, u8, u16); +``` + +This struct is properly aligned; the `u16` lies on a two byte boundary, and so does +the entire struct. No padding is needed. This gives us `1 + 1 + 2 = 4 bytes`. + +When designing Rust, stuff like this is why we left the details here undefined. +It allows for exactly this kind of thing: the compiler can optimize `Suboptimal` +into `Optimal` automatically. And if you check the sizes of `Suboptimal` and +`Optimal` on Rust 1.18.0, you'll see that they both have a size of four bytes. + +We've been planning this for a while; previous versions of Rust included this +optimization on the nightly channel, but some people wrote unsafe code that +assumed the exact details of the representation. We rolled it back while we fixed +all instances of this that we know about, but if you find some code breaks due to +this, you should fix it! In the meantime, there's also a flag you can use to control +this. Imagine we have `Suboptimal` in a file named `foo.rs`, along with a `main` +function that prints out its size: + +```rust +> rustc foo.rs +> ./foo +4 +> rustc foo.rs -Z fuel=foo=0 +optimization-fuel-exhausted: Reorder fields of "Suboptimal" +> ./foo +6 +``` + +This flag is based on an idea called "[Optimization +fuel](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/dfopt-popl10.pdf)": + +> It works by giving the optimizer a finite supply of optimization fuel. Each +> time a rewrite function proposes to replace a node, one unit of fuel is +> consumed. When the optimizer runs out of fuel, further rewrites are +> suppressed. + +Currently, this is the only optimization that uses the "fuel" concept. By +setting the fuel to zero, `rustc` will not perform the optimization. This can +keep your code compiling if you run into a problem, but the longer-term fix is +to use a `#[repr]` attribute to guarantee a particular layout if you rely on it. + +We've been planning on moving `rustdoc` to use a CommonMark compliant markdown +parser for a long time now. However, just switching over can introduce +regressions where the CommonMark spec differs from our existing parser, Hoedown. +As part of the transition plan, [a new flag has been added to +`rustdoc`](https://github.com/rust-lang/rust/pull/40338), `--enable-commonmark`. +This will use the new parser instead of the old one. Please give it a try! There's +no scenario we know of where tweaking your markdown gets identical results on both +parsers. + +Finally, compiling `rustc` itself is now [15%-20% faster](https://github.com/rust-lang/rust/pull/41469). Each commit message in this PR +goes over the details, but the short of it is that there were some inefficient +things, and now they've been cleaned up. + +See the [detailed release notes][notes] for more. + +#### Library stabilizations + +Seven new APIs were stabilized this release: + +- [`Child::try_wait`] is a non-blocking form of `Child::wait`. +- [`HashMap::retain`] and [`HashSet::retain`] bring the `retain` API `Vec` has to these two hash data structures. +- [`PeekMut::pop`] lets you pop stuff off of a `BinaryHeap` +- [`TcpStream::peek`], [`UdpSocket::peek`], [`UdpSocket::peek_from`] let you peek at a stream or socket. + +[`Child::try_wait`]: https://doc.rust-lang.org/std/process/struct.Child.html#method.try_wait +[`HashMap::retain`]: https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.retain +[`HashSet::retain`]: https://doc.rust-lang.org/std/collections/struct.HashSet.html#method.retain +[`PeekMut::pop`]: https://doc.rust-lang.org/std/collections/binary_heap/struct.PeekMut.html#method.pop +[`TcpStream::peek`]: https://doc.rust-lang.org/std/net/struct.TcpStream.html#method.peek +[`UdpSocket::peek_from`]: https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.peek_from +[`UdpSocket::peek`]: https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.peek + +See the [detailed release notes][notes] for more. + +#### Cargo features + +Cargo has [added support](https://github.com/rust-lang/cargo/pull/3842) for the Pijul VCS, +which is written in Rust. `cargo new my-awesome-project --vcs=pijul` will get you going! + +To suppliment the `--all` flag, Cargo now has [several new +flags](https://github.com/rust-lang/cargo/pull/3901) such as `--bins`, +`--examples`, `--tests`, and `--benches`, which will let you build all programs of +that type. + +Finally, Cargo now supports [Haiku](https://github.com/rust-lang/cargo/pull/3952) and +[Android](https://github.com/rust-lang/cargo/pull/3885)! + +See the [detailed release notes][notes] for more. + +### Contributors to 1.18.0 + +Many people came together to create Rust 1.18. We couldn't have done it without +all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.18.0) From 97c3beeff978361f5e75c40ba4e9c8cf59439b58 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Wed, 7 Jun 2017 19:02:46 -0400 Subject: [PATCH 2/3] Edits from comments --- _posts/2017-06-08-Rust-1.18.md | 43 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/_posts/2017-06-08-Rust-1.18.md b/_posts/2017-06-08-Rust-1.18.md index 2925f561c..a5d07c81e 100644 --- a/_posts/2017-06-08-Rust-1.18.md +++ b/_posts/2017-06-08-Rust-1.18.md @@ -22,7 +22,7 @@ appropriate page on our website, and check out the [detailed release notes for ### What's in 1.18.0 stable -Rust 1.18.0 is similar to many of our releases: no big bombshells, just a number +Rust 1.18.0 is similar to many of our releases: no big surprises, just a number of improvements, cleanups, and new features. One of the largest changes is a long time coming: core team members Carol @@ -31,16 +31,15 @@ Programming Language", the official book about Rust. It's being [written openly on GitHub](https://github.com/rust-lang/book), and has over a hundred contributors in total. This release [includes the first draft of the second edition in our online documentation](https://doc.rust-lang.org/stable/book/). -19 out of 20 chapters have a draft; the draft of chapter 20 will land in the -Rust 1.19. When the book is done, a print version will be made available through -[No Starch Press](https://www.nostarch.com/Rust), if you'd like a paper copy. -While first drafts of the chapters are available, we're still working with the -editors at No Starch to improve the text, so there's more to do, but we wanted +19 out of 20 chapters have a draft; the draft of chapter 20 will land in Rust +1.19. When the book is done, a print version will be made available through [No +Starch Press](https://www.nostarch.com/Rust), if you'd like a paper copy. We're +still working with the editors at No Starch to improve the text, but we wanted to start getting a wider audience now. The new edition is a complete re-write from the ground up, using the last two years of knowledge we've gained from teaching people Rust. You'll find brand-new explanations for a lot of Rust's core concepts, new projects to build, and all kinds of other good stuff. Please -check it out and let us know what you think! +check it out and [let us know what you think](https://github.com/rust-lang/book/issues/new)! As for the language itself, an old feature has learned some new tricks: the `pub` keyword has been expanded a bit. Experienced Rustaceans will know that @@ -61,12 +60,14 @@ users. This was *possible* with the current module system, but often very awkwar You can also specify a path, like this: ```rust -pub(a::b::c) foo; +pub(in a::b::c) foo; ``` This means "usable within the hierarchy of `a::b::c`, but not elsewhere." This feature was defined in [RFC 1422](https://github.com/rust-lang/rfcs/blob/master/text/1422-pub-restricted.md) +and [is documented in the +reference](https://doc.rust-lang.org/stable/reference/visibility-and-privacy.html#pubin-path-pubcrate-pubsuper-and-pubself). For our Windows users, Rust 1.18.0 has [a new attribute, `#![windows_subsystem]`](https://github.com/rust-lang/rust/pull/40870). It @@ -147,16 +148,18 @@ to use a `#[repr]` attribute to guarantee a particular layout if you rely on it. We've been planning on moving `rustdoc` to use a CommonMark compliant markdown parser for a long time now. However, just switching over can introduce -regressions where the CommonMark spec differs from our existing parser, Hoedown. -As part of the transition plan, [a new flag has been added to -`rustdoc`](https://github.com/rust-lang/rust/pull/40338), `--enable-commonmark`. -This will use the new parser instead of the old one. Please give it a try! There's -no scenario we know of where tweaking your markdown gets identical results on both -parsers. - -Finally, compiling `rustc` itself is now [15%-20% faster](https://github.com/rust-lang/rust/pull/41469). Each commit message in this PR -goes over the details, but the short of it is that there were some inefficient -things, and now they've been cleaned up. +regressions where the CommonMark spec differs from our existing parser, +Hoedown. As part of the transition plan, [a new flag has been added to +`rustdoc`](https://github.com/rust-lang/rust/pull/40338), +`--enable-commonmark`. This will use the new parser instead of the old one. +Please give it a try! As far as we know, both parsers will produce identical +results, but we'd be interested in knowing if you find a scenario where the +rendered results differ! + +Finally, compiling `rustc` itself is now [15%-20% +faster](https://github.com/rust-lang/rust/pull/41469). Each commit message in +this PR goes over the details, but the short of it is that there were some +inefficient things, and now they've been cleaned up. See the [detailed release notes][notes] for more. @@ -166,7 +169,7 @@ Seven new APIs were stabilized this release: - [`Child::try_wait`] is a non-blocking form of `Child::wait`. - [`HashMap::retain`] and [`HashSet::retain`] bring the `retain` API `Vec` has to these two hash data structures. -- [`PeekMut::pop`] lets you pop stuff off of a `BinaryHeap` +- [`PeekMut::pop`] lets you pop the top element from a `BinaryHeap` after you've already peeked at it without needing to reorder the heap a second time. - [`TcpStream::peek`], [`UdpSocket::peek`], [`UdpSocket::peek_from`] let you peek at a stream or socket. [`Child::try_wait`]: https://doc.rust-lang.org/std/process/struct.Child.html#method.try_wait @@ -184,7 +187,7 @@ See the [detailed release notes][notes] for more. Cargo has [added support](https://github.com/rust-lang/cargo/pull/3842) for the Pijul VCS, which is written in Rust. `cargo new my-awesome-project --vcs=pijul` will get you going! -To suppliment the `--all` flag, Cargo now has [several new +To supplement the `--all` flag, Cargo now has [several new flags](https://github.com/rust-lang/cargo/pull/3901) such as `--bins`, `--examples`, `--tests`, and `--benches`, which will let you build all programs of that type. From f3f9bb6726583ec9c015de974fcbc60414740cb2 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Thu, 8 Jun 2017 10:10:58 -0400 Subject: [PATCH 3/3] Addressing aturon's nits --- _posts/2017-06-08-Rust-1.18.md | 73 +++++++++++++--------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/_posts/2017-06-08-Rust-1.18.md b/_posts/2017-06-08-Rust-1.18.md index a5d07c81e..f71749478 100644 --- a/_posts/2017-06-08-Rust-1.18.md +++ b/_posts/2017-06-08-Rust-1.18.md @@ -22,8 +22,8 @@ appropriate page on our website, and check out the [detailed release notes for ### What's in 1.18.0 stable -Rust 1.18.0 is similar to many of our releases: no big surprises, just a number -of improvements, cleanups, and new features. +As usual, Rust 1.18.0 is a collection of improvements, cleanups, and new +features. One of the largest changes is a long time coming: core team members Carol Nichols and Steve Klabnik have been writing a new edition of "The Rust @@ -35,11 +35,13 @@ edition in our online documentation](https://doc.rust-lang.org/stable/book/). 1.19. When the book is done, a print version will be made available through [No Starch Press](https://www.nostarch.com/Rust), if you'd like a paper copy. We're still working with the editors at No Starch to improve the text, but we wanted -to start getting a wider audience now. The new edition is a complete re-write -from the ground up, using the last two years of knowledge we've gained from -teaching people Rust. You'll find brand-new explanations for a lot of Rust's -core concepts, new projects to build, and all kinds of other good stuff. Please -check it out and [let us know what you think](https://github.com/rust-lang/book/issues/new)! +to start getting a wider audience now. + +The new edition is a complete re-write from the ground up, using the last two +years of knowledge we've gained from teaching people Rust. You'll find +brand-new explanations for a lot of Rust's core concepts, new projects to +build, and all kinds of other good stuff. Please check it out and [let us know +what you think](https://github.com/rust-lang/book/issues/new)! As for the language itself, an old feature has learned some new tricks: the `pub` keyword has been expanded a bit. Experienced Rustaceans will know that @@ -55,7 +57,8 @@ The bit inside of `()` is a 'restriction', which refines the notion of how this is made public. Using the `crate` keyword like the example above means that `bar` would be public to the entire crate, but not outside of it. This makes it easier to declare APIs that are "public to your crate", but not exposed to your -users. This was *possible* with the current module system, but often very awkward. +users. This was *possible* with the existing module system, but often very +awkward. You can also specify a path, like this: @@ -107,44 +110,22 @@ But what if our struct looked like this? struct Optimal(u8, u8, u16); ``` -This struct is properly aligned; the `u16` lies on a two byte boundary, and so does -the entire struct. No padding is needed. This gives us `1 + 1 + 2 = 4 bytes`. - -When designing Rust, stuff like this is why we left the details here undefined. -It allows for exactly this kind of thing: the compiler can optimize `Suboptimal` -into `Optimal` automatically. And if you check the sizes of `Suboptimal` and -`Optimal` on Rust 1.18.0, you'll see that they both have a size of four bytes. - -We've been planning this for a while; previous versions of Rust included this -optimization on the nightly channel, but some people wrote unsafe code that -assumed the exact details of the representation. We rolled it back while we fixed -all instances of this that we know about, but if you find some code breaks due to -this, you should fix it! In the meantime, there's also a flag you can use to control -this. Imagine we have `Suboptimal` in a file named `foo.rs`, along with a `main` -function that prints out its size: - -```rust -> rustc foo.rs -> ./foo -4 -> rustc foo.rs -Z fuel=foo=0 -optimization-fuel-exhausted: Reorder fields of "Suboptimal" -> ./foo -6 -``` - -This flag is based on an idea called "[Optimization -fuel](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/dfopt-popl10.pdf)": +This struct is properly aligned; the `u16` lies on a two byte boundary, and so +does the entire struct. No padding is needed. This gives us `1 + 1 + 2 = 4 +bytes`. -> It works by giving the optimizer a finite supply of optimization fuel. Each -> time a rewrite function proposes to replace a node, one unit of fuel is -> consumed. When the optimizer runs out of fuel, further rewrites are -> suppressed. +When designing Rust, we left the details of memory layout undefined for just +this reason. Because we didn't commit to a particular layout, we can make +improvements to it, such as in this case where the compiler can optimize +`Suboptimal` into `Optimal` automatically. And if you check the sizes of +`Suboptimal` and `Optimal` on Rust 1.18.0, you'll see that they both have a +size of four bytes. -Currently, this is the only optimization that uses the "fuel" concept. By -setting the fuel to zero, `rustc` will not perform the optimization. This can -keep your code compiling if you run into a problem, but the longer-term fix is -to use a `#[repr]` attribute to guarantee a particular layout if you rely on it. +We've been planning this change for a while; previous versions of Rust included +this optimization on the nightly channel, but some people wrote unsafe code +that assumed the exact details of the representation. We rolled it back while +we fixed all instances of this that we know about, but if you find some code +breaks due to this, please let us know so we can help fix it! We've been planning on moving `rustdoc` to use a CommonMark compliant markdown parser for a long time now. However, just switching over can introduce @@ -158,8 +139,8 @@ rendered results differ! Finally, compiling `rustc` itself is now [15%-20% faster](https://github.com/rust-lang/rust/pull/41469). Each commit message in -this PR goes over the details, but the short of it is that there were some -inefficient things, and now they've been cleaned up. +this PR goes over the details; there were some inefficiencies, and now they've +been cleaned up. See the [detailed release notes][notes] for more.