From affd660bfc3c8abd8bdd0794484323d10b55aae4 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Mon, 1 Jan 2024 11:57:48 -0500 Subject: [PATCH 01/10] Add another batch of updates to the changelog --- CHANGELOG.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdb671ad4c2..bf16b484a41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,56 @@ ## [Unreleased] +### Fixed + +- Fix an idempotency issue when rewriting where clauses in which rustfmt would continuously add a trailing comma `,` to the end of trailing line comments [#5941](https://github.com/rust-lang/rustfmt/issues/5941). +- When using `version=Two`, the `trace!` macro from the [log crate] is now formatted similarly to `debug!`, `info!`, `warn!`, and `error!` [#5987](https://github.com/rust-lang/rustfmt/issues/5987). +- Prevent enum variant attributes from wrapping one character early when using `version=Two` [#5801](https://github.com/rust-lang/rustfmt/issues/5801) +- Properly wrap macro matchers at the `max_width` when using `version=Two` and `format_macro_matchers=true` [#3805](https://github.com/rust-lang/rustfmt/issues/3805) +- Prevent panic when formatting trait declaration with non [Unicode Normalization Form] C (NFC) identifiers [#6069](https://github.com/rust-lang/rustfmt/issues/6069) + ```rust + // The ó below is two codepoints, ASCII o followed by U+0301 COMBINING ACUTE ACCENT. + // It NFC-normalizes to ó, U+00F3 LATIN SMALL LETTER O WITH ACUTE. + trait Foó: Bar {} + ``` +- Ensure a space is added to a range expression, when the right hand side of the range expression is a binary expression that ends with a trailing period. + ```rust + let range = 3. / 2. ..4.; + ``` +- When using `version=Two`, comments in match arms that contain `=>` no longer prevent formatting [#5998](https://github.com/rust-lang/rustfmt/issues/5998) + ```rust + match a { + _ => + // comment with => + { + println!("A") + } + } + ``` +- Prevent panics when formatting input that contains the expanded form of `offset_of!` [#5885](https://github.com/rust-lang/rustfmt/issues/5885) [#6105](https://github.com/rust-lang/rustfmt/issues/6105) + ```rust + const _: () = builtin # offset_of(x, x); + ``` + +[log crate]: https://crates.io/crates/log +[unicode normalization form]: https://unicode.org/reports/tr15/ + + +### Changed + +- `hide_parse_errors` has been soft deprecated and it's been renamed to `show_parse_errors` [#5961](https://github.com/rust-lang/rustfmt/pull/5961). +- The diff output produced by `rustfmt --check` is more compatable with editors that support navigating directly to line numbers [#5971](https://github.com/rust-lang/rustfmt/pull/5971) + + +### Added + +- `generated_marker_line_search_limit` is a new unstable configuration option that allows users to configure how many lines to search for an `@generated` marker when `format_generated_files=false` [#5658](https://github.com/rust-lang/rustfmt/issues/5658) + + +### Misc + - Updating `dirs 4.0.0 -> 5.0.1` and `cargo_metadata 0.15.4 -> 0.18.0` [#6033] (https://github.com/rust-lang/rustfmt/issues/6033) +- Addressed clap deprecations output when running `cargo check --features clap/deprecated` [#6101](https://github.com/rust-lang/rustfmt/pull/6101) - Bumped bytecount `0.6.4` -> `0.6.8` to fix compilation issues with the `generic-simd` feature. See [bytecount#92] and [bytecount#93] [bytecount#92]: https://github.com/llogiq/bytecount/pull/92 From 15dbb00421d20b38488ef2b2c13cd7c09a811abb Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Mon, 8 Apr 2024 13:00:58 -0400 Subject: [PATCH 02/10] move `trace!` macro fixes to `Changed` section. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf16b484a41..aece323d24e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ ### Fixed - Fix an idempotency issue when rewriting where clauses in which rustfmt would continuously add a trailing comma `,` to the end of trailing line comments [#5941](https://github.com/rust-lang/rustfmt/issues/5941). -- When using `version=Two`, the `trace!` macro from the [log crate] is now formatted similarly to `debug!`, `info!`, `warn!`, and `error!` [#5987](https://github.com/rust-lang/rustfmt/issues/5987). - Prevent enum variant attributes from wrapping one character early when using `version=Two` [#5801](https://github.com/rust-lang/rustfmt/issues/5801) - Properly wrap macro matchers at the `max_width` when using `version=Two` and `format_macro_matchers=true` [#3805](https://github.com/rust-lang/rustfmt/issues/3805) - Prevent panic when formatting trait declaration with non [Unicode Normalization Form] C (NFC) identifiers [#6069](https://github.com/rust-lang/rustfmt/issues/6069) @@ -41,6 +40,7 @@ - `hide_parse_errors` has been soft deprecated and it's been renamed to `show_parse_errors` [#5961](https://github.com/rust-lang/rustfmt/pull/5961). - The diff output produced by `rustfmt --check` is more compatable with editors that support navigating directly to line numbers [#5971](https://github.com/rust-lang/rustfmt/pull/5971) +- When using `version=Two`, the `trace!` macro from the [log crate] is now formatted similarly to `debug!`, `info!`, `warn!`, and `error!` [#5987](https://github.com/rust-lang/rustfmt/issues/5987). ### Added From 9cb6561fbab7e5f814f190f78fdf514f1d732966 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Mon, 8 Apr 2024 13:01:43 -0400 Subject: [PATCH 03/10] Add missing issue reference --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aece323d24e..8a2866fac3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ // It NFC-normalizes to ó, U+00F3 LATIN SMALL LETTER O WITH ACUTE. trait Foó: Bar {} ``` -- Ensure a space is added to a range expression, when the right hand side of the range expression is a binary expression that ends with a trailing period. +- Ensure a space is added to a range expression, when the right hand side of the range expression is a binary expression that ends with a trailing period [#6059](https://github.com/rust-lang/rustfmt/issues/6059) ```rust let range = 3. / 2. ..4.; ``` From 00a5894abb7bf5113f54c218b00768091a9d8ebe Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Mon, 8 Apr 2024 13:01:56 -0400 Subject: [PATCH 04/10] add link to dirs v5 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a2866fac3c..0f50ccad11e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ ### Misc - Updating `dirs 4.0.0 -> 5.0.1` and `cargo_metadata 0.15.4 -> 0.18.0` [#6033] (https://github.com/rust-lang/rustfmt/issues/6033) + - For reference, here's the [dirs v5 changelog](https://github.com/dirs-dev/dirs-rs/blob/main/README.md#5) - Addressed clap deprecations output when running `cargo check --features clap/deprecated` [#6101](https://github.com/rust-lang/rustfmt/pull/6101) - Bumped bytecount `0.6.4` -> `0.6.8` to fix compilation issues with the `generic-simd` feature. See [bytecount#92] and [bytecount#93] From 8d31be61fe83a8008e6f662e5aacc699a3b2a2cc Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Wed, 24 Apr 2024 22:42:17 -0400 Subject: [PATCH 05/10] Add itertools v0.11 -> v0.12 bump to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f50ccad11e..3aa3a1e70bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Updating `dirs 4.0.0 -> 5.0.1` and `cargo_metadata 0.15.4 -> 0.18.0` [#6033] (https://github.com/rust-lang/rustfmt/issues/6033) - For reference, here's the [dirs v5 changelog](https://github.com/dirs-dev/dirs-rs/blob/main/README.md#5) +- Updated [itertools v0.11 -> v0.12](https://github.com/rust-itertools/itertools/blob/v0.12.1/CHANGELOG.md#0120) [#6093](https://github.com/rust-lang/rustfmt/pull/6093) - Addressed clap deprecations output when running `cargo check --features clap/deprecated` [#6101](https://github.com/rust-lang/rustfmt/pull/6101) - Bumped bytecount `0.6.4` -> `0.6.8` to fix compilation issues with the `generic-simd` feature. See [bytecount#92] and [bytecount#93] From 5aa7a33ecb36032ef941ddd8501da4d0d500b69e Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Fri, 26 Apr 2024 11:02:37 -0400 Subject: [PATCH 06/10] Add changelog entry for match expr inner attribute fix with version=Two --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa3a1e70bc..a96fb29da76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,16 @@ ```rust const _: () = builtin # offset_of(x, x); ``` +- When using `version=Two` inner attributes in `match` expressions are correctly indented [#6147](https://github.com/rust-lang/rustfmt/issues/6147) + ```rust + pub fn main() { + match x { + #![attr1] + #![attr2] + _ => (), + } + } + ``` [log crate]: https://crates.io/crates/log [unicode normalization form]: https://unicode.org/reports/tr15/ From f5cd9270fd7632e50ac9bbe312cebcdc2bb06094 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Tue, 18 Jun 2024 16:55:56 -0400 Subject: [PATCH 07/10] reorder link reference definitions and one changelog entry Moved the link reference definitions closer to where they were being used and moved the `type ascription` formatting fix to the correct section. --- CHANGELOG.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a96fb29da76..2ee07a02b7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ // It NFC-normalizes to ó, U+00F3 LATIN SMALL LETTER O WITH ACUTE. trait Foó: Bar {} ``` + [unicode normalization form]: https://unicode.org/reports/tr15/ - Ensure a space is added to a range expression, when the right hand side of the range expression is a binary expression that ends with a trailing period [#6059](https://github.com/rust-lang/rustfmt/issues/6059) ```rust let range = 3. / 2. ..4.; @@ -41,9 +42,12 @@ } } ``` - -[log crate]: https://crates.io/crates/log -[unicode normalization form]: https://unicode.org/reports/tr15/ +- Output correct syntax for type ascription builtin [#6159](https://github.com/rust-lang/rustfmt/issues/6159) + ```rust + fn main() { + builtin # type_ascribe(10, usize) + } + ``` ### Changed @@ -52,6 +56,8 @@ - The diff output produced by `rustfmt --check` is more compatable with editors that support navigating directly to line numbers [#5971](https://github.com/rust-lang/rustfmt/pull/5971) - When using `version=Two`, the `trace!` macro from the [log crate] is now formatted similarly to `debug!`, `info!`, `warn!`, and `error!` [#5987](https://github.com/rust-lang/rustfmt/issues/5987). + [log crate]: https://crates.io/crates/log + ### Added @@ -66,15 +72,8 @@ - Addressed clap deprecations output when running `cargo check --features clap/deprecated` [#6101](https://github.com/rust-lang/rustfmt/pull/6101) - Bumped bytecount `0.6.4` -> `0.6.8` to fix compilation issues with the `generic-simd` feature. See [bytecount#92] and [bytecount#93] -[bytecount#92]: https://github.com/llogiq/bytecount/pull/92 -[bytecount#93]: https://github.com/llogiq/bytecount/pull/93 - -- Output correct syntax for type ascription builtin [#6159](https://github.com/rust-lang/rustfmt/issues/6159) - ```rust - fn main() { - builtin # type_ascribe(10, usize) - } - ``` + [bytecount#92]: https://github.com/llogiq/bytecount/pull/92 + [bytecount#93]: https://github.com/llogiq/bytecount/pull/93 ## [1.7.0] 2023-10-22 From f84c20deb5348b0b5f1ee91e6dc10c0b164af1c4 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Tue, 18 Jun 2024 17:00:38 -0400 Subject: [PATCH 08/10] Document fix for retaining inner attributes on const blocks --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ee07a02b7d..d94f32fa51a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,16 @@ builtin # type_ascribe(10, usize) } ``` +- rustfmt no longer removes inner attributes from inline const blocks [#6158](https://github.com/rust-lang/rustfmt/issues/6158) + ```rust + fn main() { + const { + #![allow(clippy::assertions_on_constants)] + + assert!(1 < 2); + } + } + ``` ### Changed From 4cd088f3c79ca945c9f56827058682a64a2f5df7 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Tue, 18 Jun 2024 17:03:35 -0400 Subject: [PATCH 09/10] Document removing rustfmt's `lazy_static` dependency --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d94f32fa51a..79910fb7c27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ [bytecount#92]: https://github.com/llogiq/bytecount/pull/92 [bytecount#93]: https://github.com/llogiq/bytecount/pull/93 +- Replace the `lazy_static` dependency with `std::sync::OnceLock` [#6154](https://github.com/rust-lang/rustfmt/pull/6154) ## [1.7.0] 2023-10-22 From 2e952e947f6396116a2358bd6b1b0d3766a76dd9 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi <yacintmimi@gmail.com> Date: Fri, 21 Jun 2024 13:05:00 -0400 Subject: [PATCH 10/10] document rustfmt support for `#![feature(unsafe_extern_blocks)]` --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79910fb7c27..89e90fb17dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,16 @@ } } ``` +- rustfmt no longer removes `safe` and `unsafe` keywords from static items in extern blocks. + This helps support [`#![feature(unsafe_extern_blocks)]`](https://github.com/rust-lang/rust/issues/123743) [#6204](https://github.com/rust-lang/rustfmt/pull/6204) + ```rust + #![feature(unsafe_extern_blocks)] + + unsafe extern "C" { + safe static TEST1: i32; + unsafe static TEST2: i32; + } + ``` ### Changed