Skip to content

Commit a1b5d8a

Browse files
authored
Merge pull request #993 from tmandry/rust-1-62
Rust 1.62.0 blog post
2 parents 2bfe9ac + 452900f commit a1b5d8a

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

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

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

0 commit comments

Comments
 (0)