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

release blog post for Rust 1.47 #702

Merged
merged 5 commits into from
Oct 8, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 54 additions & 4 deletions posts/2020-10-05-Rust-1.47.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,59 @@ appropriate page on our website, and check out the [detailed release notes for

## What's in 1.47.0 stable

This release contains no new significant features, and is mostly quality of
life improvements, library stabilizations and const-ifications, and toolchain
This release contains no new language features, though it does add one
long-awaited standard library feature. It is mostly quality of life
improvements, library stabilizations and const-ifications, and toolchain
improvements. See the [detailed release notes][notes] to learn about other
changes not covered by this post.

#### Traits on larger arrays

Rust does not currently have a way to be generic over integer values. This
has long caused problems with arrays, because arrays have an integer as part
of their type; `[T; N]` is the type of an array of type `T` of `N` length.
Because there is no way to be generic over `N`, you have to manually implement
traits for arrays for every `N` you want to support. For the standard library,
it was decided to support up to `N` of 32.

We have been working on a feature called "const generics" that would allow
you to be generic over `N`. Fully explaining this feature is out of the scope
of this post, because we are not stabilizing const generics just yet.
However, the core of this feature has been implemented in the compiler, and
it has been decided that the feature is far enough along that we are okay
with [the standard library using it to implement traits on arrays of any
length](https://github.com/rust-lang/rust/pull/74060/). What this means in
practice is that if you try to do something like this on Rust 1.46:

```rust
fn main() {
let xs = [0; 34];

println!("{:?}", xs);
}
```

you'd get this error:

```text
error[E0277]: arrays only have std trait implementations for lengths 0..=32
--> src/main.rs:4:22
|
4 | println!("{:?}", xs);
| ^^ the trait `std::array::LengthAtMost32` is not implemented for `[{integer}; 34]`
|
= note: required because of the requirements on the impl of `std::fmt::Debug` for `[{integer}; 34]`
= note: required by `std::fmt::Debug::fmt`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
```

But with Rust 1.47, it will properly print out.
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

This should make arrays significantly more useful to folks, though it will
take until the const generics feature stabilizes for libraries to fully be
able to do this kind of implementation for their own traits. We do not have
a current estimated date for the stabilization of const generics.

#### Shorter backtraces

Back in Rust 1.18, we [made some changes to the backtraces `rustc` would
Expand Down Expand Up @@ -128,7 +176,9 @@ on Windows. Other platforms ignore this flag.

### Library changes

Nine new APIs were stabilized this release:
[Rustdoc has gained support for the Ayu theme](https://github.com/rust-lang/rust/pull/71237/).
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

Additionally, nine new APIs were stabilized this release:

- [`Ident::new_raw`]
- [`Range::is_empty`]
Expand All @@ -140,7 +190,7 @@ Nine new APIs were stabilized this release:
- [`f32::TAU`]
- [`f64::TAU`]

Additonally, the following previously stable APIs have now been made `const`:
The following previously stable APIs have now been made `const`:

- [The `new` method for all `NonZero` integers.][73858]
- [The `checked_add`,`checked_sub`,`checked_mul`,`checked_neg`, `checked_shl`,
Expand Down