From 90198260d45bb661dc046185edbc8f7a8e408ccc Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 4 Sep 2022 17:45:55 +0200 Subject: [PATCH 01/15] Draft release notes for 1.64 Still needs lists of stabilized APIs. --- posts/2022-09-22-Rust-1.64.0.md | 256 ++++++++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 posts/2022-09-22-Rust-1.64.0.md diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md new file mode 100644 index 000000000..82ef7253a --- /dev/null +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -0,0 +1,256 @@ +--- +layout: post +title: "Announcing Rust 1.64.0" +author: Josh Triplett +team: The Release Team +release: true +--- + +The Rust team is happy to announce a new version of Rust, 1.64.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.64.0 +with: + +```console +rustup update stable +``` + +If you don't have it already, you can [get +`rustup`](https://www.rust-lang.org/install.html) from the appropriate page on +our website, and check out the [detailed release notes for +1.64.0](https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1640-2022-09-22) +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](https://github.com/rust-lang/rust/issues/new/choose) any bugs you +might come across! + +## What's in 1.64.0 stable + +### C-compatible ffi types in core and alloc + +When calling or being called by C ABIs, Rust code can use types like `c_uint` +or `c_ulong` to match the corresponding types from C on any target, without +requiring target-specific code or conditionals. + +Previously, these types were only available in `std`, so code written for +embedded targets and other scenarios that could only use `core` or `alloc` +could not use these types. + +Rust 1.64 now provides all of the `c_*` types in +[`core::ffi`](https://doc.rust-lang.org/core/ffi/index.html), as well as +[`core::ffi::CStr`](https://doc.rust-lang.org/core/ffi/struct.CStr.html) for +working with C strings. Rust 1.64 also provides +[`alloc::ffi::CString`](https://doc.rust-lang.org/alloc/ffi/struct.CString.html) +for working with owned C strings using only the `alloc` crate, rather than the +full `std` library. + +### New internal layout for network structures + +The standard library network data structures +[`Ipv4Addr`](https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html), +[`Ipv6Addr`](https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html), +[`SocketAddrV4`](https://doc.rust-lang.org/std/net/struct.SocketAddrV4.html), +and +[`SocketAddrV6`](https://doc.rust-lang.org/std/net/struct.SocketAddrV6.html) +now use a more compact, memory-efficient layout, rather than using the memory +layout of the underlying OS data structure. + +Normally, such a change would be an entirely internal detail of the standard +library, with the only user-visible effect being less memory usage. However, +some crates relied on the internal implementation details of the standard +library, by using +[`std::mem::transmute`](https://doc.rust-lang.org/std/mem/fn.transmute.html) or +similar to access the internal representation and pass it directly to OS +functions. + +Such internal implementation details of the standard library are *never* +considered a stable interface. Nonetheless, because multiple crates relied on +this, we first worked with the authors of all of the still-maintained crates +doing so to arrange for the release of new versions, and to yank the old ones, +before making this change. + +See for more details. + +### Warning about unused tuple-struct fields + +If you define a struct containing fields that are never used, rustc will warn +about the unused fields. Now, in Rust 1.64, you can enable the +`unused_tuple_struct_fields` lint to get the same warnings about unused fields +in a tuple struct. In future versions, we plan to make this lint warn by +default. + +Fields of type unit (`()`) do not produce a warning, to make it easier to +migrate existing code without having to change tuple indices. + +### Enhancing `.await` with `IntoFuture` + +Rust 1.64 stabilizes the +[`IntoFuture`](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) +trait. `IntoFuture` is a trait similar to +[`IntoIterator`](https://doc.rust-lang.org/std/iter/trait.IntoIterator.html), +but rather than supporting `for ... in ...` loops, `IntoFuture` changes how +`.await` works. With `IntoFuture`, the `.await` keyword can await mor ethan +just futures; it can await _anything which can be converted into a `Future` via +`IntoFuture`_ - which can help make your APIs more user-friendly! + +Take for example a builder which constructs requests to some storage provider +over the network: + +```rust +pub struct Error { ... } +pub struct StorageResponse { ... }: +pub struct StorageRequest(bool); + +impl StorageRequest { + /// Create a new instance of `StorageRequest`. + pub fn new() -> Self { ... } + /// Decide whether debug mode should be enabled. + pub fn set_debug(self, b: bool) -> Self { ... } + /// Send the request and receive a response. + pub async fn send(self) -> Result { ... } +} +``` + +Typical usage would likely look something like this: + +```rust +let response = StorageRequest::new() // 1. create a new instance + .set_debug(true) // 2. set some option + .send() // 3. construct the future + .await?; // 4. run the future + propagate errors +``` + +This is not bad, but we can do better here. Using `IntoFuture` we can combine +_"construct the future"_ (line 3) and _"run the future"_ (line 4) into a single +step: +```rust +let response = StorageRequest::new() // 1. create a new instance + .set_debug(true) // 2. set some option + .await?; // 3. construct + run the future + propagate errors +``` + +We can do this by implementing `IntoFuture` for `StorageRequest`. `IntoFuture` +requires us to have a named future we can return, which we can do by creating a +"boxed future" and defining a type alias for it: + +```rust +// First we must import some new types into the scope. +use std::pin::Pin; +use std::future::{Future, IntoFuture}; + +pub struct Error { ... } +pub struct StorageResponse { ... } +pub struct StorageRequest(bool); + +impl StorageRequest { + /// Create a new instance of `StorageRequest`. + pub fn new() -> Self { ... } + /// Decide whether debug mode should be enabled. + pub fn set_debug(self, b: bool) -> Self { ... } + /// Send the request and receive a response. + pub async fn send(self) -> Result { ... } +} + +// The new implementations: +// 1. create a new named future type +// 2. implement `IntoFuture` for `StorageRequest` +pub type StorageRequestFuture = Pin + Send + 'static>> +impl IntoFuture for StorageRequest { + type IntoFuture = StorageRequestFuture; + type Output = ::Output; + fn into_future(self) -> Self::IntoFuture { + Box::pin(self.send()) + } +} +``` +This takes a bit more code to implement, but provides a simpler API for users. + +In the future, the Rust Async WG hopes to simplify the creating new named +futures by supporting [`impl Trait` in `type` aliases (Type Alias Impl Trait or +TAIT)](https://rust-lang.github.io/impl-trait-initiative/explainer/tait.html). +This should make implementing `IntoFuture` easier by simplifying the type +alias' signature, and make it more performant by removing the `Box` from the +type alias. + +### Stabilizing `ready!` and `poll_fn` + +When working with the low-level details of futures, you'll currently often +encounter the [`Poll`](https://doc.rust-lang.org/std/task/enum.Poll.html) type. +We've stabilized a few helpers for working with this type: + +- [`ready!`](https://doc.rust-lang.org/std/task/macro.ready.html) takes a + `Poll` and returns from the containing function for `Poll::Pending`, or + returns the contained value in a `Poll::Ready`. This can be useful when + implementing futures manually using `Poll`. +- [`poll_fn`](https://doc.rust-lang.org/std/future/fn.poll_fn.html) turns a + function returning `Poll` into a future. + +In the future, we hope to provide simpler APIs that require less use of +low-level details like `Poll` and `Pin`, but in the meantime, these helpers +make it easier to write such code. + +### Minimum required kernel and glibc versions increased + +As [previously +announced](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html), +`linux` targets now require at least Linux kernel 3.2 (except for targets which +already required a newer kernel), and `linux-gnu` targets now require glibc +2.17 (except for targets which already required a newer glibc). + +### Profile-guided optimization (PGO) for Windows targets + +Windows builds of the Rust compiler now use profile-guided optimization, +providing performance improvements of 10-20% for compiling Rust code on +Windows. + +### `rust-analyzer` now available via `rustup`, no longer in preview + +Users of `rust-analyzer` can now obtain it via `rustup` on the stable and beta +channels, not just on nightly. + +### Cargo workspace inheritance + +When working with collections of related libraries or binary crates in one +Cargo workspace, you can now avoid duplication of common field values between +crates, such as common version numbers, repository URLs, or `rust-version`. +This also helps keep these values in sync between crates when updating them. +For more details, see +[`workspace.package`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacepackage-table), +[`workspace.dependencies`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacedependencies-table), +and ["inheriting a dependency from a +workspace"](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace). + +### Cargo multi-target builds + +When building for multiple targets, you can now pass multiple `--target` +options to `cargo build`, to build all of those targets at once. You can also +set [`build.target`](https://doc.rust-lang.org/cargo/reference/config.html#buildtarget) to an array of multiple targets in `.cargo/config.toml` to +build for multiple targets by default. + +### Stabilized APIs + +The following methods and trait implementations are now stabilized: + +- ... + +These APIs are now usable in const contexts: + +- ... + +### Other changes + +There are other changes in the Rust 1.64.0 release. Check out what changed in +[Rust](https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1640-2022-09-22), +[Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-164-2022-09-22), +and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-164). + +### Contributors to 1.64.0 + +Many people came together to create Rust 1.64.0. +We couldn't have done it without all of you. +[Thanks!](https://thanks.rust-lang.org/rust/1.64.0/) From 4d5aecb34ba270b2dce257394334c351b812cf38 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 4 Sep 2022 18:42:22 +0200 Subject: [PATCH 02/15] Fixes to Rust 1.64 blog post --- posts/2022-09-22-Rust-1.64.0.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 82ef7253a..7c47e5e7d 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -31,17 +31,17 @@ might come across! ## What's in 1.64.0 stable -### C-compatible ffi types in core and alloc +### C-compatible FFI types in core and alloc -When calling or being called by C ABIs, Rust code can use types like `c_uint` -or `c_ulong` to match the corresponding types from C on any target, without -requiring target-specific code or conditionals. +When calling or being called by C ABIs, Rust code can use type aliases like +`c_uint` or `c_ulong` to match the corresponding types from C on any target, +without requiring target-specific code or conditionals. -Previously, these types were only available in `std`, so code written for -embedded targets and other scenarios that could only use `core` or `alloc` +Previously, these type aliases were only available in `std`, so code written +for embedded targets and other scenarios that could only use `core` or `alloc` could not use these types. -Rust 1.64 now provides all of the `c_*` types in +Rust 1.64 now provides all of the `c_*` type aliases in [`core::ffi`](https://doc.rust-lang.org/core/ffi/index.html), as well as [`core::ffi::CStr`](https://doc.rust-lang.org/core/ffi/struct.CStr.html) for working with C strings. Rust 1.64 also provides @@ -72,7 +72,9 @@ Such internal implementation details of the standard library are *never* considered a stable interface. Nonetheless, because multiple crates relied on this, we first worked with the authors of all of the still-maintained crates doing so to arrange for the release of new versions, and to yank the old ones, -before making this change. +before making this change. New releases for known affected crates have been out +for typically over a year, and the vast majority of impacted users should be +able to mitigate with a `cargo update` if needed." See for more details. @@ -94,9 +96,9 @@ Rust 1.64 stabilizes the trait. `IntoFuture` is a trait similar to [`IntoIterator`](https://doc.rust-lang.org/std/iter/trait.IntoIterator.html), but rather than supporting `for ... in ...` loops, `IntoFuture` changes how -`.await` works. With `IntoFuture`, the `.await` keyword can await mor ethan -just futures; it can await _anything which can be converted into a `Future` via -`IntoFuture`_ - which can help make your APIs more user-friendly! +`.await` works. With `IntoFuture`, the `.await` keyword can await more than +just futures; it can await *anything which can be converted into a `Future` via +`IntoFuture`* - which can help make your APIs more user-friendly! Take for example a builder which constructs requests to some storage provider over the network: @@ -128,6 +130,7 @@ let response = StorageRequest::new() // 1. create a new instance This is not bad, but we can do better here. Using `IntoFuture` we can combine _"construct the future"_ (line 3) and _"run the future"_ (line 4) into a single step: + ```rust let response = StorageRequest::new() // 1. create a new instance .set_debug(true) // 2. set some option @@ -168,6 +171,7 @@ impl IntoFuture for StorageRequest { } } ``` + This takes a bit more code to implement, but provides a simpler API for users. In the future, the Rust Async WG hopes to simplify the creating new named From 5268c5b47c6c2856fb64c5056c76538e2dbb4804 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 15:30:09 +0200 Subject: [PATCH 03/15] normalize post authorship --- posts/2022-09-22-Rust-1.64.0.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 7c47e5e7d..e9182f1a2 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -1,8 +1,7 @@ --- layout: post title: "Announcing Rust 1.64.0" -author: Josh Triplett -team: The Release Team +author: The Rust Release Team release: true --- From bc7e5026b44b3246700bdf09129b806a9c48f292 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 15:43:26 +0200 Subject: [PATCH 04/15] collapse less relevant items at the bottom --- posts/2022-09-22-Rust-1.64.0.md | 68 +++++++++++++++------------------ 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index e9182f1a2..e4c65dac9 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -77,17 +77,6 @@ able to mitigate with a `cargo update` if needed." See for more details. -### Warning about unused tuple-struct fields - -If you define a struct containing fields that are never used, rustc will warn -about the unused fields. Now, in Rust 1.64, you can enable the -`unused_tuple_struct_fields` lint to get the same warnings about unused fields -in a tuple struct. In future versions, we plan to make this lint warn by -default. - -Fields of type unit (`()`) do not produce a warning, to make it easier to -migrate existing code without having to change tuple indices. - ### Enhancing `.await` with `IntoFuture` Rust 1.64 stabilizes the @@ -205,36 +194,11 @@ announced](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-require already required a newer kernel), and `linux-gnu` targets now require glibc 2.17 (except for targets which already required a newer glibc). -### Profile-guided optimization (PGO) for Windows targets - -Windows builds of the Rust compiler now use profile-guided optimization, -providing performance improvements of 10-20% for compiling Rust code on -Windows. - ### `rust-analyzer` now available via `rustup`, no longer in preview Users of `rust-analyzer` can now obtain it via `rustup` on the stable and beta channels, not just on nightly. -### Cargo workspace inheritance - -When working with collections of related libraries or binary crates in one -Cargo workspace, you can now avoid duplication of common field values between -crates, such as common version numbers, repository URLs, or `rust-version`. -This also helps keep these values in sync between crates when updating them. -For more details, see -[`workspace.package`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacepackage-table), -[`workspace.dependencies`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacedependencies-table), -and ["inheriting a dependency from a -workspace"](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace). - -### Cargo multi-target builds - -When building for multiple targets, you can now pass multiple `--target` -options to `cargo build`, to build all of those targets at once. You can also -set [`build.target`](https://doc.rust-lang.org/cargo/reference/config.html#buildtarget) to an array of multiple targets in `.cargo/config.toml` to -build for multiple targets by default. - ### Stabilized APIs The following methods and trait implementations are now stabilized: @@ -247,7 +211,37 @@ These APIs are now usable in const contexts: ### Other changes -There are other changes in the Rust 1.64.0 release. Check out what changed in +There are other changes in the Rust 1.64 release, including: + +* Windows builds of the Rust compiler now use profile-guided optimization, + providing performance improvements of 10-20% for compiling Rust code on + Windows. + +* If you define a struct containing fields that are never used, rustc will warn + about the unused fields. Now, in Rust 1.64, you can enable the + `unused_tuple_struct_fields` lint to get the same warnings about unused + fields in a tuple struct. In future versions, we plan to make this lint + warn by default. Fields of type unit (`()`) do not produce this warning, + to make it easier to migrate existing code without having to change tuple + indices. + +* When working with collections of related libraries or binary crates in one + Cargo workspace, you can now avoid duplication of common field values between + crates, such as common version numbers, repository URLs, or `rust-version`. + This also helps keep these values in sync between crates when updating them. + For more details, see + [`workspace.package`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacepackage-table), + [`workspace.dependencies`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacedependencies-table), + and ["inheriting a dependency from a + workspace"](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace). + +* When building for multiple targets, you can now pass multiple `--target` + options to `cargo build`, to build all of those targets at once. You can + also set [`build.target`](https://doc.rust-lang.org/cargo/reference/config.html#buildtarget) + to an array of multiple targets in `.cargo/config.toml` to build for + multiple targets by default. + +Check out everything that changed in [Rust](https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1640-2022-09-22), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-164-2022-09-22), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-164). From b0001473bcf8d7386ed50f07e4f5a414010d0fac Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 15:57:32 +0200 Subject: [PATCH 05/15] move all compat notes to their own section --- posts/2022-09-22-Rust-1.64.0.md | 58 ++++++++++++--------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index e4c65dac9..3009ca3ac 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -48,35 +48,6 @@ working with C strings. Rust 1.64 also provides for working with owned C strings using only the `alloc` crate, rather than the full `std` library. -### New internal layout for network structures - -The standard library network data structures -[`Ipv4Addr`](https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html), -[`Ipv6Addr`](https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html), -[`SocketAddrV4`](https://doc.rust-lang.org/std/net/struct.SocketAddrV4.html), -and -[`SocketAddrV6`](https://doc.rust-lang.org/std/net/struct.SocketAddrV6.html) -now use a more compact, memory-efficient layout, rather than using the memory -layout of the underlying OS data structure. - -Normally, such a change would be an entirely internal detail of the standard -library, with the only user-visible effect being less memory usage. However, -some crates relied on the internal implementation details of the standard -library, by using -[`std::mem::transmute`](https://doc.rust-lang.org/std/mem/fn.transmute.html) or -similar to access the internal representation and pass it directly to OS -functions. - -Such internal implementation details of the standard library are *never* -considered a stable interface. Nonetheless, because multiple crates relied on -this, we first worked with the authors of all of the still-maintained crates -doing so to arrange for the release of new versions, and to yank the old ones, -before making this change. New releases for known affected crates have been out -for typically over a year, and the vast majority of impacted users should be -able to mitigate with a `cargo update` if needed." - -See for more details. - ### Enhancing `.await` with `IntoFuture` Rust 1.64 stabilizes the @@ -186,14 +157,6 @@ In the future, we hope to provide simpler APIs that require less use of low-level details like `Poll` and `Pin`, but in the meantime, these helpers make it easier to write such code. -### Minimum required kernel and glibc versions increased - -As [previously -announced](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html), -`linux` targets now require at least Linux kernel 3.2 (except for targets which -already required a newer kernel), and `linux-gnu` targets now require glibc -2.17 (except for targets which already required a newer glibc). - ### `rust-analyzer` now available via `rustup`, no longer in preview Users of `rust-analyzer` can now obtain it via `rustup` on the stable and beta @@ -209,6 +172,27 @@ These APIs are now usable in const contexts: - ... +### Compatibility notes + +Rust 1.64 includes some changes that might prevent you from upgrading: + +* As [previously + announced](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html), + `linux` targets now require at least Linux kernel 3.2 (except for targets which + already required a newer kernel), and `linux-gnu` targets now require glibc + 2.17 (except for targets which already required a newer glibc). + +* Rust 1.64.0 changes the memory layout of `Ipv4Addr`, `Ipv6Addr`, + `SocketAddrV4` and `SocketAddrV6` to be more compact and memory efficient. + This internal representation was never exposed, but some crates relied on + it anyway by using `std::mem::transmute`, resulting in invalid memory + accesses. Such internal implementation details of the standard library are + *never* considered a stable interface. To limit the damage, we worked with + the authors of all of the still-maintained crates doing so to release fixed + versions, which have been out for more than a year. The vast majority of + impacted users should be able to mitigate with a `cargo update`. + + ### Other changes There are other changes in the Rust 1.64 release, including: From 47e373d838ff331c67c4a60f8e2f6d16d18f7158 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 16:01:11 +0200 Subject: [PATCH 06/15] add RLS note --- posts/2022-09-22-Rust-1.64.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 3009ca3ac..03a77d937 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -192,6 +192,10 @@ Rust 1.64 includes some changes that might prevent you from upgrading: versions, which have been out for more than a year. The vast majority of impacted users should be able to mitigate with a `cargo update`. +As part of the [RLS +deprecation](https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html), this +is also the last release containing a copy of RLS. Starting from Rust 1.65.0, +RLS will be replaced by a small LSP server showing the deprecation warning. ### Other changes From 1792880b844ee808ed43b3f2de107bc9342f8901 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 16:01:31 +0200 Subject: [PATCH 07/15] move IntoFuture ahead of c-compatible ffi types --- posts/2022-09-22-Rust-1.64.0.md | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 03a77d937..61b8e9b32 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -30,24 +30,6 @@ might come across! ## What's in 1.64.0 stable -### C-compatible FFI types in core and alloc - -When calling or being called by C ABIs, Rust code can use type aliases like -`c_uint` or `c_ulong` to match the corresponding types from C on any target, -without requiring target-specific code or conditionals. - -Previously, these type aliases were only available in `std`, so code written -for embedded targets and other scenarios that could only use `core` or `alloc` -could not use these types. - -Rust 1.64 now provides all of the `c_*` type aliases in -[`core::ffi`](https://doc.rust-lang.org/core/ffi/index.html), as well as -[`core::ffi::CStr`](https://doc.rust-lang.org/core/ffi/struct.CStr.html) for -working with C strings. Rust 1.64 also provides -[`alloc::ffi::CString`](https://doc.rust-lang.org/alloc/ffi/struct.CString.html) -for working with owned C strings using only the `alloc` crate, rather than the -full `std` library. - ### Enhancing `.await` with `IntoFuture` Rust 1.64 stabilizes the @@ -140,6 +122,24 @@ This should make implementing `IntoFuture` easier by simplifying the type alias' signature, and make it more performant by removing the `Box` from the type alias. +### C-compatible FFI types in core and alloc + +When calling or being called by C ABIs, Rust code can use type aliases like +`c_uint` or `c_ulong` to match the corresponding types from C on any target, +without requiring target-specific code or conditionals. + +Previously, these type aliases were only available in `std`, so code written +for embedded targets and other scenarios that could only use `core` or `alloc` +could not use these types. + +Rust 1.64 now provides all of the `c_*` type aliases in +[`core::ffi`](https://doc.rust-lang.org/core/ffi/index.html), as well as +[`core::ffi::CStr`](https://doc.rust-lang.org/core/ffi/struct.CStr.html) for +working with C strings. Rust 1.64 also provides +[`alloc::ffi::CString`](https://doc.rust-lang.org/alloc/ffi/struct.CString.html) +for working with owned C strings using only the `alloc` crate, rather than the +full `std` library. + ### Stabilizing `ready!` and `poll_fn` When working with the low-level details of futures, you'll currently often From b9a1bce44da6123e2d41a093146129a15e21f9fe Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 16:05:45 +0200 Subject: [PATCH 08/15] expand note about rustup --- posts/2022-09-22-Rust-1.64.0.md | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 61b8e9b32..87ca97530 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -157,10 +157,36 @@ In the future, we hope to provide simpler APIs that require less use of low-level details like `Poll` and `Pin`, but in the meantime, these helpers make it easier to write such code. -### `rust-analyzer` now available via `rustup`, no longer in preview +### rust-analyzer is now available via rustup -Users of `rust-analyzer` can now obtain it via `rustup` on the stable and beta -channels, not just on nightly. +[rust-analyzer](https://rust-analyzer.github.io/) is now included as part of +the collection of tools included with Rust. This can make it easier to download +and access rust-analyzer, and makes it available on more platforms. It is +available as a [rustup +component](https://rust-lang.github.io/rustup/concepts/components.html) which +can be installed with: + +``` +rustup component add rust-analyzer +``` + +At this time, to run the rustup-installed version, you need to invoke it this +way: + +``` +rustup run rust-analyzer +``` + +The next release of rustup will have a built-in proxy so that running the +executable `rust-analyzer` will launch the appropriate version. + +Most users should continue to use the releases provided by the rust-analyzer +team (available on the [rust-analyzer releases +page](https://github.com/rust-lang/rust-analyzer/releases)), which are +published more frequently. Users of the [official VSCode +extension](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) +are not affected since it automatically downloads and updates releases in the +background. ### Stabilized APIs From d9dccbe4593caf26dfa149f8dbb334a41fbd667f Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 16:08:26 +0200 Subject: [PATCH 09/15] add stablized apis --- posts/2022-09-22-Rust-1.64.0.md | 49 +++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 87ca97530..f8ad37508 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -192,11 +192,56 @@ background. The following methods and trait implementations are now stabilized: -- ... +- [`future::IntoFuture`](https://doc.rust-lang.org/stable/std/future/trait.IntoFuture.html) +- [`future::poll_fn`](https://doc.rust-lang.org/stable/std/future/fn.poll_fn.html) +- [`task::ready!`](https://doc.rust-lang.org/stable/std/task/macro.ready.html) +- [`num::NonZero*::checked_mul`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_mul) +- [`num::NonZero*::checked_pow`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_pow) +- [`num::NonZero*::saturating_mul`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.saturating_mul) +- [`num::NonZero*::saturating_pow`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.saturating_pow) +- [`num::NonZeroI*::abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.abs) +- [`num::NonZeroI*::checked_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.checked_abs) +- [`num::NonZeroI*::overflowing_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.overflowing_abs) +- [`num::NonZeroI*::saturating_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.saturating_abs) +- [`num::NonZeroI*::unsigned_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.unsigned_abs) +- [`num::NonZeroI*::wrapping_abs`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroIsize.html#method.wrapping_abs) +- [`num::NonZeroU*::checked_add`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_add) +- [`num::NonZeroU*::checked_next_power_of_two`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_next_power_of_two) +- [`num::NonZeroU*::saturating_add`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.saturating_add) +- [`os::unix::process::CommandExt::process_group`](https://doc.rust-lang.org/stable/std/os/unix/process/trait.CommandExt.html#tymethod.process_group) +- [`os::windows::fs::FileTypeExt::is_symlink_dir`](https://doc.rust-lang.org/stable/std/os/windows/fs/trait.FileTypeExt.html#tymethod.is_symlink_dir) +- [`os::windows::fs::FileTypeExt::is_symlink_file`](https://doc.rust-lang.org/stable/std/os/windows/fs/trait.FileTypeExt.html#tymethod.is_symlink_file) + +These types were previously stable in `std::ffi`, but are now also available in +`core` and `alloc`: + +- [`core::ffi::CStr`](https://doc.rust-lang.org/stable/core/ffi/struct.CStr.html) +- [`core::ffi::FromBytesWithNulError`](https://doc.rust-lang.org/stable/core/ffi/struct.FromBytesWithNulError.html) +- [`alloc::ffi::CString`](https://doc.rust-lang.org/stable/alloc/ffi/struct.CString.html) +- [`alloc::ffi::FromVecWithNulError`](https://doc.rust-lang.org/stable/alloc/ffi/struct.FromVecWithNulError.html) +- [`alloc::ffi::IntoStringError`](https://doc.rust-lang.org/stable/alloc/ffi/struct.IntoStringError.html) +- [`alloc::ffi::NulError`](https://doc.rust-lang.org/stable/alloc/ffi/struct.NulError.html) + +These types were previously stable in `std::os::raw`, but are now also +available in `core::ffi` and `std::ffi`: + +- [`ffi::c_char`](https://doc.rust-lang.org/stable/std/ffi/type.c_char.html) +- [`ffi::c_double`](https://doc.rust-lang.org/stable/std/ffi/type.c_double.html) +- [`ffi::c_float`](https://doc.rust-lang.org/stable/std/ffi/type.c_float.html) +- [`ffi::c_int`](https://doc.rust-lang.org/stable/std/ffi/type.c_int.html) +- [`ffi::c_long`](https://doc.rust-lang.org/stable/std/ffi/type.c_long.html) +- [`ffi::c_longlong`](https://doc.rust-lang.org/stable/std/ffi/type.c_longlong.html) +- [`ffi::c_schar`](https://doc.rust-lang.org/stable/std/ffi/type.c_schar.html) +- [`ffi::c_short`](https://doc.rust-lang.org/stable/std/ffi/type.c_short.html) +- [`ffi::c_uchar`](https://doc.rust-lang.org/stable/std/ffi/type.c_uchar.html) +- [`ffi::c_uint`](https://doc.rust-lang.org/stable/std/ffi/type.c_uint.html) +- [`ffi::c_ulong`](https://doc.rust-lang.org/stable/std/ffi/type.c_ulong.html) +- [`ffi::c_ulonglong`](https://doc.rust-lang.org/stable/std/ffi/type.c_ulonglong.html) +- [`ffi::c_ushort`](https://doc.rust-lang.org/stable/std/ffi/type.c_ushort.html) These APIs are now usable in const contexts: -- ... +- [`slice::from_raw_parts`](https://doc.rust-lang.org/stable/core/slice/fn.from_raw_parts.html) ### Compatibility notes From 1f9b9b58ebe47f97832151b3802cc685b8760548 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 21 Sep 2022 17:44:09 +0100 Subject: [PATCH 10/15] Avoid suggesting not upgrading; let compat notes stand on their own --- posts/2022-09-22-Rust-1.64.0.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index f8ad37508..fec80bf51 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -245,8 +245,6 @@ These APIs are now usable in const contexts: ### Compatibility notes -Rust 1.64 includes some changes that might prevent you from upgrading: - * As [previously announced](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html), `linux` targets now require at least Linux kernel 3.2 (except for targets which From c2ea1739e5df79753bf88de0329e8dfba953549f Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 21 Sep 2022 18:51:26 +0200 Subject: [PATCH 11/15] update links Co-authored-by: Scott Schafer --- posts/2022-09-22-Rust-1.64.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index fec80bf51..a164190a5 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -287,8 +287,8 @@ There are other changes in the Rust 1.64 release, including: crates, such as common version numbers, repository URLs, or `rust-version`. This also helps keep these values in sync between crates when updating them. For more details, see - [`workspace.package`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacepackage-table), - [`workspace.dependencies`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacedependencies-table), + [`workspace.package`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-package-table), + [`workspace.dependencies`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table), and ["inheriting a dependency from a workspace"](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace). From dcde451216c3bc25ce6fa824d4393dc09a6aecef Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 22 Sep 2022 10:11:52 +0100 Subject: [PATCH 12/15] Move Cargo changes from "other" to their own section Leave the two combined in one heading, since they're one paragraph each, but move them from bullets to paragraphs. --- posts/2022-09-22-Rust-1.64.0.md | 35 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index a164190a5..af1c7b6b7 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -188,6 +188,25 @@ extension](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-an are not affected since it automatically downloads and updates releases in the background. +### Cargo improvements: workspace inheritance and multi-target builds + +When working with collections of related libraries or binary crates in one +Cargo workspace, you can now avoid duplication of common field values between +crates, such as common version numbers, repository URLs, or `rust-version`. +This also helps keep these values in sync between crates when updating them. +For more details, see +[`workspace.package`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-package-table), +[`workspace.dependencies`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table), +and ["inheriting a dependency from a +workspace"](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace). + +When building for multiple targets, you can now pass multiple `--target` +options to `cargo build`, to build all of those targets at once. You can also +set +[`build.target`](https://doc.rust-lang.org/cargo/reference/config.html#buildtarget) +to an array of multiple targets in `.cargo/config.toml` to build for multiple +targets by default. + ### Stabilized APIs The following methods and trait implementations are now stabilized: @@ -282,22 +301,6 @@ There are other changes in the Rust 1.64 release, including: to make it easier to migrate existing code without having to change tuple indices. -* When working with collections of related libraries or binary crates in one - Cargo workspace, you can now avoid duplication of common field values between - crates, such as common version numbers, repository URLs, or `rust-version`. - This also helps keep these values in sync between crates when updating them. - For more details, see - [`workspace.package`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-package-table), - [`workspace.dependencies`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table), - and ["inheriting a dependency from a - workspace"](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace). - -* When building for multiple targets, you can now pass multiple `--target` - options to `cargo build`, to build all of those targets at once. You can - also set [`build.target`](https://doc.rust-lang.org/cargo/reference/config.html#buildtarget) - to an array of multiple targets in `.cargo/config.toml` to build for - multiple targets by default. - Check out everything that changed in [Rust](https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1640-2022-09-22), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-164-2022-09-22), From a7dac7cb2df3f5cf83e9d5aeb54ec8d8429121c8 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 22 Sep 2022 10:31:26 +0100 Subject: [PATCH 13/15] Consistently use bullets in the compatibility section --- posts/2022-09-22-Rust-1.64.0.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index af1c7b6b7..74b2f0790 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -280,10 +280,11 @@ These APIs are now usable in const contexts: versions, which have been out for more than a year. The vast majority of impacted users should be able to mitigate with a `cargo update`. -As part of the [RLS -deprecation](https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html), this -is also the last release containing a copy of RLS. Starting from Rust 1.65.0, -RLS will be replaced by a small LSP server showing the deprecation warning. +* As part of the [RLS + deprecation](https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html), + this is also the last release containing a copy of RLS. Starting from Rust + 1.65.0, RLS will be replaced by a small LSP server showing the deprecation + warning. ### Other changes From d35704d74f752bd2bb3ece9acf0b8e51bbedc860 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 22 Sep 2022 10:33:51 +0100 Subject: [PATCH 14/15] Tighten language about `ready!` and `poll_fn` and move to stabilizations --- posts/2022-09-22-Rust-1.64.0.md | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 74b2f0790..0a0b4c7d2 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -140,23 +140,6 @@ working with C strings. Rust 1.64 also provides for working with owned C strings using only the `alloc` crate, rather than the full `std` library. -### Stabilizing `ready!` and `poll_fn` - -When working with the low-level details of futures, you'll currently often -encounter the [`Poll`](https://doc.rust-lang.org/std/task/enum.Poll.html) type. -We've stabilized a few helpers for working with this type: - -- [`ready!`](https://doc.rust-lang.org/std/task/macro.ready.html) takes a - `Poll` and returns from the containing function for `Poll::Pending`, or - returns the contained value in a `Poll::Ready`. This can be useful when - implementing futures manually using `Poll`. -- [`poll_fn`](https://doc.rust-lang.org/std/future/fn.poll_fn.html) turns a - function returning `Poll` into a future. - -In the future, we hope to provide simpler APIs that require less use of -low-level details like `Poll` and `Pin`, but in the meantime, these helpers -make it easier to write such code. - ### rust-analyzer is now available via rustup [rust-analyzer](https://rust-analyzer.github.io/) is now included as part of @@ -212,8 +195,6 @@ targets by default. The following methods and trait implementations are now stabilized: - [`future::IntoFuture`](https://doc.rust-lang.org/stable/std/future/trait.IntoFuture.html) -- [`future::poll_fn`](https://doc.rust-lang.org/stable/std/future/fn.poll_fn.html) -- [`task::ready!`](https://doc.rust-lang.org/stable/std/task/macro.ready.html) - [`num::NonZero*::checked_mul`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_mul) - [`num::NonZero*::checked_pow`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.checked_pow) - [`num::NonZero*::saturating_mul`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroUsize.html#method.saturating_mul) @@ -258,6 +239,16 @@ available in `core::ffi` and `std::ffi`: - [`ffi::c_ulonglong`](https://doc.rust-lang.org/stable/std/ffi/type.c_ulonglong.html) - [`ffi::c_ushort`](https://doc.rust-lang.org/stable/std/ffi/type.c_ushort.html) +We've stabilized some helpers for use with `Poll`, the low-level implementation +underneath futures: + +- [`future::poll_fn`](https://doc.rust-lang.org/stable/std/future/fn.poll_fn.html) +- [`task::ready!`](https://doc.rust-lang.org/stable/std/task/macro.ready.html) + +In the future, we hope to provide simpler APIs that require less use of +low-level details like `Poll` and `Pin`, but in the meantime, these helpers +make it easier to write such code. + These APIs are now usable in const contexts: - [`slice::from_raw_parts`](https://doc.rust-lang.org/stable/core/slice/fn.from_raw_parts.html) From 540c2b4a787ba9fcf0cb1b70d3a627e7e43273e9 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 22 Sep 2022 10:39:32 +0100 Subject: [PATCH 15/15] Tighten up some language --- posts/2022-09-22-Rust-1.64.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posts/2022-09-22-Rust-1.64.0.md b/posts/2022-09-22-Rust-1.64.0.md index 0a0b4c7d2..5393ed0ce 100644 --- a/posts/2022-09-22-Rust-1.64.0.md +++ b/posts/2022-09-22-Rust-1.64.0.md @@ -143,7 +143,7 @@ full `std` library. ### rust-analyzer is now available via rustup [rust-analyzer](https://rust-analyzer.github.io/) is now included as part of -the collection of tools included with Rust. This can make it easier to download +the collection of tools included with Rust. This makes it easier to download and access rust-analyzer, and makes it available on more platforms. It is available as a [rustup component](https://rust-lang.github.io/rustup/concepts/components.html) which @@ -160,7 +160,7 @@ way: rustup run rust-analyzer ``` -The next release of rustup will have a built-in proxy so that running the +The next release of rustup will provide a built-in proxy so that running the executable `rust-analyzer` will launch the appropriate version. Most users should continue to use the releases provided by the rust-analyzer