The Rust team is happy to announce a new version of Rust, 1.73.0. Rust is a programming language empowering everyone to build reliable and efficient software.
If you have a previous version of Rust installed via rustup, you can get 1.73.0 with:
$ 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.73.0 on GitHub.
If you'd like to help us out by testing future releases, you might consider updating locally to use the beta channel (rustup default beta
) or the nightly channel (rustup default nightly
). Please report any bugs you might come across!
What's in 1.73.0 stable
Cleaner panic messages
The output produced by the default panic handler has been changed to put the panic message on its own line instead of wrapping it in quotes. This can make panic messages easier to read, as shown in this example:
fn main() {
let file = "ferris.txt";
panic!("oh no! {file:?} not found!");
}
Output before Rust 1.73:
thread 'main' panicked at 'oh no! "ferris.txt" not found!', src/main.rs:3:5
Output starting in Rust 1.73:
thread 'main' panicked at src/main.rs:3:5:
oh no! "ferris.txt" not found!
This is especially useful when the message is long, contains nested quotes, or spans multiple lines.
Additionally, the panic messages produced by assert_eq
and assert_ne
have
been modified, moving the custom message (the third argument)
and removing some unnecessary punctuation, as shown below:
fn main() {
assert_eq!("🦀", "🐟", "ferris is not a fish");
}
Output before Rust 1.73:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `"🦀"`,
right: `"🐟"`: ferris is not a fish', src/main.rs:2:5
Output starting in Rust 1.73:
thread 'main' panicked at src/main.rs:2:5:
assertion `left == right` failed: ferris is not a fish
left: "🦀"
right: "🐟"
Thread local initialization
As proposed in RFC 3184, LocalKey<Cell<T>>
and LocalKey<RefCell<T>>
can now be directly manipulated with get()
, set()
, take()
, and replace()
methods, rather than jumping through a with(|inner| ...)
closure as needed for general LocalKey
work. LocalKey<T>
is the type of thread_local!
statics.
The new methods make common code more concise and avoid running the extra initialization code for the default value specified in thread_local!
for new threads.
thread_local! {
static THINGS: Cell<Vec<i32>> = Cell::new(Vec::new());
}
fn f() {
// before:
THINGS.with(|i| i.set(vec![1, 2, 3]));
// now:
THINGS.set(vec![1, 2, 3]);
// ...
// before:
let v = THINGS.with(|i| i.take());
// now:
let v: Vec<i32> = THINGS.take();
}
Stabilized APIs
- Unsigned
{integer}::div_ceil
- Unsigned
{integer}::next_multiple_of
- Unsigned
{integer}::checked_next_multiple_of
std::ffi::FromBytesUntilNulError
std::os::unix::fs::chown
std::os::unix::fs::fchown
std::os::unix::fs::lchown
LocalKey::<Cell<T>>::get
LocalKey::<Cell<T>>::set
LocalKey::<Cell<T>>::take
LocalKey::<Cell<T>>::replace
LocalKey::<RefCell<T>>::with_borrow
LocalKey::<RefCell<T>>::with_borrow_mut
LocalKey::<RefCell<T>>::set
LocalKey::<RefCell<T>>::take
LocalKey::<RefCell<T>>::replace
These APIs are now stable in const contexts:
Other changes
Check out everything that changed in Rust, Cargo, and Clippy.
Contributors to 1.73.0
Many people came together to create Rust 1.73.0. We couldn't have done it without all of you. Thanks!