Skip to content

Commit 1d02ae9

Browse files
committed
Rust 1.62.0
1 parent 4842952 commit 1d02ae9

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

posts/2022-06-30-Rust-1.62.0.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Rust 1.62.0
2+
3+
---
4+
layout: post
5+
title: "Announcing Rust 1.62.0"
6+
author: The Rust Release Team
7+
release: true
8+
---
9+
10+
The Rust team is happy to announce a new version of Rust, 1.62.0. Rust is a programming language
11+
empowering everyone to build reliable and efficient software.
12+
13+
If you have a previous version of Rust installed via rustup, you can get 1.62.0 with:
14+
15+
```console
16+
rustup update stable
17+
```
18+
19+
If you don't have it already, you can [get `rustup`][install]
20+
from the appropriate page on our website, and check out the
21+
[detailed release notes for 1.62.0][notes] on GitHub.
22+
23+
If you'd like to help us out by testing future releases, you might consider updating locally to use
24+
the beta channel (`rustup default beta`) or the nightly channel (`rustup default nightly`).
25+
Please [report] any bugs you might come across!
26+
27+
[install]: https://www.rust-lang.org/install.html
28+
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1620-2022-06-30
29+
[report]: https://github.com/rust-lang/rust/issues/new/choose
30+
31+
## What's in 1.62.0 stable
32+
33+
### `cargo add`
34+
35+
You can now add new dependencies directly from the command line using `cargo add`. This command supports specifying features and versions. It can also be used to modify existing dependencies.
36+
37+
For example:
38+
39+
```console
40+
cargo add log
41+
cargo add serde --features derive
42+
cargo add nom@5
43+
```
44+
45+
See the [cargo documentation](https://doc.rust-lang.org/nightly/cargo/commands/cargo-add.html) for more.
46+
47+
### `#[default]` enum variants
48+
49+
You can now use `#[derive(Default)]` on enums if you specify a default variant. For example, until now you would have to manually write a `Default` impl for this enum:
50+
51+
52+
```rust
53+
#[derive(Default)]
54+
enum Maybe<T> {
55+
#[default]
56+
Nothing,
57+
58+
Something(T),
59+
}
60+
```
61+
62+
As of now only "unit" variants (variants that have no fields) are allowed to be marked `#[default]`. More information is available in the [RFC](https://rust-lang.github.io/rfcs/3107-derive-default-enum.html) for this feature.
63+
64+
### Thinner, faster mutexes on Linux
65+
66+
Previously, `Mutex`, `Condvar`, and `RwLock` were backed by the pthreads library on Linux. The pthreads locks support more features than the Rust APIs themselves do, including runtime configuration, and are designed to be used in languages with fewer static guarantees than Rust provides.
67+
68+
The mutex implementation, for example, is 40 bytes and cannot be moved. This forced us the standard library to allocate a `Box` behind the scenes for each new mutex for platforms that use pthreads.
69+
70+
Rust's standard library now ships with a raw futex-based implementation of these locks on Linux, which is very lightweight and doesn't require extra allocation. In 1.62.0 `Mutex` only needs 5 bytes for its internal state on Linux, though this may change in future versions.
71+
72+
This is part of a long effort to improve the efficiency of Rust's lock types, which includes previous improvements on Windows such as unboxing its primitives. You can read more about that effort in the [tracking issue](https://github.com/rust-lang/rust/issues/93740).
73+
74+
### Bare metal `x86_64` target
75+
76+
It's now easier to build OS-less binaries for `x86_64`, for example when writing a kernel. `x86_64-unknown-none` has been promoted to a Tier 2 target and can be installed with rustup.
77+
78+
```console
79+
rustup target add x86_64-unknown-none
80+
rustc --target x86_64-unknown-none my_no_std_program.rs
81+
```
82+
83+
You can read more about development using `no_std` in the [Embedded Rust book](https://docs.rust-embedded.org/book/intro/no-std.html).
84+
85+
### Stabilized APIs
86+
87+
The following methods and trait implementations are now stabilized:
88+
89+
- [`bool::then_some`]
90+
- [`f32::total_cmp`]
91+
- [`f64::total_cmp`]
92+
- [`Stdin::lines`]
93+
- [`windows::CommandExt::raw_arg`]
94+
- [`impl<T: Default> Default for AssertUnwindSafe<T>`]
95+
- [`From<Rc<str>> for Rc<[u8]>`][rc-u8-from-str]
96+
- [`From<Arc<str>> for Arc<[u8]>`][arc-u8-from-str]
97+
- [`FusedIterator for EncodeWide`]
98+
- [RDM intrinsics on aarch64][stdarch/1285]
99+
100+
### Other changes
101+
102+
There are other changes in the Rust 1.62.0 release. Check out what changed in
103+
[Rust](https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1620-2022-06-30),
104+
[Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-1620-2022-06-30),
105+
and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-162).
106+
107+
### Contributors to 1.62.0
108+
109+
Many people came together to create Rust 1.62.0.
110+
We couldn't have done it without all of you.
111+
[Thanks!](https://thanks.rust-lang.org/rust/1.62.0/)
112+
113+
[`bool::then_some`]: https://doc.rust-lang.org/stable/std/primitive.bool.html#method.then_some
114+
[`f32::total_cmp`]: https://doc.rust-lang.org/stable/std/primitive.f32.html#method.total_cmp
115+
[`f64::total_cmp`]: https://doc.rust-lang.org/stable/std/primitive.f64.html#method.total_cmp
116+
[`Stdin::lines`]: https://doc.rust-lang.org/stable/std/io/struct.Stdin.html#method.lines
117+
[`impl<T: Default> Default for AssertUnwindSafe<T>`]: https://doc.rust-lang.org/stable/std/panic/struct.AssertUnwindSafe.html#impl-Default
118+
[rc-u8-from-str]: https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#impl-From%3CRc%3Cstr%3E%3E
119+
[arc-u8-from-str]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#impl-From%3CArc%3Cstr%3E%3E
120+
[stdarch/1285]: https://github.com/rust-lang/stdarch/pull/1285
121+
[`windows::CommandExt::raw_arg`]: https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg
122+
[`FusedIterator for EncodeWide`]: https://doc.rust-lang.org/stable/std/os/windows/ffi/struct.EncodeWide.html#impl-FusedIterator

0 commit comments

Comments
 (0)