Skip to content

Commit 0ee5907

Browse files
committed
Auto merge of #153145 - ytmimi:rustfmt-subtree-update, r=ytmimi
rustfmt subtree update r? @ghost
2 parents 6a979b3 + 02a4978 commit 0ee5907

247 files changed

Lines changed: 6490 additions & 1182 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 9 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@ dependencies = [
5252
"libc",
5353
]
5454

55-
[[package]]
56-
name = "annotate-snippets"
57-
version = "0.9.2"
58-
source = "registry+https://github.com/rust-lang/crates.io-index"
59-
checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e"
60-
dependencies = [
61-
"unicode-width 0.1.14",
62-
"yansi-term",
63-
]
64-
6555
[[package]]
6656
name = "annotate-snippets"
6757
version = "0.11.5"
@@ -1213,16 +1203,6 @@ dependencies = [
12131203
"dirs-sys",
12141204
]
12151205

1216-
[[package]]
1217-
name = "dirs-next"
1218-
version = "2.0.0"
1219-
source = "registry+https://github.com/rust-lang/crates.io-index"
1220-
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
1221-
dependencies = [
1222-
"cfg-if",
1223-
"dirs-sys-next",
1224-
]
1225-
12261206
[[package]]
12271207
name = "dirs-sys"
12281208
version = "0.5.0"
@@ -1231,21 +1211,10 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
12311211
dependencies = [
12321212
"libc",
12331213
"option-ext",
1234-
"redox_users 0.5.2",
1214+
"redox_users",
12351215
"windows-sys 0.61.2",
12361216
]
12371217

1238-
[[package]]
1239-
name = "dirs-sys-next"
1240-
version = "0.1.2"
1241-
source = "registry+https://github.com/rust-lang/crates.io-index"
1242-
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
1243-
dependencies = [
1244-
"libc",
1245-
"redox_users 0.4.6",
1246-
"winapi",
1247-
]
1248-
12491218
[[package]]
12501219
name = "dispatch2"
12511220
version = "0.3.0"
@@ -3229,17 +3198,6 @@ dependencies = [
32293198
"bitflags",
32303199
]
32313200

