Skip to content

Draft of 1.24 announcement #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions _posts/2018-02-15-Rust-1.24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
layout: post
title: "Announcing Rust 1.24"
author: The Rust Core Team
---

The Rust team is happy to announce a new version of Rust, 1.24.0. Rust is a
systems programming language focused on safety, speed, and concurrency.

If you have a previous version of Rust installed via rustup, getting Rust
1.24.0 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.24.0][notes] on GitHub.

[install]: https://www.rust-lang.org/install.html
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1240-2018-02-15

## What's in 1.24.0 stable

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

#### `rustfmt`

For years now, we've wanted a tool that automatically can reformat your Rust code to some sort
of "standard style." With this release, we're happy to announce that a *preview* of `rustfmt`
can be used with 1.24 stable. Before we get into the details, here's how to install `rustfmt`:

```bash
$ rustup component add rustfmt-preview
```

Notably, you should *not* install `rustfmt` through `cargo install`. Why not? Well, `rustfmt`
relies on using the compiler as a library to do its job. As such, the exact right version of
`rustfmt` for the exact compiler version you're using is critical, otherwise, it will not work.
`rustup` knows what compiler version you're using, and so is able to pair it with the correct
`rustfmt` version. Once you've added this component to a given toolchain, `rustup` will
automatically update it as well. Run the command once, and then on every future
`rustup update stable`, `rustfmt-preview` will be updated as well.

> This strategy is expected to be used for other developer tools that integrate tightly with
> the compiler, like the RLS and Clippy, in the future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already do this for RLS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but we've never talked about it before, so i phrased it that way


Finally, please take note of that `-preview` in the name: `rustfmt` is still not quite
at 1.0 yet. Some tweaks to the default styles are still occuring, though they're relatively
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/occuring/occurring/

minor. Once `rustfmt` hits 1.0, we'll be releasing a `rustfmt` component and
deprecating `rustfmt-preview`. Since this is the first major component we're distributing
this way, we wanted to clearly signal that it is still developing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MIght want to say something about this will happen without any user interaction - rustup will handle it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and it's the second component - you also have to use rls-preview

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above; we've never talked about rls-preview


For more, please check out [`rustfmt` on GitHub](https://github.com/rust-lang-nursery/rustfmt).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to say that if you've previously installed rustfmt with Cargo then you'll have to remove it, but that rustup should tell you about that.


#### Incremental compilation

Back in September, we blogged about [Incremental Compilation](https://blog.rust-lang.org/2016/09/08/incremental.html).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this post is from September 2016 (!) already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we say anything about the expected performance wins?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It very much depends on what you are compiling and what changes you made. "twice as fast" seems to be a good bet, looking at http://perf.rust-lang.org. For cargo check it might be different (better, hopefully) but we don't track that on perf.rlo yet.

While that post goes into the details, the idea is basically this: when you're working on
a project, you often compile it, then change something small, then compile again. Historically,
the compiler has compiled your *entire* project, no matter how little you've changed the code.
The idea with incremental compilation is that you only need to compile the code you've actually
changed, which means that that second build is faster.

As of Rust 1.24, this is now [turned on by default](https://github.com/rust-lang/cargo/pull/4817).
This means that your builds should get faster!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that cargo check should be used to get the best possible edit-compile cycle; can reference previous release announcement about that. I don't think we've done enough advertising of this as the recommended workflow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we have documentation somewhere that says when cargo defaults to incr. comp. and when it doesn't?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't believe we do


This is still not the end story for compiler performance generally, nor incremental compilation
specifically. We have a lot more work planned in the future. For example, another change
related to performance hit stable this release:
[`codegen-units` is now set to 16 by default](https://github.com/rust-lang/rust/pull/46910).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth mentioning that this will likely make builds faster, but final products slower.

More to come!

#### Other good stuff

There's one other change we'd like to talk about here: undefined behavior. Rust generally
strives to minimize undefined behavior, having none of it in safe code, and as little as
possible in unsafe code. One area where you could invoke UB is when a `panic!` goes
across an FFI boundary. In other words, this:

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

This cannot work, as the exact mechanism of how panics work would have to be reconciled
with how the `"C"` ABI works, in this example, or any other ABI in other examples.

In Rust 1.24, [this code will now abort](https://github.com/rust-lang/rust/pull/46833)
instead of producing undefined behavior.

See the [detailed release notes][notes] for more.

### Library stabilizations

If you're a fan of `str::find`, used to find a given `char` inside of a `&str`, you'll be

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to put which is in front of used. I had to reread the sentence a few times thinking the wording was a typo

happy to see this pull request: [it's now 10x faster](https://github.com/rust-lang/rust/pull/46735)!
This is thanks to `memchr`. `[u8]::contains` [uses it too](https://github.com/rust-lang/rust/pull/46713),
though it doesn't get such an extreme speedup.

Additionally, a few new APIs were stabilized this release:

* [`RefCell::replace`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.replace)
* [`RefCell::swap`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.swap)
* [`std::sync::atomic::spin_loop_hint`](https://doc.rust-lang.org/std/sync/atomic/fn.spin_loop_hint.html)

Finally, these functions may now be used inside a constant expression, for example, to initialize a `static`:

* `Cell`, `RefCell`, and `UnsafeCell`'s `new` functions
* The `new` functions of the various `Atomic` integer types
* `{integer}::min_value` and `max_value`
* `mem`'s `size_of` and `align_of`
* `ptr::null` and `null_mut`

See the [detailed release notes][notes] for more.

### Cargo features

The big feature of this release was turning on incremental compilation by default, as mentioned above.

See the [detailed release notes][notes] for more.

## Contributors to 1.24.0

Many people came together to create Rust 1.24. We couldn't have done it
without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.24.0)