Skip to content

Commit 1cfafa0

Browse files
authored
Merge pull request #952 from Mark-Simulacrum/60blog
Add 1.60.0 blog post
2 parents c77cf12 + ffc8e26 commit 1cfafa0

File tree

2 files changed

+10336
-0
lines changed

2 files changed

+10336
-0
lines changed

posts/2022-04-07-Rust-1.60.0.md

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
---
2+
layout: post
3+
title: "Announcing Rust 1.60.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.60.0. Rust is a programming language empowering everyone to build reliable and efficient software.
9+
10+
If you have a previous version of Rust installed via rustup, you can get 1.60.0 with:
11+
12+
```console
13+
rustup update stable
14+
```
15+
16+
If you don't have it already, you can [get `rustup`][install]
17+
from the appropriate page on our website, and check out the
18+
[detailed release notes for 1.60.0][notes] on GitHub.
19+
If you'd like to help us out by testing future releases, you might consider updating locally to use
20+
the beta channel (`rustup default beta`) or the nightly channel (`rustup default nightly`). Please [report] any bugs you might come across!
21+
22+
[install]: https://www.rust-lang.org/install.html
23+
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1600-2022-04-07
24+
[report]: https://github.com/rust-lang/rust/issues/new/choose
25+
26+
## What's in 1.60.0 stable
27+
28+
### Source-based Code Coverage
29+
30+
Support for LLVM-based coverage instrumentation has been stabilized in rustc. You can try this out on your code by rebuilding your code with `-Cinstrument-coverage`, for example like this:
31+
32+
```shell=
33+
RUSTFLAGS="-C instrument-coverage" cargo build
34+
```
35+
36+
After that, you can run the resulting binary, which will produce a
37+
`default.profraw` file in the current directory. (The path and filename can be
38+
overriden by an environment variable; see
39+
[documentation](https://doc.rust-lang.org/stable/rustc/instrument-coverage.html#running-the-instrumented-binary-to-generate-raw-coverage-profiling-data)
40+
for details).
41+
42+
The `llvm-tools-preview` component includes `llvm-profdata` for processing and
43+
merging raw profile output (coverage region execution counts); and `llvm-cov`
44+
for report generation. `llvm-cov` combines the processed output, from
45+
`llvm-profdata`, and the binary itself, because the binary embeds a mapping from
46+
counters to actual source code regions.
47+
48+
```shell=
49+
rustup component add llvm-tools-preview
50+
$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -sparse default.profraw -o default.profdata
51+
$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov show -Xdemangler=rustfilt target/debug/coverage-testing \
52+
-instr-profile=default.profdata \
53+
-show-line-counts-or-regions \
54+
-show-instantiations
55+
```
56+
57+
The above commands on a simple helloworld binary produce this annotated report, showing that each line of the input was covered.
58+
59+
```
60+
1| 1|fn main() {
61+
2| 1| println!("Hello, world!");
62+
3| 1|}
63+
```
64+
65+
For more details, please read the
66+
[documentation](https://doc.rust-lang.org/rustc/instrument-coverage.html) in the
67+
rustc book. The baseline functionality is stable and will exist in some form
68+
in all future Rust releases, but the specific output format and LLVM tooling which
69+
produces it are subject to change. For this reason, it is important to make
70+
sure that you use the same version for both the `llvm-tools-preview` and the
71+
rustc binary used to compile your code.
72+
73+
### `cargo --timings`
74+
75+
Cargo has stabilized support for collecting information on build with the `--timings` flag.
76+
77+
```shell
78+
$ cargo build --timings
79+
Compiling hello-world v0.1.0 (hello-world)
80+
Timing report saved to target/cargo-timings/cargo-timing-20220318T174818Z.html
81+
Finished dev [unoptimized + debuginfo] target(s) in 0.98s
82+
```
83+
84+
The report is also copied to `target/cargo-timings/cargo-timing.html`. A report on the release build of Cargo has been put up [here](/images/2022-04-07-timing.html). These reports can be useful for improving build performance.
85+
More information about the timing reports may be found in the [documentation](https://doc.rust-lang.org/nightly/cargo/reference/timings.html).
86+
87+
### New syntax for Cargo features
88+
89+
This release introduces two new changes to improve support for [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html) and how they interact with [optional dependencies](https://doc.rust-lang.org/cargo/reference/features.html#optional-dependencies): Namespaced dependencies and weak dependency features.
90+
91+
Cargo has long supported features along with optional dependencies, as illustrated by the snippet below.
92+
93+
```toml
94+
[dependencies]
95+
jpeg-decoder = { version = "0.1.20", default-features = false, optional = true }
96+
97+
[features]
98+
# Enables parallel processing support by enabling the "rayon" feature of jpeg-decoder.
99+
parallel = ["jpeg-decoder/rayon"]
100+
```
101+
102+
There are two things to note in this example:
103+
* The optional dependency `jpeg-decoder` implicitly defines a feature of the same name. Enabling the `jpeg-decoder` feature will enable the `jpeg-decoder` dependency.
104+
* The `"jpeg-decoder/rayon"` syntax enables the `jpeg-decoder` dependency *and* enables the `jpeg-decoder` dependency's `rayon` feature.
105+
106+
Namespaced features tackles the first issue. You can now use the `dep:` prefix in the `[features]` table to explicitly refer to an optional dependency without implicitly exposing it as a feature. This gives you more control on how to define the feature corresponding to the optional dependency including hiding optional dependencies behind more descriptive feature names.
107+
108+
Weak dependency features tackle the second issue where the `"optional-dependency/feature-name"` syntax would always enable `optional-dependency`. However, often you want to enable the feature on the optional dependency *only* if some other feature has enabled the optional dependency. Starting in 1.60, you can add a ? as in `"package-name?/feature-name"` which will only enable the given feature if something else has enabled the optional dependency.
109+
110+
For example, let's say we have added some serialization support to our library, and it requires enabling a corresponding feature in some optional dependencies. That can be done like this:
111+
112+
```toml
113+
[dependencies]
114+
serde = { version = "1.0.133", optional = true }
115+
rgb = { version = "0.8.25", optional = true }
116+
117+
[features]
118+
serde = ["dep:serde", "rgb?/serde"]
119+
```
120+
121+
In this example, enabling the serde feature will enable the serde dependency. It will also enable the serde feature for the rgb dependency, but only if something else has enabled the rgb dependency.
122+
123+
### Incremental compilation status
124+
125+
Incremental compilation is re-enabled for the 1.60 release. The Rust team continues to work on fixing bugs in incremental, but no problems causing widespread breakage are known at this time, so we have chosen to reenable incremental compilation. Additionally, the compiler team is continuing to work on long-term strategy to avoid future problems of this kind. That process is in relatively early days, so we don't have anything to share yet on that front.
126+
127+
### `Instant` monotonicity guarantees
128+
129+
On all platforms `Instant` will try to use an OS API that guarantees monotonic
130+
behavior if available (which is the case on all tier 1 platforms). In practice
131+
such guarantees are -- under rare circumstances -- broken by hardware,
132+
virtualization, or operating system bugs. To work around these bugs and platforms
133+
not offering monotonic clocks, `Instant::duration_since`, `Instant::elapsed` and
134+
`Instant::sub` now saturate to zero. In older Rust versions this led to a panic
135+
instead. `Instant::checked_duration_since` can be used to detect and handle
136+
situations where monotonicity is violated, or `Instant`s are subtracted in the
137+
wrong order.
138+
139+
This workaround obscures programming errors where earlier and later instants are
140+
accidentally swapped. For this reason future Rust versions may reintroduce
141+
panics in at least those cases, if possible and efficient.
142+
143+
Prior to 1.60, the monotonicity guarantees were provided through mutexes or
144+
atomics in std, which can introduce large performance overheads to
145+
`Instant::now()`. Additionally, the panicking behavior meant that Rust software
146+
could panic in a subset of environments, which was largely undesirable, as the
147+
authors of that software may not be able to fix or upgrade the operating system,
148+
hardware, or virtualization system they are running on. Further, introducing
149+
unexpected panics into these environments made Rust software less reliable and
150+
portable, which is of higher concern than exposing typically uninteresting
151+
platform bugs in monotonic clock handling to end users.
152+
153+
### Stabilized APIs
154+
155+
The following methods and trait implementations are now stabilized:
156+
157+
- [`Arc::new_cyclic`][arc_new_cyclic]
158+
- [`Rc::new_cyclic`][rc_new_cyclic]
159+
- [`slice::EscapeAscii`][slice_escape_ascii]
160+
- [`<[u8]>::escape_ascii`][slice_u8_escape_ascii]
161+
- [`u8::escape_ascii`][u8_escape_ascii]
162+
- [`Vec::spare_capacity_mut`][vec_spare_capacity_mut]
163+
- [`MaybeUninit::assume_init_drop`][assume_init_drop]
164+
- [`MaybeUninit::assume_init_read`][assume_init_read]
165+
- [`i8::abs_diff`][i8_abs_diff]
166+
- [`i16::abs_diff`][i16_abs_diff]
167+
- [`i32::abs_diff`][i32_abs_diff]
168+
- [`i64::abs_diff`][i64_abs_diff]
169+
- [`i128::abs_diff`][i128_abs_diff]
170+
- [`isize::abs_diff`][isize_abs_diff]
171+
- [`u8::abs_diff`][u8_abs_diff]
172+
- [`u16::abs_diff`][u16_abs_diff]
173+
- [`u32::abs_diff`][u32_abs_diff]
174+
- [`u64::abs_diff`][u64_abs_diff]
175+
- [`u128::abs_diff`][u128_abs_diff]
176+
- [`usize::abs_diff`][usize_abs_diff]
177+
- [`Display for io::ErrorKind`][display_error_kind]
178+
- [`From<u8> for ExitCode`][from_u8_exit_code]
179+
- [`Not for !` (the "never" type)][not_never]
180+
- [_Op_`Assign<$t> for Wrapping<$t>`][wrapping_assign_ops]
181+
- [`arch::is_aarch64_feature_detected!`][is_aarch64_feature_detected]
182+
183+
### Other changes
184+
185+
There are other changes in the Rust 1.60.0 release. Check out what changed in
186+
[Rust](https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1600-2022-04-07),
187+
[Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-160-2022-04-07),
188+
and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-160).
189+
190+
### Contributors to 1.60.0
191+
192+
Many people came together to create Rust 1.60.0.
193+
We couldn't have done it without all of you.
194+
[Thanks!](https://thanks.rust-lang.org/rust/1.60.0/)
195+
196+
[arc_new_cyclic]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.new_cyclic
197+
[rc_new_cyclic]: https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.new_cyclic
198+
[slice_escape_ascii]: https://doc.rust-lang.org/stable/std/slice/struct.EscapeAscii.html
199+
[slice_u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.escape_ascii
200+
[u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.escape_ascii
201+
[vec_spare_capacity_mut]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.spare_capacity_mut
202+
[assume_init_drop]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_drop
203+
[assume_init_read]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_read
204+
[i8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.abs_diff
205+
[i16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.abs_diff
206+
[i32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.abs_diff
207+
[i64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.abs_diff
208+
[i128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.abs_diff
209+
[isize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.abs_diff
210+
[u8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.abs_diff
211+
[u16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.abs_diff
212+
[u32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.abs_diff
213+
[u64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.abs_diff
214+
[u128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.abs_diff
215+
[usize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.abs_diff
216+
[display_error_kind]: https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#impl-Display
217+
[from_u8_exit_code]: https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html#impl-From%3Cu8%3E
218+
[not_never]: https://doc.rust-lang.org/stable/std/primitive.never.html#impl-Not
219+
[wrapping_assign_ops]: https://doc.rust-lang.org/stable/std/num/struct.Wrapping.html#trait-implementations
220+
[is_aarch64_feature_detected]: https://doc.rust-lang.org/stable/std/arch/macro.is_aarch64_feature_detected.html

0 commit comments

Comments
 (0)