3232-
[[package]]
3233-
name = "redox_users"
3234-
version = "0.4.6"
3235-
source = "registry+https://github.com/rust-lang/crates.io-index"
3236-
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
3237-
dependencies = [
3238-
"getrandom 0.2.16",
3239-
"libredox",
3240-
"thiserror 1.0.69",
3241-
]
3242-
32433201
[[package]]
32443202
name = "redox_users"
32453203
version = "0.5.2"
@@ -4871,9 +4829,9 @@ dependencies = [
48714829

48724830
[[package]]
48734831
name = "rustfmt-nightly"
4874-
version = "1.8.0"
4832+
version = "1.9.0"
48754833
dependencies = [
4876-
"annotate-snippets 0.9.2",
4834+
"annotate-snippets 0.11.5",
48774835
"anyhow",
48784836
"bytecount",
48794837
"cargo_metadata 0.18.1",
@@ -4886,11 +4844,13 @@ dependencies = [
48864844
"itertools",
48874845
"regex",
48884846
"rustfmt-config_proc_macro",
4847+
"semver",
48894848
"serde",
48904849
"serde_json",
4850+
"tempfile",
48914851
"term",
48924852
"thiserror 1.0.69",
4893-
"toml 0.7.8",
4853+
"toml 0.9.8",
48944854
"tracing",
48954855
"tracing-subscriber",
48964856
"unicode-properties",
@@ -5410,13 +5370,11 @@ dependencies = [
54105370

54115371
[[package]]
54125372
name = "term"
5413-
version = "0.7.0"
5373+
version = "1.2.1"
54145374
source = "registry+https://github.com/rust-lang/crates.io-index"
5415-
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
5375+
checksum = "d8c27177b12a6399ffc08b98f76f7c9a1f4fe9fc967c784c5a071fa8d93cf7e1"
54165376
dependencies = [
5417-
"dirs-next",
5418-
"rustversion",
5419-
"winapi",
5377+
"windows-sys 0.61.2",
54205378
]
54215379

54225380
[[package]]
@@ -6289,22 +6247,6 @@ dependencies = [
62896247
"wasm-bindgen",
62906248
]
62916249

6292-
[[package]]
6293-
name = "winapi"
6294-
version = "0.3.9"
6295-
source = "registry+https://github.com/rust-lang/crates.io-index"
6296-
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
6297-
dependencies = [
6298-
"winapi-i686-pc-windows-gnu",
6299-
"winapi-x86_64-pc-windows-gnu",
6300-
]
6301-
6302-
[[package]]
6303-
name = "winapi-i686-pc-windows-gnu"
6304-
version = "0.4.0"
6305-
source = "registry+https://github.com/rust-lang/crates.io-index"
6306-
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
6307-
63086250
[[package]]
63096251
name = "winapi-util"
63106252
version = "0.1.11"
@@ -6314,12 +6256,6 @@ dependencies = [
63146256
"windows-sys 0.61.2",
63156257
]
63166258

6317-
[[package]]
6318-
name = "winapi-x86_64-pc-windows-gnu"
6319-
version = "0.4.0"
6320-
source = "registry+https://github.com/rust-lang/crates.io-index"
6321-
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
6322-
63236259
[[package]]
63246260
name = "windows"
63256261
version = "0.61.3"
@@ -6786,15 +6722,6 @@ dependencies = [
67866722
"lzma-sys",
67876723
]
67886724

6789-
[[package]]
6790-
name = "yansi-term"
6791-
version = "0.1.2"
6792-
source = "registry+https://github.com/rust-lang/crates.io-index"
6793-
checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1"
6794-
dependencies = [
6795-
"winapi",
6796-
]
6797-
67986725
[[package]]
67996726
name = "yoke"
68006727
version = "0.8.1"

src/tools/rustfmt/.github/workflows/check_diff.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,29 @@ on:
33
workflow_dispatch:
44
inputs:
55
clone_url:
6-
description: 'Git url of a rustfmt fork to compare against the latest master rustfmt'
6+
description: 'Git url of a rustfmt fork to compare against the latest rustfmt'
77
required: true
88
branch_name:
99
description: 'Name of the feature branch on the forked repo'
1010
required: true
11+
language_edition:
12+
description: 'Rust language `edition` used to parse code'
13+
required: true
14+
default: 2015
15+
type: choice
16+
options:
17+
- 2015
18+
- 2018
19+
- 2021
20+
- 2024
21+
style_edition:
22+
description: 'rustfmt `style_edition` used when formatting code.'
23+
required: true
24+
default: 2021
25+
type: choice
26+
options:
27+
- 2021 # 2015, 2018, and 2021 are all formatted the same since `style_edition` was added between 2021 and 2024
28+
- 2024
1129
commit_hash:
1230
description: 'Optional commit hash from the feature branch'
1331
required: false
@@ -23,11 +41,27 @@ jobs:
2341
- name: checkout
2442
uses: actions/checkout@v4
2543

26-
- name: install rustup
44+
- name: Build check_diff binary
45+
working-directory: ./check_diff
46+
run: cargo build --release
47+
48+
- name: Run Diff Check
49+
working-directory: ./check_diff
50+
env:
51+
CHECK_DIFF_LOG: info
52+
shell: bash
2753
run: |
28-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
29-
sh rustup-init.sh -y --default-toolchain none
30-
rustup target add x86_64-unknown-linux-gnu
54+
OPTIONS=""
55+
56+
if [[ -n "${{ github.event.inputs.commit_hash }}" ]]; then
57+
OPTIONS+="--commit-hash ${{ github.event.inputs.commit_hash }} "
58+
fi
59+
60+
if [[ -n "${{ github.event.inputs.rustfmt_configs }}" ]]; then
61+
OPTIONS+="--rustfmt-config ${{ github.event.inputs.rustfmt_configs }} "
62+
fi
3163
32-
- name: check diff
33-
run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.event.inputs.commit_hash || github.event.inputs.branch_name }} ${{ github.event.inputs.rustfmt_configs }}
64+
target/release/check_diff ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} \
65+
--edition ${{ github.event.inputs.language_edition }} \
66+
--style-edition ${{ github.event.inputs.style_edition }} \
67+
$OPTIONS

src/tools/rustfmt/.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: integration
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77

88
jobs:

src/tools/rustfmt/.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: linux
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77

88
jobs:

src/tools/rustfmt/.github/workflows/mac.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: mac
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77

88
jobs:

src/tools/rustfmt/.github/workflows/rustdoc_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: rustdoc check
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77

88
jobs:

src/tools/rustfmt/.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: windows
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77

88
jobs:

src/tools/rustfmt/CHANGELOG.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
6+
## [1.9.0] 2026-02-26
7+
8+
### Fixed
9+
- No longer strip `r#` prefix from `break` and `continue` labels [#6411](https://github.com/rust-lang/rustfmt/issues/6411)
10+
```rust
11+
fn main() {
12+
'r#if: {
13+
break 'r#if;
14+
}
15+
}
16+
```
17+
- Fix panic when sorting imports [#6333](https://github.com/rust-lang/rustfmt/issues/6333)
18+
- Fix issue with `wrap_comments` invalidating code blocks [#6417](https://github.com/rust-lang/rustfmt/pull/6417)
19+
- No longer remove closure block label within a macro call [#6465](https://github.com/rust-lang/rustfmt/issues/6465)
20+
- Fix idempotency issue when normalizing imports [#6558](https://github.com/rust-lang/rustfmt/issues/6558)
21+
- Properly split long pattern in `if-let` at the `max_width` when setting `style_edition=2027` [#6202](https://github.com/rust-lang/rustfmt/issues/6202)
22+
- Format `lazy_static::lazy_static!` like `lazy_static!` when setting `style_edition=2027` [#6287](https://github.com/rust-lang/rustfmt/issues/6287)
23+
- Prevent panic when rewriting missing spans that contain unicode whitespace chars [#5739](https://github.com/rust-lang/rustfmt/issues/5739)
24+
- Allow `NotADirectory` errors when looking up rustfmt configuration files [#6624](https://github.com/rust-lang/rustfmt/pull/6624)
25+
- Prevent panic when sorting imports starting with a `_` for `style_edition=2015|2018|2021` [#6668](https://github.com/rust-lang/rustfmt/issues/6668)
26+
- Properly wrap long `impl trait` function parameters at the `max_width` when setting `style_edition=2027` [#6381](https://github.com/rust-lang/rustfmt/issues/6381)
27+
- Better support for deduplicating imports when setting `imports_granularity=Module` [#6243](https://github.com/rust-lang/rustfmt/issues/6243)
28+
29+
### Changed
30+
- Stabilize `style_edition=2024` and stabilize the `style_edition` command line option [#6431](https://github.com/rust-lang/rustfmt/pull/6431) [rust-lang/rust#134929](https://github.com/rust-lang/rust/pull/134929)
31+
- Apply version sorting to module declarations when using `style_edition=2027` [#6368](https://github.com/rust-lang/rustfmt/pull/6368) and [#6594](https://github.com/rust-lang/rustfmt/pull/6594)
32+
- When users set the deprecated `version` config, rustfmt now gives a hint about which equivalent `style_edition` they should use [#6361](https://github.com/rust-lang/rustfmt/pull/6361)
33+
- Correct version chunk splitting in the internal version sort algorithm [#6407](https://github.com/rust-lang/rustfmt/pull/6407)
34+
- Extend support for single line let-chain formatting to include cases where the left hand side operand is a literal, in alignment with finalized style rules as part of let-chain stabilization [#6492](https://github.com/rust-lang/rustfmt/pull/6492)
35+
- Begin initial formatting for `use closures` and `use chains` (`#![feature(ergonomic_clones)]`). Previously, the closure and chain was left as the developer wrote it [#6532](https://github.com/rust-lang/rustfmt/pull/6532)
36+
- The unstable `required_version` configuration option now support cargo flavored semantic versioning using the `semver` crate [#6063](https://github.com/rust-lang/rustfmt/issues/6063)
37+
- Top-level imports are no longer merged when setting `imports_granularity=Module`. Note that `imports_granularity=Module` is still an unstable configuration [#6191](https://github.com/rust-lang/rustfmt/issues/6191)
38+
- Disable the `bytecount/generic-simd` optional dependency when using the `generic-simd` feature. The dependency was preventing rustfmt from building on nightly. simd support will be re-enabled once the issue has been fixed [#6807](https://github.com/rust-lang/rustfmt/pull/6807) [llogiq/bytecount#100](https://github.com/llogiq/bytecount/pull/100)
39+
- The `trailing_semicolon` configuration option will add a trailing semicolon to the last expression in a loop body when enabled along with `edition >= 2024` and `style_edition >= 2027` [#6711](https://github.com/rust-lang/rustfmt/pull/6711)
40+
```rust
41+
fn main() {
42+
for x in 0..10 {
43+
println!("{x}");
44+
}
45+
}
46+
```
47+
48+
49+
### Added
50+
- Add `style_edition=2027` to gate unstable formatting [#6324](https://github.com/rust-lang/rustfmt/pull/6324)
51+
- Support discovering and formatting files via external mods imported within `cfg_match`, similar to `cfg_if` behavior [#6522](https://github.com/rust-lang/rustfmt/pull/6522)
52+
- Add new nightly-only `match_arm_indent` option [#6525](https://github.com/rust-lang/rustfmt/pull/6525)
53+
- See the [`match_arm_indent` configuration documentation](https://rust-lang.github.io/rustfmt/?version=v1.9.0&search=#match_arm_indent) for more details
54+
- Add new nightly-only `float_literal_trailing_zero` option [#3187](https://github.com/rust-lang/rustfmt/issues/3187)
55+
- See the [`float_literal_trailing_zero` configuration documentation](https://rust-lang.github.io/rustfmt/?version=v1.9.0&search=#float_literal_trailing_zero) for more details
56+
57+
### Misc
58+
- Update `term` dependency to 1.1 [#6628](https://github.com/rust-lang/rustfmt/pull/6628)
59+
- Update `toml` dependency to 0.9.5 [#6652](https://github.com/rust-lang/rustfmt/pull/6652)
60+
61+
362
## [1.8.0] 2024-09-20
463

564
### Fixed
@@ -39,7 +98,7 @@
3998
use std::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64};
4099
```
41100
[style guide's version sorting algorithm]: https://doc.rust-lang.org/nightly/style-guide/#sorting
42-
- When parsing rustfmt configurations fails, rustfmt will now include the path to the toml file in the erorr message [#6302](https://github.com/rust-lang/rustfmt/issues/6302)
101+
- When parsing rustfmt configurations fails, rustfmt will now include the path to the toml file in the error message [#6302](https://github.com/rust-lang/rustfmt/issues/6302)
43102

44103
### Added
45104
- rustfmt now formats trailing where clauses in type aliases [#5887](https://github.com/rust-lang/rustfmt/pull/5887)
@@ -133,7 +192,7 @@
133192
### Changed
134193

135194
- `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).
136-
- 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)
195+
- The diff output produced by `rustfmt --check` is more compatible with editors that support navigating directly to line numbers [#5971](https://github.com/rust-lang/rustfmt/pull/5971)
137196
- 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).
138197

139198
[log crate]: https://crates.io/crates/log
@@ -298,7 +357,7 @@
298357

299358
### Added
300359

301-
- New configuration option [`skip_macro_invocations`](https://rust-lang.github.io/rustfmt/?version=master&search=#skip_macro_invocations) [#5347](https://github.com/rust-lang/rustfmt/pull/5347) that can be used to globally define a single enumerated list of macro calls that rustfmt should skip formatting. rustfmt [currently also supports this via a custom tool attribute](https://github.com/rust-lang/rustfmt#tips), however, these cannot be used in all contexts because [custom inner attributes are unstable](https://github.com/rust-lang/rust/issues/54726)
360+
- New configuration option [`skip_macro_invocations`](https://rust-lang.github.io/rustfmt/?version=main&search=#skip_macro_invocations) [#5347](https://github.com/rust-lang/rustfmt/pull/5347) that can be used to globally define a single enumerated list of macro calls that rustfmt should skip formatting. rustfmt [currently also supports this via a custom tool attribute](https://github.com/rust-lang/rustfmt#tips), however, these cannot be used in all contexts because [custom inner attributes are unstable](https://github.com/rust-lang/rust/issues/54726)
302361

303362
### Misc
304363

0 commit comments

Comments
 (0)