Skip to content

Commit a2ecbf8

Browse files
committed
Auto merge of #98040 - calebcartwright:sync-rustfmt, r=calebcartwright
Sync rustfmt subtree
2 parents 3bdec3c + 3733e45 commit a2ecbf8

File tree

90 files changed

+12933
-1248
lines changed

Some content is hidden

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

90 files changed

+12933
-1248
lines changed

Cargo.lock

+42-62
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ name = "annotate-snippets"
7272
version = "0.8.0"
7373
source = "registry+https://github.com/rust-lang/crates.io-index"
7474
checksum = "d78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5"
75+
76+
[[package]]
77+
name = "annotate-snippets"
78+
version = "0.9.1"
79+
source = "registry+https://github.com/rust-lang/crates.io-index"
80+
checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36"
7581
dependencies = [
82+
"unicode-width",
7683
"yansi-term",
7784
]
7885

@@ -614,6 +621,7 @@ checksum = "6d76c22c9b9b215eeb8d016ad3a90417bd13cb24cf8142756e6472445876cab7"
614621
dependencies = [
615622
"atty",
616623
"bitflags",
624+
"clap_derive",
617625
"indexmap",
618626
"lazy_static",
619627
"os_str_bytes",
@@ -631,6 +639,19 @@ dependencies = [
631639
"clap 3.1.1",
632640
]
633641

642+
[[package]]
643+
name = "clap_derive"
644+
version = "3.1.18"
645+
source = "registry+https://github.com/rust-lang/crates.io-index"
646+
checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
647+
dependencies = [
648+
"heck 0.4.0",
649+
"proc-macro-error",
650+
"proc-macro2",
651+
"quote",
652+
"syn",
653+
]
654+
634655
[[package]]
635656
name = "clippy"
636657
version = "0.1.63"
@@ -1099,11 +1120,10 @@ dependencies = [
10991120

11001121
[[package]]
11011122
name = "dirs"
1102-
version = "2.0.2"
1123+
version = "4.0.0"
11031124
source = "registry+https://github.com/rust-lang/crates.io-index"
1104-
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
1125+
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
11051126
dependencies = [
1106-
"cfg-if 0.1.10",
11071127
"dirs-sys",
11081128
]
11091129

@@ -1219,19 +1239,6 @@ dependencies = [
12191239
"termcolor",
12201240
]
12211241

1222-
[[package]]
1223-
name = "env_logger"
1224-
version = "0.8.4"
1225-
source = "registry+https://github.com/rust-lang/crates.io-index"
1226-
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
1227-
dependencies = [
1228-
"atty",
1229-
"humantime 2.0.1",
1230-
"log",
1231-
"regex",
1232-
"termcolor",
1233-
]
1234-
12351242
[[package]]
12361243
name = "env_logger"
12371244
version = "0.9.0"
@@ -1708,6 +1715,12 @@ dependencies = [
17081715
"unicode-segmentation",
17091716
]
17101717

1718+
[[package]]
1719+
name = "heck"
1720+
version = "0.4.0"
1721+
source = "registry+https://github.com/rust-lang/crates.io-index"
1722+
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
1723+
17111724
[[package]]
17121725
name = "hermit-abi"
17131726
version = "0.1.19"
@@ -3290,7 +3303,7 @@ dependencies = [
32903303
"difference",
32913304
"env_logger 0.9.0",
32923305
"futures 0.3.19",
3293-
"heck",
3306+
"heck 0.3.1",
32943307
"home",
32953308
"itertools",
32963309
"jsonrpc-core",
@@ -3500,6 +3513,7 @@ version = "1.0.0"
35003513
dependencies = [
35013514
"bstr",
35023515
"byteorder",
3516+
"clap 3.1.1",
35033517
"crossbeam-utils",
35043518
"libc",
35053519
"libz-sys",
@@ -3834,7 +3848,7 @@ dependencies = [
38343848
name = "rustc_errors"
38353849
version = "0.0.0"
38363850
dependencies = [
3837-
"annotate-snippets",
3851+
"annotate-snippets 0.8.0",
38383852
"atty",
38393853
"rustc_data_structures",
38403854
"rustc_error_messages",
@@ -4085,7 +4099,7 @@ dependencies = [
40854099
name = "rustc_macros"
40864100
version = "0.1.0"
40874101
dependencies = [
4088-
"annotate-snippets",
4102+
"annotate-snippets 0.8.0",
40894103
"fluent-bundle",
40904104
"fluent-syntax",
40914105
"proc-macro2",
@@ -4687,16 +4701,17 @@ dependencies = [
46874701

46884702
[[package]]
46894703
name = "rustfmt-nightly"
4690-
version = "1.4.38"
4704+
version = "1.5.0"
46914705
dependencies = [
4692-
"annotate-snippets",
4706+
"annotate-snippets 0.9.1",
46934707
"anyhow",
46944708
"bytecount",
46954709
"cargo_metadata",
4710+
"clap 3.1.1",
46964711
"derive-new",
46974712
"diff",
46984713
"dirs",
4699-
"env_logger 0.8.4",
4714+
"env_logger 0.9.0",
47004715
"getopts",
47014716
"ignore",
47024717
"itertools",
@@ -4707,8 +4722,7 @@ dependencies = [
47074722
"rustfmt-config_proc_macro",
47084723
"serde",
47094724
"serde_json",
4710-
"structopt",
4711-
"term 0.6.1",
4725+
"term",
47124726
"thiserror",
47134727
"toml",
47144728
"unicode-segmentation",
@@ -5096,30 +5110,6 @@ version = "0.10.0"
50965110
source = "registry+https://github.com/rust-lang/crates.io-index"
50975111
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
50985112

5099-
[[package]]
5100-
name = "structopt"
5101-
version = "0.3.25"
5102-
source = "registry+https://github.com/rust-lang/crates.io-index"
5103-
checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c"
5104-
dependencies = [
5105-
"clap 2.34.0",
5106-
"lazy_static",
5107-
"structopt-derive",
5108-
]
5109-
5110-
[[package]]
5111-
name = "structopt-derive"
5112-
version = "0.4.18"
5113-
source = "registry+https://github.com/rust-lang/crates.io-index"
5114-
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
5115-
dependencies = [
5116-
"heck",
5117-
"proc-macro-error",
5118-
"proc-macro2",
5119-
"quote",
5120-
"syn",
5121-
]
5122-
51235113
[[package]]
51245114
name = "strum"
51255115
version = "0.18.0"
@@ -5132,7 +5122,7 @@ version = "0.18.0"
51325122
source = "registry+https://github.com/rust-lang/crates.io-index"
51335123
checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c"
51345124
dependencies = [
5135-
"heck",
5125+
"heck 0.3.1",
51365126
"proc-macro2",
51375127
"quote",
51385128
"syn",
@@ -5212,16 +5202,6 @@ dependencies = [
52125202
"utf-8",
52135203
]
52145204

5215-
[[package]]
5216-
name = "term"
5217-
version = "0.6.1"
5218-
source = "registry+https://github.com/rust-lang/crates.io-index"
5219-
checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5"
5220-
dependencies = [
5221-
"dirs",
5222-
"winapi",
5223-
]
5224-
52255205
[[package]]
52265206
name = "term"
52275207
version = "0.7.0"
@@ -5276,7 +5256,7 @@ dependencies = [
52765256
"getopts",
52775257
"libc",
52785258
"num_cpus",
5279-
"term 0.7.0",
5259+
"term",
52805260
]
52815261

52825262
[[package]]
@@ -5705,9 +5685,9 @@ dependencies = [
57055685

57065686
[[package]]
57075687
name = "unicode-segmentation"
5708-
version = "1.6.0"
5688+
version = "1.9.0"
57095689
source = "registry+https://github.com/rust-lang/crates.io-index"
5710-
checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
5690+
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
57115691

57125692
[[package]]
57135693
name = "unicode-width"

src/tools/rustc-workspace-hack/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ features = [
7373
[dependencies]
7474
bstr = { version = "0.2.13", features = ["default"] }
7575
byteorder = { version = "1", features = ['default', 'std'] }
76+
clap = { version = "3.1.1", features = ["lazy_static", "derive", "clap_derive"]}
7677
curl-sys = { version = "0.4.13", features = ["http2", "libnghttp2-sys"], optional = true }
7778
crossbeam-utils = { version = "0.8.0", features = ["nightly"] }
7879
libc = { version = "0.2.79", features = ["align"] }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969

7070
steps:
7171
- name: checkout
72-
uses: actions/checkout@v2
72+
uses: actions/checkout@v3
7373

7474
# Run build
7575
- name: install rustup

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
steps:
2828
- name: checkout
29-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
3030

3131
# Run build
3232
- name: install rustup

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: checkout
26-
uses: actions/checkout@v2
26+
uses: actions/checkout@v3
2727

2828
# Run build
2929
- name: install rustup

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: rustdoc check
1212
steps:
1313
- name: checkout
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1515

1616
- name: install rustup
1717
run: |

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
target: x86_64-pc-windows-msvc
3232
runs-on: ${{ matrix.os }}
3333
steps:
34-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v3
3535

3636
# Run build
3737
- name: install rustup

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: disable git eol translation
3434
run: git config --global core.autocrlf false
3535
- name: checkout
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v3
3737

3838
# Run build
3939
- name: Install Rustup using win.rustup.rs

src/tools/rustfmt/CHANGELOG.md

+75-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,82 @@
22

33
## [Unreleased]
44

5-
### Fixed
5+
## [1.5.0] 2022-06-13
6+
7+
### Changed
8+
9+
- Simplify the rustfmt help text by eliding the full path to the rustfmt binary path from the usage string when running `rustfmt --help` [#5214](https://github.com/rust-lang/rustfmt/issues/5214)
10+
11+
### Fixed
12+
13+
- Remove duplicate imports when `imports_granularity` is set to `Item` [#4725](https://github.com/rust-lang/rustfmt/issues/4725)
14+
- Properly handle stdin input containing an inner skip attribute [#5368](https://github.com/rust-lang/rustfmt/issues/5368)
15+
- Maintain attributes on imports when `imports_granularity` is set to `Item` [#5030](https://github.com/rust-lang/rustfmt/issues/5030)
16+
- Format empty trait definitions as a single line when both `empty_item_single_line` is enabled and `brace_style` is set to `AlwaysNextLine` [#5047](https://github.com/rust-lang/rustfmt/issues/5047)
17+
- Don't change granularity of imports containing comments with `imports_granularity` if doing so could lose or misplace those comments [#5311](https://github.com/rust-lang/rustfmt/pull/5311)
18+
- Prevent rustfmt from removing trailing comments at the end of files annotated with inner `#![rustfmt::skip]` attributes [#5033](https://github.com/rust-lang/rustfmt/issues/5033)
19+
- Fixed various `error[internal]: left behind trailing whitespace"` issues:
20+
- Remove trailing whitespace when formatting a where clause who's bounds have an empty right hand side [#5012](https://github.com/rust-lang/rustfmt/issues/5012) [#4850](https://github.com/rust-lang/rustfmt/issues/4850)
21+
- Prevent rustfmt from adding an empty comment line when rewriting markdown lists at the start of doc comments. This issue was triggered when `wrap_comments=true` [#5088](https://github.com/rust-lang/rustfmt/issues/5088)
22+
- Prevent adding a block indented newline before a function parameter with a complex type that was formatted over multiple lines [#5125](https://github.com/rust-lang/rustfmt/issues/5125)
23+
- Fix various module resolution issues preventing rustfmt from finding modules that should be formatted:
24+
- Handle external mods imported via external->inline load hierarchy [#5063](https://github.com/rust-lang/rustfmt/issues/5063)
25+
- Resolve sub modules of integration tests [#5119](https://github.com/rust-lang/rustfmt/issues/5119)
26+
- Module resolution will fallback to the current search directory if a relative directory search results in a `FileNotFound` error [#5198](https://github.com/rust-lang/rustfmt/issues/5198)
27+
- Give users a clearer error message when resolving a module who's file path is ambiguous (e.g `x.rs` and `x/mod.rs`). Before users were given a `File not found` error message which was confusing [#5167](https://github.com/rust-lang/rustfmt/issues/5167)
28+
- Fix various issues related to type aliases:
29+
- Prevent rustfmt from adding `= impl` to associated types defined in macro bodies [#4823](https://github.com/rust-lang/rustfmt/issues/4823)
30+
- Properly block indent type alias impl traits (TAITs) that wrap to the next line when `version=Two` is set. Before any trait bounds that wrapped to the next line would not be indented [#5027](https://github.com/rust-lang/rustfmt/issues/5027)
31+
- Prevent rustfmt from adding an `impl Trait` definition into types [#5086](https://github.com/rust-lang/rustfmt/issues/5086)
32+
- Fix cases where `normalize_comments=true` would de-normalizes some comments by changing inline comments into block comments [#4909](https://github.com/rust-lang/rustfmt/issues/4909)
33+
- Prevent rustfmt from wrapping the content of markdown [reference-style links](https://www.markdownguide.org/basic-syntax/#reference-style-links) in doc comments [#5095](https://github.com/rust-lang/rustfmt/issues/5095) [#4933](https://github.com/rust-lang/rustfmt/issues/4933)
34+
- Don't format files annotated with inner `#![rustfmt::skip]` attribute [PR #5094](https://github.com/rust-lang/rustfmt/pull/5094)
35+
- Prevent duplicate comma when struct pattern ends with `..` and `trailing_comma=Always`. For example, `let Foo { a, .. } = b;` would become `let Foo { a,, .. } = b;` [#5066](https://github.com/rust-lang/rustfmt/issues/5066)
36+
- Fix the order of `static` and `async` keywords when rewriting static async closures. The correct order is `static` and then `async` (e.g `static async || {}`) [#5149](https://github.com/rust-lang/rustfmt/issues/5149)
37+
- Retain the fully qualified path segment when rewriting struct literals in expression position. Now `<Struct as Trait>::Type` is not rewritten as `Trait::Type` [#5151](https://github.com/rust-lang/rustfmt/issues/5151)
38+
- Do not remove match arm braces from a match arm with a single `ast::ExprKind::Block` that has leading attributes. Removing the braces could lead to code that does not compile. Now rustfmt will leave the outer `{}` in place when formatting `=> {#[allow(unsafe_code)]unsafe {}}` [#4109](https://github.com/rust-lang/rustfmt/issues/4109)
39+
- Backport json emitter and stdin changes [PR #5054](https://github.com/rust-lang/rustfmt/pull/5054)
40+
- Make `--check` work when running rustfmt with input from stdin [PR #3896](https://github.com/rust-lang/rustfmt/pull/3896)
41+
- Fix `--check` with the `--files-with-diff` flag [PR #3910](https://github.com/rust-lang/rustfmt/pull/3910)
42+
- Produce valid JSON when using the JSON emitter [PR #3953](https://github.com/rust-lang/rustfmt/pull/3953)
43+
- Fix newlines in JSON output [PR #4262](https://github.com/rust-lang/rustfmt/pull/4262)
44+
- Use `<stdin>` when emitting stdin as filename [PR #4298](https://github.com/rust-lang/rustfmt/pull/4298)
45+
- Always generate some output when formatting `@generated` files via stdin even when `format_generated_files=false`. Not producing output caused rust-analyzer to delete the file content [rust-lang/rust-analyzer](https://github.com/rust-lang/rust-analyzer/issues/11285) [#5172](https://github.com/rust-lang/rustfmt/issues/5172)
46+
- Properly block indent multi-line comments in empty struct definitions. Previously, only the first comment line would be block indented. All other comment lines would be aligned with the struct definition [#4854](https://github.com/rust-lang/rustfmt/issues/4854)
47+
- Prevent rustfmt from wrapping a comment at a byte position inside a non-ascii character when `wrap_comments=true`. This prevents rustfmt from panicking when breaking on the invalid position [#5023](https://github.com/rust-lang/rustfmt/issues/5023)
48+
- Prevent rustfmt from removing commented out trailing separators (e.g commas) when rewriting lists. For example, remove the comma from a comment like this `// ...,` would lead to a scenario where the entire list could not be rewritten because the content of the comment changed [#5042](https://github.com/rust-lang/rustfmt/issues/5042)
49+
- Fix panic when `import_granularity` was set to `Module`, `One`, or `Crate` and the import use declaration contained an alias `use crate a::b as b1` [#5131](https://github.com/rust-lang/rustfmt/issues/5131)
50+
- Add a newline between generic parameters and their doc comments to prevent the generic parameters from being merged into their doc comments [#5122](https://github.com/rust-lang/rustfmt/issues/5122)
51+
- Fixes indentation issue where string literals manually broken with line continuation characters (`\`) would be incorrectly indented in macro definitions when setting `format_strings=true`[#4036](https://github.com/rust-lang/rustfmt/issues/4036)
52+
- Properly wrap and format long markdown block quotes when `wrap_comments=true` [#5157](https://github.com/rust-lang/rustfmt/issues/5157)
53+
- Prevent rustfmt from wrapping markdown headers even when `wrap_comments=true`. Wrapping the markdown headers would prevent them from being properly rendered with rustdoc [#5238](https://github.com/rust-lang/rustfmt/issues/5238)
54+
- Prevent rustfmt from removing commas between struct fields when those fields were also separated by an empty line [#4791](https://github.com/rust-lang/rustfmt/issues/4791) [#4928](https://github.com/rust-lang/rustfmt/issues/4928)
55+
- Fix compiler error caused when formatting imports with `imports_granularity=Module` and a path containing `self`. Given the following import `use crate::lexer::{self, tokens::TokenData};`, rustfmt would transform the `self` import into `use crate::lexer::self;`. Now rustfmt produces `use crate::lexer::{self};` [#4681](https://github.com/rust-lang/rustfmt/issues/4681)
56+
- Prevent rustfmt from breaking long type links in doc comments on namespace qualifiers (`::`) when `wrap_comments=true`. Breaking these long type links over multiple lines prevented them from being properly rendered in rustdoc [#5260](https://github.com/rust-lang/rustfmt/issues/5260)
57+
- Correctly find the start of struct bodies after any generic `const` parameters. Naively searching for an opening `{` lead to issues since generic `const` parameters are also defined with `{}` (e.g. `struct Example<const N: usize = { 1048576 }> {}`) [#5273](https://github.com/rust-lang/rustfmt/issues/5273)
58+
- Prevent rustfmt from merging derives when using inner or outer `rustfmt::skip::attributes` attributes. For example, `#[rustfmt::skip::attributes(derive)]` [#5270](https://github.com/rust-lang/rustfmt/issues/5270)
59+
- Retain trailing `;` when rewriting macro calls in extern blocks. For example, `extern "C" { x!(-); }`[#5281](https://github.com/rust-lang/rustfmt/issues/5281)
60+
- Add a newline when formatting struct fields preceded by both doc comments and inline comments to prevent the field from being merged into the inline comment. This was not an issue when a struct was preceded by just a doc comment or just an inline comment [#5215](https://github.com/rust-lang/rustfmt/issues/5215)
61+
62+
### Added
63+
64+
- Added `One` as a new [group_imports](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#group_imports) option to create a single group for all imports [PR #4966](https://github.com/rust-lang/rustfmt/pull/4966)
65+
- Add [short_array_element_width_threshold](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#short_array_element_width_threshold) config option to give users more control over when `Mixed` list formatting is used [PR #5228](https://github.com/rust-lang/rustfmt/pull/5228)
666

7-
- Fixes issue where wrapped strings would be incorrectly indented in macro defs when `format_strings` was enabled [#4036](https://github.com/rust-lang/rustfmt/issues/4036)
67+
### Removed
68+
69+
- Removed unstable, nightly-only config option `report_todo` [#5101](https://github.com/rust-lang/rustfmt/issues/5101)
70+
- Removed unstable, nightly-only config option `report_fixme` [#5102](https://github.com/rust-lang/rustfmt/issues/5102)
71+
- Removed unstable, nightly-only config option `license_template_path` [#5103](https://github.com/rust-lang/rustfmt/issues/5103)
72+
73+
### Misc
74+
75+
- Improved performance when formatting large and deeply nested expression trees, often found in generated code, which have many expressions that exceed `max_width` [#5128](https://github.com/rust-lang/rustfmt/issues/5128), [#4867](https://github.com/rust-lang/rustfmt/issues/4867), [#4476](https://github.com/rust-lang/rustfmt/issues/4476), [#5139](https://github.com/rust-lang/rustfmt/pull/5139)
76+
77+
### Install/Download Options
78+
- **rustup (nightly)** - *pending*
79+
- **GitHub Release Binaries** - [Release v1.5.0](https://github.com/rust-lang/rustfmt/releases/tag/v1.5.0)
80+
- **Build from source** - [Tag v1.5.0](https://github.com/rust-lang/rustfmt/tree/v1.5.0), see instructions for how to [install rustfmt from source][install-from-source]
881

982
## [1.4.38] 2021-10-20
1083

0 commit comments

Comments
 (0)