Skip to content

Commit aa44f3d

Browse files
committed
Draft of 1.24
1 parent 14d7933 commit aa44f3d

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

_posts/2018-02-15-Rust-1.24.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
layout: post
3+
title: "Announcing Rust 1.24"
4+
author: The Rust Core Team
5+
---
6+
7+
The Rust team is happy to announce a new version of Rust, 1.24.0. Rust is a
8+
systems programming language focused on safety, speed, and concurrency.
9+
10+
If you have a previous version of Rust installed via rustup, getting Rust
11+
1.24.0 is as easy as:
12+
13+
```bash
14+
$ rustup update stable
15+
```
16+
17+
If you don't have it already, you can [get `rustup`][install] from the
18+
appropriate page on our website, and check out the [detailed release notes for
19+
1.24.0][notes] on GitHub.
20+
21+
[install]: https://www.rust-lang.org/install.html
22+
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1240-2018-02-15
23+
24+
## What's in 1.24.0 stable
25+
26+
This release contains two very exciting new features: `rustfmt` and incremental compilation!
27+
28+
#### `rustfmt`
29+
30+
For years now, we've wanted a tool that automatically can reformat your Rust code to some sort
31+
of "standard style." With this release, we're happy to announce that a *preview* of `rustfmt`
32+
can be used with 1.24 stable. Before we get into the details, here's how to install `rustfmt`:
33+
34+
```bash
35+
$ rustup component add rustfmt-preview
36+
```
37+
38+
Notably, you should *not* install `rustfmt` through `cargo install`. Why not? Well, `rustfmt`
39+
relies on using the compiler as a library to do its job. As such, the exact right version of
40+
`rustfmt` for the exact compiler version you're using is critical, otherwise, it will not work.
41+
`rustup` knows what compiler version you're using, and so is able to pair it with the correct
42+
`rustfmt` version. Once you've added this component to a given toolchain, `rustup` will
43+
automatically update it as well. Run the command once, and then on every future
44+
`rustup update stable`, `rustfmt-preview` will be updated as well.
45+
46+
> This strategy is expected to be used for other developer tools that integrate tightly with
47+
> the compiler, like the RLS and Clippy, in the future.
48+
49+
Finally, please take note of that `-preview` in the name: `rustfmt` is still not quite
50+
at 1.0 yet. Some tweaks to the default styles are still occuring, though they're relatively
51+
minor. Once `rustfmt` hits 1.0, we'll be releasing a `rustfmt` component and
52+
deprecating `rustfmt-preview`. Since this is the first major component we're distributing
53+
this way, we wanted to clearly signal that it is still developing.
54+
55+
For more, please check out [`rustfmt` on GitHub](https://github.com/rust-lang-nursery/rustfmt).
56+
57+
#### Incremental compilation
58+
59+
Back in September, we blogged about [Incremental Compilation](https://blog.rust-lang.org/2016/09/08/incremental.html).
60+
While that post goes into the details, the idea is basically this: when you're working on
61+
a project, you often compile it, then change something small, then compile again. Historically,
62+
the compiler has compiled your *entire* project, no matter how little you've changed the code.
63+
The idea with incremental compilation is that you only need to compile the code you've actually
64+
changed, which means that that second build is faster.
65+
66+
As of Rust 1.24, this is now [turned on by default](https://github.com/rust-lang/cargo/pull/4817).
67+
This means that your builds should get faster!
68+
69+
This is still not the end story for compiler performance generally, nor incremental compilation
70+
specifically. We have a lot more work planned in the future. For example, another change
71+
related to performance hit stable this release:
72+
[`codegen-units` is now set to 16 by default](https://github.com/rust-lang/rust/pull/46910).
73+
More to come!
74+
75+
#### Other good stuff
76+
77+
There's one other change we'd like to talk about here: undefined behavior. Rust generally
78+
strives to minimize undefined behavior, having none of it in safe code, and as little as
79+
possible in unsafe code. One area where you could invoke UB is when a `panic!` goes
80+
across an FFI boundary. In other words, this:
81+
82+
```rust
83+
extern "C" fn panic_in_ffi() {
84+
panic!("Test");
85+
}
86+
```
87+
88+
This cannot work, as the exact mechanism of how panics work would have to be reconciled
89+
with how the `"C"` ABI works, in this example, or any other ABI in other examples.
90+
91+
In Rust 1.24, [this code will now abort](https://github.com/rust-lang/rust/pull/46833)
92+
instead of producing undefined behavior.
93+
94+
See the [detailed release notes][notes] for more.
95+
96+
### Library stabilizations
97+
98+
If you're a fan of `str::find`, used to find a given `char` inside of a `&str`, you'll be
99+
happy to see this pull request: [it's now 10x faster](https://github.com/rust-lang/rust/pull/46735)!
100+
This is thanks to `memchr`. `[u8]::contains` [uses it too](https://github.com/rust-lang/rust/pull/46713),
101+
though it doesn't get such an extreme speedup.
102+
103+
Additionally, a few new APIs were stabilized this release:
104+
105+
* [`RefCell::replace`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.replace)
106+
* [`RefCell::swap`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.swap)
107+
* [`std::sync::atomic::spin_loop_hint`](https://doc.rust-lang.org/std/sync/atomic/fn.spin_loop_hint.html)
108+
109+
Finally, these functions may now be used inside a constant expression, for example, to initialize a `static`:
110+
111+
* `Cell`, `RefCell`, and `UnsafeCell`'s `new` functions
112+
* The `new` functions of the various `Atomic` integer types
113+
* `{integer}::min_value` and `max_value`
114+
* `mem`'s `size_of` and `align_of`
115+
* `ptr::null` and `null_mut`
116+
117+
See the [detailed release notes][notes] for more.
118+
119+
### Cargo features
120+
121+
The big feature of this release was turning on incremental compilation by default, as mentioned above.
122+
123+
See the [detailed release notes][notes] for more.
124+
125+
## Contributors to 1.24.0
126+
127+
Many people came together to create Rust 1.24. We couldn't have done it
128+
without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.24.0)

0 commit comments

Comments
 (0)