Skip to content

Blog for Rust 1.49.0 #745

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 8 commits into from
Dec 31, 2020
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
169 changes: 169 additions & 0 deletions posts/2020-12-31-Rust-1.49.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
layout: post
title: "Announcing Rust 1.40.0"
author: The Rust Release Team
release: true
---

The Rust team is happy to announce a new version of Rust, 1.49.0. Rust is a
programming language that is empowering everyone to build reliable and
efficient software.

If you have a previous version of Rust installed via rustup, getting Rust
1.49.0 is as easy as:

```console
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.49.0][notes] on GitHub.

[install]: https://www.rust-lang.org/install.html
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1490-2020-12-31

## What's in 1.49.0 stable

For this release, we have some new targets and an improvement to the test
framework. See the [detailed release notes][notes] to learn about other
changes not covered by this post.

### aarch64 targets

We have two big changes to three targets:

* [`aarch64-unknown-linux-gnu` is now Tier 1](https://github.com/rust-lang/rust/pull/78228)
* [`aarch64-apple-darwin` is now Tier 2](https://github.com/rust-lang/rust/pull/75991)
* [`aarch64-pc-windows-msvc` is now Tier 2](https://github.com/rust-lang/rust/pull/75914)

If you're not familiar with our "tiers" of support, you can read about that
on our [platform support
page](https://doc.rust-lang.org/stable/rustc/platform-support.html). In
brief, Tier 1 is "guaranteed to work," Tier 2 is "guaranteed to build," and
Tier 3 is "code exists but is not tested." If you're a 64-bit ARM user, these
changes mean that Rust programs will work better on your platforms!

### Test framework captures output in threads

Rust's built-in testing framework doesn't have a ton of features, but that
doesn't mean it can't be improved! Consider a test that looks like this:

```rust
#[test]
fn thready_pass() {
println!("fee");
std::thread::spawn(|| {
println!("fie");
println!("foe");
})
.join()
.unwrap();
println!("fum");
}
```

Here's what running this test looks like before Rust 1.49.0:

```text
❯ cargo test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.38s
Running target\debug\deps\threadtest-02f42ffd9836cae5.exe

running 1 test
fie
foe
test thready_pass ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Doc-tests threadtest

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```

You can see that the output from the thread is printed, which intermixes
from the output of the test framework itself. Wouldn't it be nice
if every `println!` worked like that one that prints "`fum`?" Well, [that's
the behavior in Rust 1.49.0](https://github.com/rust-lang/rust/pull/78227):

```text
❯ cargo +nightly test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.52s
Running target\debug\deps\threadtest-40aabfaa345584be.exe

running 1 test
test thready_pass ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Doc-tests threadtest

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
```

But don't worry; if the test were to fail, you'll still see all of the
output. By adding a `panic!` to the end of the test, we can see what failure
looks like:

```text
❯ cargo +nightly test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.52s
Running target\debug\deps\threadtest-40aabfaa345584be.exe

running 1 test
test thready_pass ... FAILED

failures:

---- thready_pass stdout ----
fee
fie
foe
fum
thread 'thready_pass' panicked at 'explicit panic', src\lib.rs:11:5
```

Specifically, the test runner makes sure to capture the output, and saves it
in case the test fails.

### Library changes

In Rust 1.49.0, there are three new stable functions:

- [`slice::select_nth_unstable`]
- [`slice::select_nth_unstable_by`]
- [`slice::select_nth_unstable_by_key`]

And two functions were made `const`:

- [`Poll::is_ready`]
- [`Poll::is_pending`]

See the [detailed release notes][notes] to learn about other changes.

[`slice::select_nth_unstable`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.select_nth_unstable
[`slice::select_nth_unstable_by`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.select_nth_unstable_by
[`slice::select_nth_unstable_by_key`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.select_nth_unstable_by_key
[`Poll::is_ready`]: https://doc.rust-lang.org/stable/std/task/enum.Poll.html#method.is_ready
[`Poll::is_pending`]: https://doc.rust-lang.org/stable/std/task/enum.Poll.html#method.is_pending

### Other changes

[relnotes-cargo]: https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-149-2020-12-31
[relnotes-clippy]: https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-149

There are other changes in the Rust 1.49.0 release: check out what changed in
[Rust][notes], [Cargo][relnotes-cargo], and [Clippy][relnotes-clippy].

## Contributors to 1.49.0

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