Skip to content

Commit

Permalink
Rollup merge of #90087 - calebcartwright:rustfmt-subtree, r=calebcart…
Browse files Browse the repository at this point in the history
…wright

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
  • Loading branch information
matthiaskrgr committed Oct 23, 2021
2 parents 1782d13 + 170214f commit c400fee
Show file tree
Hide file tree
Showing 144 changed files with 2,941 additions and 961 deletions.
80 changes: 37 additions & 43 deletions Cargo.lock
Expand Up @@ -265,14 +265,23 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81a18687293a1546b67c246452202bbbf143d239cb43494cc163da14979082da"

[[package]]
name = "camino"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52d74260d9bf6944e2208aa46841b4b8f0d7ffc0849a06837b2f510337f86b2b"
dependencies = [
"serde",
]

[[package]]
name = "cargo"
version = "0.58.0"
dependencies = [
"anyhow",
"atty",
"bytesize",
"cargo-platform",
"cargo-platform 0.1.2",
"cargo-test-macro",
"cargo-test-support",
"cargo-util",
Expand Down Expand Up @@ -374,6 +383,15 @@ dependencies = [
"serde",
]

[[package]]
name = "cargo-platform"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27"
dependencies = [
"serde",
]

[[package]]
name = "cargo-test-macro"
version = "0.1.0"
Expand Down Expand Up @@ -421,23 +439,24 @@ dependencies = [

[[package]]
name = "cargo_metadata"
version = "0.8.2"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "700b3731fd7d357223d0000f4dbf1808401b694609035c3c411fbc0cd375c426"
checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345"
dependencies = [
"semver 0.9.0",
"semver 0.11.0",
"serde",
"serde_derive",
"serde_json",
]

[[package]]
name = "cargo_metadata"
version = "0.12.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345"
checksum = "c297bd3135f558552f99a0daa180876984ea2c4ffa7470314540dff8c654109a"
dependencies = [
"semver 0.11.0",
"camino",
"cargo-platform 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 1.0.3",
"serde",
"serde_json",
]
Expand Down Expand Up @@ -1070,9 +1089,9 @@ dependencies = [

[[package]]
name = "env_logger"
version = "0.6.2"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"atty",
"humantime 1.3.0",
Expand All @@ -1083,12 +1102,12 @@ dependencies = [

[[package]]
name = "env_logger"
version = "0.7.1"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"atty",
"humantime 1.3.0",
"humantime 2.0.1",
"log",
"regex",
"termcolor",
Expand Down Expand Up @@ -1698,15 +1717,6 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"

[[package]]
name = "itertools"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
dependencies = [
"either",
]

[[package]]
name = "itertools"
version = "0.9.0"
Expand Down Expand Up @@ -4673,19 +4683,19 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.4.37"
version = "1.4.38"
dependencies = [
"annotate-snippets",
"anyhow",
"bytecount",
"cargo_metadata 0.8.2",
"cargo_metadata 0.14.0",
"derive-new",
"diff",
"dirs",
"env_logger 0.6.2",
"env_logger 0.8.4",
"getopts",
"ignore",
"itertools 0.8.2",
"itertools 0.9.0",
"lazy_static",
"log",
"regex",
Expand Down Expand Up @@ -4768,23 +4778,13 @@ dependencies = [
"libc",
]

[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser 0.7.0",
"serde",
]

[[package]]
name = "semver"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
dependencies = [
"semver-parser 0.10.2",
"semver-parser",
"serde",
]

Expand All @@ -4797,12 +4797,6 @@ dependencies = [
"serde",
]

[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"

[[package]]
name = "semver-parser"
version = "0.10.2"
Expand Down
29 changes: 15 additions & 14 deletions src/tools/rustfmt/.github/workflows/upload-assets.yml
@@ -1,8 +1,10 @@
name: upload

on:
push:
release:
types: [created]
workflow_dispatch:

jobs:
build-release:
Expand All @@ -14,42 +16,40 @@ jobs:
- build: linux-x86_64
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-gnu
- build: macos-x86_64
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
- build: windows-x86_64-gnu
os: windows-latest
rust: nightly-x86_64-gnu
target: x86_64-pc-windows-gnu
- build: windows-x86_64-msvc
os: windows-latest
rust: nightly-x86_64-msvc
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
# Run build
- name: install rustup
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
rustup target add ${{ matrix.target }}
- name: Add mingw64 to path for x86_64-gnu
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
if: matrix.rust == 'nightly-x86_64-gnu'
shell: bash

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: --force cargo-make

- name: Build release binaries
uses: actions-rs/cargo@v1
with:
command: make
args: release
command: build
args: --release

- name: Build archive
shell: bash
Expand All @@ -70,6 +70,7 @@ jobs:
fi
- name: Upload Release Asset
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 0 additions & 3 deletions src/tools/rustfmt/.github/workflows/windows.yml
Expand Up @@ -54,9 +54,6 @@ jobs:
if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
shell: bash

- name: cargo-make
run: cargo install --force cargo-make

- name: build
run: |
rustc -Vv
Expand Down
1 change: 1 addition & 0 deletions src/tools/rustfmt/.gitignore
Expand Up @@ -5,6 +5,7 @@
# Generated by Cargo
# will have compiled files and executables
/target
tests/cargo-fmt/**/target

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Expand Down
67 changes: 67 additions & 0 deletions src/tools/rustfmt/CHANGELOG.md
Expand Up @@ -2,6 +2,73 @@

## [Unreleased]

## [1.4.38] 2021-10-20

### Changed

- Switched from `rustc-ap-*` crates to `rustc_private` for consumption model of rustc internals
- `annotate-snippets` updated to v0.8 [PR #4762](https://github.com/rust-lang/rustfmt/pull/4762)
- 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)
- Improved formatting of long slice patterns [#4530](https://github.com/rust-lang/rustfmt/issues/4530)
- **Note you must have `version = Two` in your configuration to take advantage of the new formatting**
- 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)
- 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)
- 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])
- Addressed various clippy and rustc warnings


### Fixed

- 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)
- Nested out-of-line mods are again parsed and formatted [#4874](https://github.com/rust-lang/rustfmt/issues/4874)
- Accepts `2021` for edition value from rustfmt command line [PR #4847](https://github.com/rust-lang/rustfmt/pull/4847)
- Unstable command line options are no longer displayed in `--help` text on stable [PR #4798](https://github.com/rust-lang/rustfmt/issues/4798)
- Stopped panicking on patterns in match arms which start with non-ascii characters [#4868](https://github.com/rust-lang/rustfmt/issues/4868)
- Stopped stripping defaults on const params [#4816](https://github.com/rust-lang/rustfmt/issues/4816)
- Fixed issue with dropped content with GAT aliases with self bounds in impls [#4911](https://github.com/rust-lang/rustfmt/issues/4911)
- Stopped removing generic args on associated type constraints [#4943](https://github.com/rust-lang/rustfmt/issues/4943)
- Stopped dropping visibility on certain trait and impl items [#4960](https://github.com/rust-lang/rustfmt/issues/4960)
- 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)
- Fixed bug in line width calculation that was causing specious formatting of certain patterns [#4031](https://github.com/rust-lang/rustfmt/issues/4031)
- **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**
- 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)
- Resolved idempotency issue with extern body elements [#4963](https://github.com/rust-lang/rustfmt/issues/4963)
- 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)
- 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)
- Fixed bug in cases where derive attributes started with a block style comment [#4984](https://github.com/rust-lang/rustfmt/issues/4984)
- 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)
- 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)
- Handles tuple structs that have explicit visibilities and start with a block style comment [#5011](https://github.com/rust-lang/rustfmt/issues/5011)
- Handles leading line-style comments in certain types of macro calls [#4615](https://github.com/rust-lang/rustfmt/issues/4615)


### Added
- Granular width heuristic options made available for user control [PR #4782](https://github.com/rust-lang/rustfmt/pull/4782). This includes the following:
- [`array_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#array_width)
- [`attr_fn_like_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#attr_fn_like_width)
- [`chain_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#chain_width)
- [`fn_call_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#fn_call_width)
- [`single_line_if_else_max_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#single_line_if_else_max_width)
- [`struct_lit_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_lit_width)
- [`struct_variant_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_variant_width)

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
[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)

- 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)
- 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)
- 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)

See the section on the configuration site for more information
https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#hex_literal_case

- `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)

### Install/Download Options
- **rustup (nightly)** - *pending*
- **GitHub Release Binaries** - [Release v1.4.38](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.38)
- **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]

## [1.4.37] 2021-04-03

### Changed
Expand Down

0 comments on commit c400fee

Please sign in to comment.