From 1b663b93577c23d94ddb85ae65d2270243abc6d0 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 10 Mar 2024 18:01:21 -0400 Subject: [PATCH 01/10] Add post for 1.77 --- posts/2024-03-21-Rust-1.77.0.md | 93 +++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 posts/2024-03-21-Rust-1.77.0.md diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md new file mode 100644 index 000000000..e657844c6 --- /dev/null +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -0,0 +1,93 @@ +--- +layout: post +title: "Announcing Rust 1.77.0" +author: The Rust Release Team +release: true +--- + +The Rust team is happy to announce a new version of Rust, 1.77.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.77.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.77.0](https://doc.rust-lang.org/nightly/releases.html#version-77-2024-03-21). + +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.77.0 stable + +This release is relatively minor, but as always, even incremental improvements lead to a greater whole. A few of those changes are highlighted in this post, and others may yet fill more niche needs. + +### C-string literals + +Rust now supports C-string literals (`c"abc"`) which expand to a nul-byte +terminated string in memory of type `&CStr`. This makes it easier to write code +taking nul-terminated strings, with all of the relevant error checking (e.g., +lack of interior nul byte) implemented within the compiler. + +### `offset_of!` + +1.77.0 stabilizes [`offset_of!`] for struct fields, which provides access to the +byte offset of the relevant public field of a struct. This macro is most useful +when the offset of a field is required without an existing instance of a type. +Implementing such a macro is already possible on stable, but without an +instance of the type the implementation would require tricky unsafe code which +makes it easy to get into undefined behavior. + +Users can now access the offset of a public field with `offset_of!(StructName, +field)`. This expands to a `usize` expression with the offset in bytes from the +start of the struct. + +Note that the output of the macro is not typically stable across compiler +versions or across platforms. See the macro's documentation for details on when the output can be relied on. + +[`offset_of!`]: https://doc.rust-lang.org/nightly/std/mem/macro.offset_of.html + +### Enable strip in release profiles by default + +Cargo [profiles](https://doc.rust-lang.org/stable/cargo/reference/profiles.html) +which do not enable [debug info](https://doc.rust-lang.org/stable/cargo/reference/profiles.html#debug) in +outputs (e.g., `debug = 0`) will enable `strip = "debuginfo"` by default. + +This is primarily needed because the (precompiled) standard library ships with +debug info, which means that statically linked results would include the +debuginfo from the standard library even if the local compilations didn't +explicitly request debuginfo. + +Users which do want debuginfo can explicitly enable it with the +[debug](https://doc.rust-lang.org/stable/cargo/reference/profiles.html#debug) +flag in the relevant Cargo profile. + +### Stabilized APIs + +- [`array::each_ref`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.each_ref) +- [`array::each_mut`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.each_mut) +- [`core::net`](https://doc.rust-lang.org/stable/core/net/index.html) +- [`f32::round_ties_even`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.round_ties_even) +- [`f64::round_ties_even`](https://doc.rust-lang.org/stable/std/primitive.f64.html#method.round_ties_even) +- [`mem::offset_of!`](https://doc.rust-lang.org/stable/std/mem/macro.offset_of.html) +- [`slice::first_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first_chunk) +- [`slice::first_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first_chunk_mut) +- [`slice::split_first_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first_chunk) +- [`slice::split_first_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first_chunk_mut) +- [`slice::last_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.last_chunk) +- [`slice::last_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.last_chunk_mut) +- [`slice::split_last_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_last_chunk) +- [`slice::split_last_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_last_chunk_mut) +- [`slice::chunk_by`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.chunk_by) +- [`slice::chunk_by_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.chunk_by_mut) +- [`Bound::map`](https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.map) +- [`File::create_new`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.create_new) +- [`Mutex::clear_poison`](https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html#method.clear_poison) +- [`RwLock::clear_poison`](https://doc.rust-lang.org/stable/std/sync/struct.RwLock.html#method.clear_poison) + +### Other changes + +Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.77.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-177-2024-02-08), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-177). + +## Contributors to 1.77.0 + +Many people came together to create Rust 1.77.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.77.0/) From f57710057d1d694693701c2417f47e7d7b7feaa0 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 10 Mar 2024 19:58:25 -0400 Subject: [PATCH 02/10] Update posts/2024-03-21-Rust-1.77.0.md Co-authored-by: Kevin Reid --- posts/2024-03-21-Rust-1.77.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index e657844c6..c24deaa87 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -7,7 +7,7 @@ release: true The Rust team is happy to announce a new version of Rust, 1.77.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.77.0 with: +If you have a previous version of Rust installed via `rustup`, you can get 1.77.0 with: ```console $ rustup update stable From e4d1ae02eabb02df2687fab210a7277611b56c75 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 10 Mar 2024 19:58:35 -0400 Subject: [PATCH 03/10] Update posts/2024-03-21-Rust-1.77.0.md Co-authored-by: Eric Huss --- posts/2024-03-21-Rust-1.77.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index c24deaa87..56ff610ab 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -86,7 +86,7 @@ flag in the relevant Cargo profile. ### Other changes -Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.77.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-177-2024-02-08), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-177). +Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.77.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-177-2024-03-21), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-177). ## Contributors to 1.77.0 From e3e5303b65cfc6602fc12f7d23d0c59448ea243c Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 10 Mar 2024 19:59:13 -0400 Subject: [PATCH 04/10] Update posts/2024-03-21-Rust-1.77.0.md Co-authored-by: Kevin Reid --- posts/2024-03-21-Rust-1.77.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index 56ff610ab..2b8db9931 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -25,8 +25,8 @@ This release is relatively minor, but as always, even incremental improvements l Rust now supports C-string literals (`c"abc"`) which expand to a nul-byte terminated string in memory of type `&CStr`. This makes it easier to write code -taking nul-terminated strings, with all of the relevant error checking (e.g., -lack of interior nul byte) implemented within the compiler. +providing nul-terminated strings, with all of the relevant error checking (e.g., +lack of interior nul byte) performed at compile time. ### `offset_of!` From 7e184bb8eb052b9d842d98f2357d715281a7b5d8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 16 Mar 2024 10:08:58 -0400 Subject: [PATCH 05/10] Spell debuginfo consistently --- posts/2024-03-21-Rust-1.77.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index 2b8db9931..929f18eb5 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -49,11 +49,11 @@ versions or across platforms. See the macro's documentation for details on when ### Enable strip in release profiles by default Cargo [profiles](https://doc.rust-lang.org/stable/cargo/reference/profiles.html) -which do not enable [debug info](https://doc.rust-lang.org/stable/cargo/reference/profiles.html#debug) in +which do not enable [debuginfo](https://doc.rust-lang.org/stable/cargo/reference/profiles.html#debug) in outputs (e.g., `debug = 0`) will enable `strip = "debuginfo"` by default. This is primarily needed because the (precompiled) standard library ships with -debug info, which means that statically linked results would include the +debuginfo, which means that statically linked results would include the debuginfo from the standard library even if the local compilations didn't explicitly request debuginfo. From e1d95c6bd755dac29bedbc93ab24684285d9d269 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 16 Mar 2024 10:09:38 -0400 Subject: [PATCH 06/10] Avoid explaining subtle details --- posts/2024-03-21-Rust-1.77.0.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index 929f18eb5..6e3c2d00f 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -35,16 +35,13 @@ byte offset of the relevant public field of a struct. This macro is most useful when the offset of a field is required without an existing instance of a type. Implementing such a macro is already possible on stable, but without an instance of the type the implementation would require tricky unsafe code which -makes it easy to get into undefined behavior. +makes it easy to accidentally introduce undefined behavior. Users can now access the offset of a public field with `offset_of!(StructName, field)`. This expands to a `usize` expression with the offset in bytes from the start of the struct. -Note that the output of the macro is not typically stable across compiler -versions or across platforms. See the macro's documentation for details on when the output can be relied on. - -[`offset_of!`]: https://doc.rust-lang.org/nightly/std/mem/macro.offset_of.html +[`offset_of!`]: https://doc.rust-lang.org/stable/std/mem/macro.offset_of.html ### Enable strip in release profiles by default From 4df797aacc8669845178365f001ca257297318f8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 16 Mar 2024 10:26:27 -0400 Subject: [PATCH 07/10] Add two new sections --- posts/2024-03-21-Rust-1.77.0.md | 38 +++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index 6e3c2d00f..315419cb1 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -25,8 +25,27 @@ This release is relatively minor, but as always, even incremental improvements l Rust now supports C-string literals (`c"abc"`) which expand to a nul-byte terminated string in memory of type `&CStr`. This makes it easier to write code -providing nul-terminated strings, with all of the relevant error checking (e.g., -lack of interior nul byte) performed at compile time. +interoperating with foreign language interfaces which require nul-terminated +strings, with all of the relevant error checking (e.g., lack of interior nul +byte) performed at compile time. + +### Support for recursion in `async fn` + +async functions previously could not call themselves due to a compiler analysis +limitation. In 1.77, that limitation has been lifted, so recursive calls are +permitted so long as they use some form of indirection to avoid an infinite +size for the state of the function. + +This means that code like this now works: + +```rust +async fn fib(n : u32) -> u32 { + match n { + 0 | 1 => 1, + _ => Box::pin(fib(n-1)).await + Box::pin(fib(n-2)).await + } +} +``` ### `offset_of!` @@ -58,6 +77,21 @@ Users which do want debuginfo can explicitly enable it with the [debug](https://doc.rust-lang.org/stable/cargo/reference/profiles.html#debug) flag in the relevant Cargo profile. +### Clippy adds a new `incompatible_msrv` lint + +The Rust project only supports the latest stable release of Rust. Some +libraries aim to have an older minimum supported Rust version (MSRV), typically +verifying this support by compiling in CI with an older release. However, when +developing new code, it's convenient to use latest documentation and the latest +toolchain with fixed bugs, performance improvements, and other improvements. +This can make it easy to accidentally start using an API that's only available +on newer versions of Rust. + +Clippy has added a new lint, [`incompatible_msrv`](https://rust-lang.github.io/rust-clippy/master/index.html#/incompatible_msrv), +which will inform users if functionality being referenced is only available on +newer versions than their +[declared MSRV](https://github.com/rust-lang/rust-clippy/?tab=readme-ov-file#specifying-the-minimum-supported-rust-version). + ### Stabilized APIs - [`array::each_ref`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.each_ref) From f5080e08b917438ba9563975254ba765c44104e1 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 16 Mar 2024 18:22:27 -0400 Subject: [PATCH 08/10] Update posts/2024-03-21-Rust-1.77.0.md Co-authored-by: Kevin Reid --- posts/2024-03-21-Rust-1.77.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index 315419cb1..bc78b9aaf 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -39,7 +39,7 @@ size for the state of the function. This means that code like this now works: ```rust -async fn fib(n : u32) -> u32 { +async fn fib(n: u32) -> u32 { match n { 0 | 1 => 1, _ => Box::pin(fib(n-1)).await + Box::pin(fib(n-2)).await From 5e6ffbfad47764819585f66b7a181f6c18878c31 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 17 Mar 2024 13:42:42 -0400 Subject: [PATCH 09/10] Update posts/2024-03-21-Rust-1.77.0.md Co-authored-by: Josh Stone --- posts/2024-03-21-Rust-1.77.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index bc78b9aaf..44897e922 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -24,7 +24,7 @@ This release is relatively minor, but as always, even incremental improvements l ### C-string literals Rust now supports C-string literals (`c"abc"`) which expand to a nul-byte -terminated string in memory of type `&CStr`. This makes it easier to write code +terminated string in memory of type `&'static CStr`. This makes it easier to write code interoperating with foreign language interfaces which require nul-terminated strings, with all of the relevant error checking (e.g., lack of interior nul byte) performed at compile time. From c2cbb757120b265355ac749200b6be7891005f0e Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 18 Mar 2024 09:00:38 -0400 Subject: [PATCH 10/10] Update posts/2024-03-21-Rust-1.77.0.md Co-authored-by: lcnr --- posts/2024-03-21-Rust-1.77.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2024-03-21-Rust-1.77.0.md b/posts/2024-03-21-Rust-1.77.0.md index 44897e922..f31eb71e1 100644 --- a/posts/2024-03-21-Rust-1.77.0.md +++ b/posts/2024-03-21-Rust-1.77.0.md @@ -31,7 +31,7 @@ byte) performed at compile time. ### Support for recursion in `async fn` -async functions previously could not call themselves due to a compiler analysis +Async functions previously could not call themselves due to a compiler limitation. In 1.77, that limitation has been lifted, so recursive calls are permitted so long as they use some form of indirection to avoid an infinite size for the state of the function.