Skip to content

Commit c400fee

Browse files
authored
Rollup merge of rust-lang#90087 - calebcartwright:rustfmt-subtree, r=calebcartwright
Sync rustfmt subtree There's a large number of small fixes and new features, but nothing too big. Detailed changelog for those interested can be found in https://github.com/rust-lang/rustfmt/blob/master/CHANGELOG.md#1438-2021-10-20
2 parents 1782d13 + 170214f commit c400fee

File tree

144 files changed

+2941
-961
lines changed

Some content is hidden

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

144 files changed

+2941
-961
lines changed

Cargo.lock

+37-43
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,23 @@ version = "1.0.1"
265265
source = "registry+https://github.com/rust-lang/crates.io-index"
266266
checksum = "81a18687293a1546b67c246452202bbbf143d239cb43494cc163da14979082da"
267267

268+
[[package]]
269+
name = "camino"
270+
version = "1.0.5"
271+
source = "registry+https://github.com/rust-lang/crates.io-index"
272+
checksum = "52d74260d9bf6944e2208aa46841b4b8f0d7ffc0849a06837b2f510337f86b2b"
273+
dependencies = [
274+
"serde",
275+
]
276+
268277
[[package]]
269278
name = "cargo"
270279
version = "0.58.0"
271280
dependencies = [
272281
"anyhow",
273282
"atty",
274283
"bytesize",
275-
"cargo-platform",
284+
"cargo-platform 0.1.2",
276285
"cargo-test-macro",
277286
"cargo-test-support",
278287
"cargo-util",
@@ -374,6 +383,15 @@ dependencies = [
374383
"serde",
375384
]
376385

386+
[[package]]
387+
name = "cargo-platform"
388+
version = "0.1.2"
389+
source = "registry+https://github.com/rust-lang/crates.io-index"
390+
checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27"
391+
dependencies = [
392+
"serde",
393+
]
394+
377395
[[package]]
378396
name = "cargo-test-macro"
379397
version = "0.1.0"
@@ -421,23 +439,24 @@ dependencies = [
421439

422440
[[package]]
423441
name = "cargo_metadata"
424-
version = "0.8.2"
442+
version = "0.12.0"
425443
source = "registry+https://github.com/rust-lang/crates.io-index"
426-
checksum = "700b3731fd7d357223d0000f4dbf1808401b694609035c3c411fbc0cd375c426"
444+
checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345"
427445
dependencies = [
428-
"semver 0.9.0",
446+
"semver 0.11.0",
429447
"serde",
430-
"serde_derive",
431448
"serde_json",
432449
]
433450

434451
[[package]]
435452
name = "cargo_metadata"
436-
version = "0.12.0"
453+
version = "0.14.0"
437454
source = "registry+https://github.com/rust-lang/crates.io-index"
438-
checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345"
455+
checksum = "c297bd3135f558552f99a0daa180876984ea2c4ffa7470314540dff8c654109a"
439456
dependencies = [
440-
"semver 0.11.0",
457+
"camino",
458+
"cargo-platform 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
459+
"semver 1.0.3",
441460
"serde",
442461
"serde_json",
443462
]
@@ -1070,9 +1089,9 @@ dependencies = [
10701089

10711090
[[package]]
10721091
name = "env_logger"
1073-
version = "0.6.2"
1092+
version = "0.7.1"
10741093
source = "registry+https://github.com/rust-lang/crates.io-index"
1075-
checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
1094+
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
10761095
dependencies = [
10771096
"atty",
10781097
"humantime 1.3.0",
@@ -1083,12 +1102,12 @@ dependencies = [
10831102

10841103
[[package]]
10851104
name = "env_logger"
1086-
version = "0.7.1"
1105+
version = "0.8.4"
10871106
source = "registry+https://github.com/rust-lang/crates.io-index"
1088-
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
1107+
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
10891108
dependencies = [
10901109
"atty",
1091-
"humantime 1.3.0",
1110+
"humantime 2.0.1",
10921111
"log",
10931112
"regex",
10941113
"termcolor",
@@ -1698,15 +1717,6 @@ version = "0.1.6"
16981717
source = "registry+https://github.com/rust-lang/crates.io-index"
16991718
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
17001719

1701-
[[package]]
1702-
name = "itertools"
1703-
version = "0.8.2"
1704-
source = "registry+https://github.com/rust-lang/crates.io-index"
1705-
checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
1706-
dependencies = [
1707-
"either",
1708-
]
1709-
17101720
[[package]]
17111721
name = "itertools"
17121722
version = "0.9.0"
@@ -4673,19 +4683,19 @@ dependencies = [
46734683

46744684
[[package]]
46754685
name = "rustfmt-nightly"
4676-
version = "1.4.37"
4686+
version = "1.4.38"
46774687
dependencies = [
46784688
"annotate-snippets",
46794689
"anyhow",
46804690
"bytecount",
4681-
"cargo_metadata 0.8.2",
4691+
"cargo_metadata 0.14.0",
46824692
"derive-new",
46834693
"diff",
46844694
"dirs",
4685-
"env_logger 0.6.2",
4695+
"env_logger 0.8.4",
46864696
"getopts",
46874697
"ignore",
4688-
"itertools 0.8.2",
4698+
"itertools 0.9.0",
46894699
"lazy_static",
46904700
"log",
46914701
"regex",
@@ -4768,23 +4778,13 @@ dependencies = [
47684778
"libc",
47694779
]
47704780

4771-
[[package]]
4772-
name = "semver"
4773-
version = "0.9.0"
4774-
source = "registry+https://github.com/rust-lang/crates.io-index"
4775-
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
4776-
dependencies = [
4777-
"semver-parser 0.7.0",
4778-
"serde",
4779-
]
4780-
47814781
[[package]]
47824782
name = "semver"
47834783
version = "0.11.0"
47844784
source = "registry+https://github.com/rust-lang/crates.io-index"
47854785
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
47864786
dependencies = [
4787-
"semver-parser 0.10.2",
4787+
"semver-parser",
47884788
"serde",
47894789
]
47904790

@@ -4797,12 +4797,6 @@ dependencies = [
47974797
"serde",
47984798
]
47994799

4800-
[[package]]
4801-
name = "semver-parser"
4802-
version = "0.7.0"
4803-
source = "registry+https://github.com/rust-lang/crates.io-index"
4804-
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
4805-
48064800
[[package]]
48074801
name = "semver-parser"
48084802
version = "0.10.2"

src/tools/rustfmt/.github/workflows/upload-assets.yml

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: upload
22

33
on:
4+
push:
45
release:
56
types: [created]
7+
workflow_dispatch:
68

79
jobs:
810
build-release:
@@ -14,42 +16,40 @@ jobs:
1416
- build: linux-x86_64
1517
os: ubuntu-latest
1618
rust: nightly
19+
target: x86_64-unknown-linux-gnu
1720
- build: macos-x86_64
1821
os: macos-latest
1922
rust: nightly
23+
target: x86_64-apple-darwin
2024
- build: windows-x86_64-gnu
2125
os: windows-latest
2226
rust: nightly-x86_64-gnu
27+
target: x86_64-pc-windows-gnu
2328
- build: windows-x86_64-msvc
2429
os: windows-latest
2530
rust: nightly-x86_64-msvc
31+
target: x86_64-pc-windows-msvc
2632
runs-on: ${{ matrix.os }}
2733
steps:
2834
- uses: actions/checkout@v2
2935

30-
- name: Install Rust
31-
uses: actions-rs/toolchain@v1
32-
with:
33-
profile: minimal
34-
toolchain: ${{ matrix.rust }}
35-
override: true
36+
# Run build
37+
- name: install rustup
38+
run: |
39+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
40+
sh rustup-init.sh -y --default-toolchain none
41+
rustup target add ${{ matrix.target }}
3642
3743
- name: Add mingw64 to path for x86_64-gnu
3844
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
3945
if: matrix.rust == 'nightly-x86_64-gnu'
4046
shell: bash
4147

42-
- name: Install cargo-make
43-
uses: actions-rs/cargo@v1
44-
with:
45-
command: install
46-
args: --force cargo-make
47-
4848
- name: Build release binaries
4949
uses: actions-rs/cargo@v1
5050
with:
51-
command: make
52-
args: release
51+
command: build
52+
args: --release
5353

5454
- name: Build archive
5555
shell: bash
@@ -70,6 +70,7 @@ jobs:
7070
fi
7171
7272
- name: Upload Release Asset
73+
if: github.event_name == 'release'
7374
uses: actions/upload-release-asset@v1
7475
env:
7576
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ jobs:
5454
if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
5555
shell: bash
5656

57-
- name: cargo-make
58-
run: cargo install --force cargo-make
59-
6057
- name: build
6158
run: |
6259
rustc -Vv

src/tools/rustfmt/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Generated by Cargo
66
# will have compiled files and executables
77
/target
8+
tests/cargo-fmt/**/target
89

910
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
1011
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock

src/tools/rustfmt/CHANGELOG.md

+67
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,73 @@
22

33
## [Unreleased]
44

5+
## [1.4.38] 2021-10-20
6+
7+
### Changed
8+
9+
- Switched from `rustc-ap-*` crates to `rustc_private` for consumption model of rustc internals
10+
- `annotate-snippets` updated to v0.8 [PR #4762](https://github.com/rust-lang/rustfmt/pull/4762)
11+
- Greatly improved the performance of `cargo fmt` in large workspaces utilizing the `--all` flag by updating to a newer version of `cargo_metadata` that leverages updated `cargo` output from v1.51+ [PR #4997](https://github.com/rust-lang/rustfmt/pull/4997)
12+
- Improved formatting of long slice patterns [#4530](https://github.com/rust-lang/rustfmt/issues/4530)
13+
- **Note you must have `version = Two` in your configuration to take advantage of the new formatting**
14+
- Stabilized `match_block_trailing_comma` configuration option [#3380](https://github.com/rust-lang/rustfmt/issues/3380) - [https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#match_block_trailing_comma](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#match_block_trailing_comma)
15+
- Stabilized `disable_all_formatting` configuration option [#5026](https://github.com/rust-lang/rustfmt/pull/5026) - [https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#disable_all_formatting](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#disable_all_formatting)
16+
- Various improvements to the configuration documentation website [https://rust-lang.github.io/rustfmt/?version=v1.4.38]([https://rust-lang.github.io/rustfmt/?version=v1.4.38])
17+
- Addressed various clippy and rustc warnings
18+
19+
20+
### Fixed
21+
22+
- Resolved issue where specious whitespace would be inserted when a block style comment was terminated within string literal processing [#4312](https://github.com/rust-lang/rustfmt/issues/4312)
23+
- Nested out-of-line mods are again parsed and formatted [#4874](https://github.com/rust-lang/rustfmt/issues/4874)
24+
- Accepts `2021` for edition value from rustfmt command line [PR #4847](https://github.com/rust-lang/rustfmt/pull/4847)
25+
- Unstable command line options are no longer displayed in `--help` text on stable [PR #4798](https://github.com/rust-lang/rustfmt/issues/4798)
26+
- Stopped panicking on patterns in match arms which start with non-ascii characters [#4868](https://github.com/rust-lang/rustfmt/issues/4868)
27+
- Stopped stripping defaults on const params [#4816](https://github.com/rust-lang/rustfmt/issues/4816)
28+
- Fixed issue with dropped content with GAT aliases with self bounds in impls [#4911](https://github.com/rust-lang/rustfmt/issues/4911)
29+
- Stopped removing generic args on associated type constraints [#4943](https://github.com/rust-lang/rustfmt/issues/4943)
30+
- Stopped dropping visibility on certain trait and impl items [#4960](https://github.com/rust-lang/rustfmt/issues/4960)
31+
- Fixed dropping of qualified paths in struct patterns [#4908](https://github.com/rust-lang/rustfmt/issues/4908) and [#5005](https://github.com/rust-lang/rustfmt/issues/5005)
32+
- Fixed bug in line width calculation that was causing specious formatting of certain patterns [#4031](https://github.com/rust-lang/rustfmt/issues/4031)
33+
- **Note that this bug fix may cause observable formatting changes in cases where code had been formatted with prior versions of rustfmt that contained the bug**
34+
- Fixed bug where rustfmt would drop parameter attributes if they were too long in certain cases [#4579](https://github.com/rust-lang/rustfmt/issues/4579)
35+
- Resolved idempotency issue with extern body elements [#4963](https://github.com/rust-lang/rustfmt/issues/4963)
36+
- rustfmt will now handle doc-style comments on function parameters, since they could appear with certain macro usage patterns even though it's generally invalid syntax [#4936](https://github.com/rust-lang/rustfmt/issues/4936)
37+
- Fixed bug in `match_block_trailing_comma` where commas were not added to the blocks of bodies whose arm had a guard that did not fit on the same line as the pattern [#4998](https://github.com/rust-lang/rustfmt/pull/4998)
38+
- Fixed bug in cases where derive attributes started with a block style comment [#4984](https://github.com/rust-lang/rustfmt/issues/4984)
39+
- Fixed issue where the struct rest could be lost when `struct_field_align_threshold` was enabled [#4926](https://github.com/rust-lang/rustfmt/issues/4926)
40+
- Handles cases where certain control flow type expressions have comments between patterns/keywords and the pattern ident contains the keyword [#5009](https://github.com/rust-lang/rustfmt/issues/5009)
41+
- Handles tuple structs that have explicit visibilities and start with a block style comment [#5011](https://github.com/rust-lang/rustfmt/issues/5011)
42+
- Handles leading line-style comments in certain types of macro calls [#4615](https://github.com/rust-lang/rustfmt/issues/4615)
43+
44+
45+
### Added
46+
- Granular width heuristic options made available for user control [PR #4782](https://github.com/rust-lang/rustfmt/pull/4782). This includes the following:
47+
- [`array_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#array_width)
48+
- [`attr_fn_like_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#attr_fn_like_width)
49+
- [`chain_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#chain_width)
50+
- [`fn_call_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#fn_call_width)
51+
- [`single_line_if_else_max_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#single_line_if_else_max_width)
52+
- [`struct_lit_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_lit_width)
53+
- [`struct_variant_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_variant_width)
54+
55+
Note this hit the rustup distributions prior to the v1.4.38 release as part of an out-of-cycle updates, but is listed in this version because the feature was not in the other v1.4.37 releases. See also the `use_small_heuristics` section on the configuration site for more information
56+
[https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics)
57+
58+
- New `One` variant added to `imports_granularity` configuration option which can be used to reformat all imports into a single use statement [#4669](https://github.com/rust-lang/rustfmt/issues/4669)
59+
- rustfmt will now skip files that are annotated with `@generated` at the top of the file [#3958](https://github.com/rust-lang/rustfmt/issues/3958)
60+
- New configuration option `hex_literal_case` that allows user to control the casing utilized for hex literals [PR #4903](https://github.com/rust-lang/rustfmt/pull/4903)
61+
62+
See the section on the configuration site for more information
63+
https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#hex_literal_case
64+
65+
- `cargo fmt` now directly supports the `--check` flag, which means it's now possible to run `cargo fmt --check` instead of the more verbose `cargo fmt -- --check` [#3888](https://github.com/rust-lang/rustfmt/issues/3888)
66+
67+
### Install/Download Options
68+
- **rustup (nightly)** - *pending*
69+
- **GitHub Release Binaries** - [Release v1.4.38](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.38)
70+
- **Build from source** - [Tag v1.4.38](https://github.com/rust-lang/rustfmt/tree/v1.4.38), see instructions for how to [install rustfmt from source][install-from-source]
71+
572
## [1.4.37] 2021-04-03
673

774
### Changed

0 commit comments

Comments
 (0)