Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 1.60.0 blog post #952

Merged
merged 11 commits into from
Apr 7, 2022
172 changes: 172 additions & 0 deletions posts/2022-04-07-Rust-1.60.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
---
layout: post
title: "Announcing Rust 1.60.0"
author: The Rust Release Team
release: true
---

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.

If you have a previous version of Rust installed via rustup, you can get 1.60.0 with:

```console
rustup update stable
```

If you don't have it already, you can [get `rustup`][install]
from the appropriate page on our website, and check out the
[detailed release notes for 1.60.0][notes] 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!

[install]: https://www.rust-lang.org/install.html
[notes]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1600-2022-04-07
[report]: https://github.com/rust-lang/rust/issues/new/choose

## What's in 1.60.0 stable

### Instrumentation-based Code Coverage
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

Support for LLVM-based coverage instrumentation has been stabilized in rustc, enabled with `-C instrument-coverage`. You can try this out on your code by rebuilding your code with `-Cinstrument-coverage`:
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

```shell=
RUSTFLAGS="-C instrument-coverage" cargo build
```

After that, you can run the resulting binary, which will produce
a `default.profraw` file in the current directory. That can be consumed
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved
by the `llvm-cov` binary shipped with rustc as part of the llvm-tools-preview
component.

```shell=
rustup component add llvm-tools-preview
$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -sparse default.profraw -o default.profdata
$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov show -Xdemangler=rustfilt target/debug/coverage-testing \
-instr-profile=default.profdata \
-show-line-counts-or-regions \
-show-instantiations
```

The above commands on a simple helloworld binary produce this annotated report, showing that each line of the input was covered.

```
1| 1|fn main() {
2| 1| println!("Hello, world!");
3| 1|}
```

For more details, please read the [documentation](https://doc.rust-lang.org/rustc/instrument-coverage.html) in the rustc book. The specific output format and LLVM tooling to consume it are both not guaranteed to exist in this specific form, but the baseline functionality will continue to exist for future Rust releases.
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

### `cargo --timings`

Cargo has stabilized support for collecting information on build with the `--timings` flag.

```shell
$ cargo build --timings
Compiling hello-world v0.1.0 (hello-world)
Timing report saved to target/cargo-timings/cargo-timing-20220318T174818Z.html
Finished dev [unoptimized + debuginfo] target(s) in 0.98s
```

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.

Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved
### Weak feature dependencies in Cargo

Cargo has long supported [features](https://doc.rust-lang.org/cargo/reference/resolver.html#features) along with optional dependencies, as illustrated by the snippet below.
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

```toml
[dependencies]
jpeg-decoder = { version = "0.1.20", default-features = false, optional = true }

[features]
# Enables parallel processing support by enabling the "rayon" feature of jpeg-decoder.
parallel = ["jpeg-decoder/rayon"]
```

The `"package-name/feature-name"` syntax will also enable package-name if it is an optional dependency. Often this is not what you want, and starting in 1.60, you can add a ? as in `"package-name?/feature-name"` which will only enable the given feature if something else enables the optional dependency.
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

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:

```toml
[dependencies]
serde = { version = "1.0.133", optional = true }
rgb = { version = "0.8.25", optional = true }

[features]
serde = ["dep:serde", "rgb?/serde"]
```

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.

### Incremental compilation status

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.
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

### Stabilized APIs

The following methods and trait implementations are now stabilized:

- [`Arc::new_cyclic`][arc_new_cyclic]
- [`Rc::new_cyclic`][rc_new_cyclic]
- [`slice::EscapeAscii`][slice_escape_ascii]
- [`<[u8]>::escape_ascii`][slice_u8_escape_ascii]
- [`u8::escape_ascii`][u8_escape_ascii]
- [`Vec::spare_capacity_mut`][vec_spare_capacity_mut]
- [`MaybeUninit::assume_init_drop`][assume_init_drop]
- [`MaybeUninit::assume_init_read`][assume_init_read]
- [`i8::abs_diff`][i8_abs_diff]
- [`i16::abs_diff`][i16_abs_diff]
- [`i32::abs_diff`][i32_abs_diff]
- [`i64::abs_diff`][i64_abs_diff]
- [`i128::abs_diff`][i128_abs_diff]
- [`isize::abs_diff`][isize_abs_diff]
- [`u8::abs_diff`][u8_abs_diff]
- [`u16::abs_diff`][u16_abs_diff]
- [`u32::abs_diff`][u32_abs_diff]
- [`u64::abs_diff`][u64_abs_diff]
- [`u128::abs_diff`][u128_abs_diff]
- [`usize::abs_diff`][usize_abs_diff]
- [`Display for io::ErrorKind`][display_error_kind]
- [`From<u8> for ExitCode`][from_u8_exit_code]
- [`Not for !` (the "never" type)][not_never]
- [_Op_`Assign<$t> for Wrapping<$t>`][wrapping_assign_ops]
- [`arch::is_aarch64_feature_detected!`][is_aarch64_feature_detected]

### Other changes

There are other changes in the Rust 1.60.0 release. Check out what changed in
[Rust](https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1600-2022-04-07),
[Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-160-2022-04-07),
and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-160).

### Contributors to 1.60.0

Many people came together to create Rust 1.60.0.
We couldn't have done it without all of you.
[Thanks!](https://thanks.rust-lang.org/rust/1.60.0/)

[arc_new_cyclic]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.new_cyclic
[rc_new_cyclic]: https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.new_cyclic
[slice_escape_ascii]: https://doc.rust-lang.org/stable/std/slice/struct.EscapeAscii.html
[slice_u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.escape_ascii
[u8_escape_ascii]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.escape_ascii
[vec_spare_capacity_mut]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.spare_capacity_mut
[assume_init_drop]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_drop
[assume_init_read]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_read
[i8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.abs_diff
[i16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.abs_diff
[i32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.abs_diff
[i64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.abs_diff
[i128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.abs_diff
[isize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.abs_diff
[u8_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.abs_diff
[u16_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.abs_diff
[u32_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.abs_diff
[u64_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.abs_diff
[u128_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.abs_diff
[usize_abs_diff]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.abs_diff
[display_error_kind]: https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#impl-Display
[from_u8_exit_code]: https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html#impl-From%3Cu8%3E
[not_never]: https://doc.rust-lang.org/stable/std/primitive.never.html#impl-Not
[wrapping_assign_ops]: https://doc.rust-lang.org/stable/std/num/struct.Wrapping.html#trait-implementations
[is_aarch64_feature_detected]: https://doc.rust-lang.org/stable/std/arch/macro.is_aarch64_feature_detected.html
Loading