From 2e8f90b448c8d9c5d1b48feb5fe0e28ad7cf603e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 22 Aug 2023 17:38:11 -0700 Subject: [PATCH 1/7] Announcing Rust 1.72.0 --- posts/2023-08-24-Rust-1.72.0.md | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 posts/2023-08-24-Rust-1.72.0.md diff --git a/posts/2023-08-24-Rust-1.72.0.md b/posts/2023-08-24-Rust-1.72.0.md new file mode 100644 index 000000000..0c809d36e --- /dev/null +++ b/posts/2023-08-24-Rust-1.72.0.md @@ -0,0 +1,60 @@ +--- +layout: post +title: "Announcing Rust 1.72.0" +author: The Rust Release Team +release: true +--- + +The Rust team is happy to announce a new version of Rust, 1.72.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.72.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.72.0](https://github.com/rust-lang/rust/releases/tag/1.72.0) 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.72.0 stable + +### Uplifted lints from Clippy + +Several lints from Clippy have been pulled into `rustc`: + +* [`clippy::undropped_manually_drops`](https://rust-lang.github.io/rust-clippy/rust-1.71.0/index.html#undropped_manually_drops) to [`undropped_manually_drops`](https://doc.rust-lang.org/1.72.0/rustc/lints/listing/deny-by-default.html#undropped-manually-drops) (deny) + - `ManuallyDrop` does not drop its inner value, so calling `std::mem::drop` on it does nothing. Instead, the lint will suggest `ManuallyDrop::into_inner` first, or you may use the unsafe `ManuallyDrop::drop` to run the destructor in-place. This lint is denied by default. + +* [`clippy::invalid_utf8_in_unchecked`](https://rust-lang.github.io/rust-clippy/rust-1.71.0/index.html#invalid_utf8_in_unchecked) to [`invalid_from_utf8_unchecked`](https://doc.rust-lang.org/1.72.0/rustc/lints/listing/deny-by-default.html#invalid-from-utf8-unchecked) (deny) and [`invalid_from_utf8`](https://doc.rust-lang.org/1.72.0/rustc/lints/listing/warn-by-default.html#invalid-from-utf8) (warn) + - The first checks for calls to `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut` with an invalid UTF-8 literal, which violates their safety pre-conditions, resulting in undefined behavior. This lint is denied by default. + - The second checks for calls to `std::str::from_utf8` and `std::str::from_utf8_mut` with an invalid UTF-8 literal, which will always return an error. This lint is a warning by default. + +* [`clippy::cmp_nan`](https://rust-lang.github.io/rust-clippy/rust-1.71.0/index.html#cmp_nan) to [`invalid_nan_comparisons`](https://doc.rust-lang.org/1.72.0/rustc/lints/listing/warn-by-default.html#invalid-nan-comparisons) (warn) + - This checks for comparisons with `f32::NAN` or `f64::NAN` as one of the operands. NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false. This lint is a warning by default, and will suggest calling the `is_nan()` method instead. + +* [`clippy::cast_ref_to_mut`](https://rust-lang.github.io/rust-clippy/rust-1.71.0/index.html#cast_ref_to_mut) to [`invalid_reference_casting`](https://doc.rust-lang.org/1.72.0/rustc/lints/listing/allowed-by-default.html#invalid-reference-casting) (allow) + - This checks for casts of `&T` to `&mut T` without using interior mutability, which is immediate undefined behavior, even if the reference is unused. This lint is currently allowed by default, but it is planned to be denied by default in 1.73 after implementation improvements. + +### Stabilized APIs + +- [`impl Sync for mpsc::Sender`](https://doc.rust-lang.org/stable/std/sync/mpsc/struct.Sender.html#impl-Sync-for-Sender%3CT%3E) +- [`impl TryFrom<&OsStr> for &str`](https://doc.rust-lang.org/stable/std/primitive.str.html#impl-TryFrom%3C%26'a+OsStr%3E-for-%26'a+str) +- [`String::leak`](https://doc.rust-lang.org/stable/alloc/string/struct.String.html#method.leak) + +These APIs are now stable in const contexts: + +- [`CStr::from_bytes_with_nul`](https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html#method.from_bytes_with_nul) +- [`CStr::to_bytes`](https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html#method.to_bytes) +- [`CStr::to_bytes_with_nul`](https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html#method.to_bytes_with_nul) +- [`CStr::to_str`](https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html#method.to_str) + +### Other changes + +Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.72.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-172-2023-08-24), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-172). + +In a future release we're planning to increase the minimum supported Windows version to 10. The accepted proposal in compiler [MCP 651](https://github.com/rust-lang/compiler-team/issues/651) is that Rust 1.75 will be the last to officially support Windows 7, 8, and 8.1. When Rust 1.76 is released in February 2024, only Windows 10 and later will be supported as tier-1 targets. + +## Contributors to 1.72.0 + +Many people came together to create Rust 1.72.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.72.0/) From 4d233c746ef58ccec2f44ec1316427abc87c34bb Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 23 Aug 2023 08:33:47 -0700 Subject: [PATCH 2/7] Add entry about unlimited const evaluation --- posts/2023-08-24-Rust-1.72.0.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/posts/2023-08-24-Rust-1.72.0.md b/posts/2023-08-24-Rust-1.72.0.md index 0c809d36e..d3c5a9460 100644 --- a/posts/2023-08-24-Rust-1.72.0.md +++ b/posts/2023-08-24-Rust-1.72.0.md @@ -19,6 +19,25 @@ If you'd like to help us out by testing future releases, you might consider upda ## What's in 1.72.0 stable +### Const evaluation time is now unlimited + +To prevent user-provided const evaluation from getting into a compile-time +infinite loop or otherwise taking unbounded time at compile time, Rust +previously limited the maximum number of *statements* run as part of any given +constant evaluation. However, especially creative Rust code could hit these +limits and produce a compiler error. Worse, whether code hit the limit could +vary wildly based on libraries invoked by the user; if a library you invoked +split a statement into two within one of its functions, your code could then +fail to compile. + +Now, you can do an unlimited amount of const evaluation at compile time, To +avoid having long compilations without feedback, the compiler will always emit +a message after your compile-time code has been running for a while, and repeat +that message after a period that doubles each time. By default, the compiler +will also emit a deny-by-default lint (`const_eval_long_running`) after a large +number of steps to catch infinite loops, but you can +`allow(const_eval_long_running)` to permit especially long const evaluation. + ### Uplifted lints from Clippy Several lints from Clippy have been pulled into `rustc`: From b804db28eb16c1acbd82ac770b5ad8355f51c81c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 23 Aug 2023 10:29:13 -0700 Subject: [PATCH 3/7] Add a heading for the Windows note --- posts/2023-08-24-Rust-1.72.0.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/posts/2023-08-24-Rust-1.72.0.md b/posts/2023-08-24-Rust-1.72.0.md index d3c5a9460..f1cc9c333 100644 --- a/posts/2023-08-24-Rust-1.72.0.md +++ b/posts/2023-08-24-Rust-1.72.0.md @@ -72,6 +72,8 @@ These APIs are now stable in const contexts: Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.72.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-172-2023-08-24), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-172). +### Future Windows compatibility + In a future release we're planning to increase the minimum supported Windows version to 10. The accepted proposal in compiler [MCP 651](https://github.com/rust-lang/compiler-team/issues/651) is that Rust 1.75 will be the last to officially support Windows 7, 8, and 8.1. When Rust 1.76 is released in February 2024, only Windows 10 and later will be supported as tier-1 targets. ## Contributors to 1.72.0 From 2861d7f320bae5419a05b625964b7b48e9c42f21 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 23 Aug 2023 13:10:15 -0700 Subject: [PATCH 4/7] Note why invalid_reference_casting is allowed --- posts/2023-08-24-Rust-1.72.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2023-08-24-Rust-1.72.0.md b/posts/2023-08-24-Rust-1.72.0.md index f1cc9c333..aa4b92ec6 100644 --- a/posts/2023-08-24-Rust-1.72.0.md +++ b/posts/2023-08-24-Rust-1.72.0.md @@ -53,7 +53,7 @@ Several lints from Clippy have been pulled into `rustc`: - This checks for comparisons with `f32::NAN` or `f64::NAN` as one of the operands. NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false. This lint is a warning by default, and will suggest calling the `is_nan()` method instead. * [`clippy::cast_ref_to_mut`](https://rust-lang.github.io/rust-clippy/rust-1.71.0/index.html#cast_ref_to_mut) to [`invalid_reference_casting`](https://doc.rust-lang.org/1.72.0/rustc/lints/listing/allowed-by-default.html#invalid-reference-casting) (allow) - - This checks for casts of `&T` to `&mut T` without using interior mutability, which is immediate undefined behavior, even if the reference is unused. This lint is currently allowed by default, but it is planned to be denied by default in 1.73 after implementation improvements. + - This checks for casts of `&T` to `&mut T` without using interior mutability, which is immediate undefined behavior, even if the reference is unused. This lint is currently allowed by default due to potential false positives, but it is planned to be denied by default in 1.73 after implementation improvements. ### Stabilized APIs From 35546fb748640df6ec3df36c0056964d5664da6d Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 23 Aug 2023 20:05:57 -0700 Subject: [PATCH 5/7] Note the Windows change will be host and target --- posts/2023-08-24-Rust-1.72.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2023-08-24-Rust-1.72.0.md b/posts/2023-08-24-Rust-1.72.0.md index aa4b92ec6..f3491ccf5 100644 --- a/posts/2023-08-24-Rust-1.72.0.md +++ b/posts/2023-08-24-Rust-1.72.0.md @@ -74,7 +74,7 @@ Check out everything that changed in [Rust](https://github.com/rust-lang/rust/re ### Future Windows compatibility -In a future release we're planning to increase the minimum supported Windows version to 10. The accepted proposal in compiler [MCP 651](https://github.com/rust-lang/compiler-team/issues/651) is that Rust 1.75 will be the last to officially support Windows 7, 8, and 8.1. When Rust 1.76 is released in February 2024, only Windows 10 and later will be supported as tier-1 targets. +In a future release we're planning to increase the minimum supported Windows version to 10. The accepted proposal in compiler [MCP 651](https://github.com/rust-lang/compiler-team/issues/651) is that Rust 1.75 will be the last to officially support Windows 7, 8, and 8.1. When Rust 1.76 is released in February 2024, only Windows 10 and later will be supported as tier-1 targets. This change will apply both as a host compiler and as a compilation target. ## Contributors to 1.72.0 From 67b27d5572717d05695a0f1c46d71fe20ad4d63d Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 23 Aug 2023 20:08:10 -0700 Subject: [PATCH 6/7] Add a section on cfg-disabled items Co-authored-by: Josh Triplett --- posts/2023-08-24-Rust-1.72.0.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/posts/2023-08-24-Rust-1.72.0.md b/posts/2023-08-24-Rust-1.72.0.md index f3491ccf5..6f2862c7b 100644 --- a/posts/2023-08-24-Rust-1.72.0.md +++ b/posts/2023-08-24-Rust-1.72.0.md @@ -19,6 +19,34 @@ If you'd like to help us out by testing future releases, you might consider upda ## What's in 1.72.0 stable +### Rust reports potentially useful `cfg`-disabled items in errors + +You can conditionally enable Rust code using `cfg`, such as to provide certain +functions only with certain crate features, or only on particular platforms. +Previously, items disabled in this way would be effectively invisible to the +compiler. Now, though, the compiler will remember the name and `cfg` conditions +of those items, so it can report (for example) if a function you tried to call +is unavailable because you need to enable a crate feature. + +``` + Compiling my-project v0.1.0 (/tmp/my-project) +error[E0432]: unresolved import `rustix::io_uring` + --> src/main.rs:1:5 + | +1 | use rustix::io_uring; + | ^^^^^^^^^^^^^^^^ no `io_uring` in the root + | +note: found an item that was configured out + --> /home/username/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.38.8/src/lib.rs:213:9 + | +213 | pub mod io_uring; + | ^^^^^^^^ + = note: the item is gated behind the `io_uring` feature + +For more information about this error, try `rustc --explain E0432`. +error: could not compile `my-project` (bin "my-project") due to previous error +``` + ### Const evaluation time is now unlimited To prevent user-provided const evaluation from getting into a compile-time From d79cd94f6e9d6fdde74de61e872bd316e71f0e4e Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 24 Aug 2023 09:27:27 -0400 Subject: [PATCH 7/7] Update posts/2023-08-24-Rust-1.72.0.md Co-authored-by: Josh Triplett --- posts/2023-08-24-Rust-1.72.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/2023-08-24-Rust-1.72.0.md b/posts/2023-08-24-Rust-1.72.0.md index 6f2862c7b..67df6c4b3 100644 --- a/posts/2023-08-24-Rust-1.72.0.md +++ b/posts/2023-08-24-Rust-1.72.0.md @@ -58,7 +58,7 @@ vary wildly based on libraries invoked by the user; if a library you invoked split a statement into two within one of its functions, your code could then fail to compile. -Now, you can do an unlimited amount of const evaluation at compile time, To +Now, you can do an unlimited amount of const evaluation at compile time. To avoid having long compilations without feedback, the compiler will always emit a message after your compile-time code has been running for a while, and repeat that message after a period that doubles each time. By default, the compiler