Announcing Rust 1.33.0


Feb. 28, 2019 · The Rust Release Team

The Rust team is happy to announce a new version of Rust, 1.33.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.33.0 is as easy as:

$ rustup update stable

If you don't have it already, you can get rustup from the appropriate page on our website, and check out the detailed release notes for 1.33.0 on GitHub.

What's in 1.33.0 stable

The two largest features in this release are significant improvements to const fns, and the stabilization of a new concept: "pinning."

const fn improvements

With const fn, you can now do way more things! Specifically:

  • irrefutable destructuring patterns (e.g. const fn foo((x, y): (u8, u8)) { ... })
  • let bindings (e.g. let x = 1;)
  • mutable let bindings (e.g. let mut x = 1;)
  • assignment (e.g. x = y) and assignment operator (e.g. x += y) expressions, even where the assignment target is a projection (e.g. a struct field or index operation like x[3] = 42)
  • expression statements (e.g. 3;)

You're also able to call const unsafe fns inside a const fn, like this:

const unsafe fn foo() -> i32 { 5 }
const fn bar() -> i32 { unsafe { foo() }
}

With these additions, many more functions in the standard library are able to be marked as const. We'll enumerate those in the library section below.

Pinning

This release introduces a new concept for Rust programs, implemented as two types: the std::pin::Pin<P> type, and the Unpin marker trait. The core idea is elaborated on in the docs for std::pin:

It is sometimes useful to have objects that are guaranteed to not move, in the sense that their placement in memory does not change, and can thus be relied upon. A prime example of such a scenario would be building self-referential structs, since moving an object with pointers to itself will invalidate them, which could cause undefined behavior.

A Pin<P> ensures that the pointee of any pointer type P has a stable location in memory, meaning it cannot be moved elsewhere and its memory cannot be deallocated until it gets dropped. We say that the pointee is "pinned".

This feature will largely be used by library authors, and so we won't talk a lot more about the details here. Consult the docs if you're interested in digging into the details. However, the stabilization of this API is important to Rust users generally because it is a significant step forward towards a highly anticipated Rust feature: async/await. We're not quite there yet, but this stabilization brings us one step closer. You can track all of the necessary features at areweasyncyet.rs.

Import as _

You can now import an item as _. This allows you to import a trait's impls, and not have the name in the namespace. e.g.

use std::io::Read as _; // Allowed as there is only one `Read` in the module.
pub trait Read {}

See the detailed release notes for more details.

Library stabilizations

Here's all of the stuff that's been made const:

Additionally, these APIs have become stable:

See the detailed release notes for more details.

Cargo features

Cargo should now rebuild a crate if a file was modified during the initial build.

See the detailed release notes for more.

Crates.io

As previously announced, coinciding with this release, crates.io will require that you have a verified email address to publish. Starting at 2019-03-01 00:00 UTC, if you don't have a verified email address and run cargo publish, you'll get an error.

This ensures we can comply with DMCA procedures. If you haven't heeded the warnings cargo printed during the last release cycle, head on over to crates.io/me to set and verify your email address. This email address will never be displayed publicly and will only be used for crates.io operations.

Contributors to 1.33.0

Many people came together to create Rust 1.33.0. We couldn't have done it without all of you.