Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync rustfmt subtree #107275

Merged
merged 84 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ac595dd
Merge commit 'c4416f20dcaec5d93077f72470e83e150fb923b1' into sync-rus…
calebcartwright Jun 23, 2022
b3d4fb4
Allow `#[ignore]` tests to run in rustfmt's test suite
ytmimi Jun 21, 2022
2ae63f0
config_type: add unstable_variant attribute
tommilligan Jun 10, 2022
45f4f6c
ast: Add span to `Extern`
aDotInTheVoid Jul 2, 2022
35f4c55
refactor: remove some unnecessary clones
calebcartwright Jul 4, 2022
2403f82
Add test case for issue 1306 which was resolved
ytmimi Jul 9, 2022
2964d0a
implement rustfmt formatting for `for<>` closure binders
WaffleLapkin Jun 30, 2022
f026688
Add rustfmt test for formatting `for<>` before closures
WaffleLapkin Jul 3, 2022
c240f3a
feat: add skip_macro_invocations option (#5347)
tommilligan Jul 13, 2022
0cb294f
Deprecate and Rename `fn_args_layout` -> `fn_params_layout`
ytmimi Jun 16, 2022
dde2831
docs: fix duplicated names example
waynewaynetsai Jul 16, 2022
85fdf8e
Remove useless conditional compilation - 2
Urgau Jul 17, 2022
a7bf009
Fix/comments inside trait generics gets duplicated (#5446)
jmj0502 Jul 18, 2022
05332b8
Add test for issue 3033
ytmimi Jul 19, 2022
f2c31ba
Add tests for issue 2534
ytmimi Jul 19, 2022
4c78c73
Add tests for 3245 and 3561
ytmimi Jul 19, 2022
c19b145
test for issue 3164
ytmimi Jul 20, 2022
a451a39
Add test for issue 4350
ytmimi Jul 20, 2022
ed77962
Improvements: Adding tests for the issue-4643.
jmj0502 Jul 26, 2022
7432422
Update Configurations.md to point to dirs 4.0 docs
aizpurua23a Jul 27, 2022
a7801aa
Add test for issue 3987
ytmimi Jul 26, 2022
af72f7a
Remove `TreeAndSpacing`.
nnethercote Jul 28, 2022
7cc1261
feat: nicer skip context for macro/attribute
tommilligan Jul 20, 2022
3fa81c6
[review] use extend trait, enum for skip context
tommilligan Jul 20, 2022
23ef4b7
refactor(chains): encapsulate shared code, prep for overflows
calebcartwright Jul 31, 2022
662702e
Fix typos (#5486)
alex-semenyuk Aug 6, 2022
a392dd1
Merge remote-tracking branch 'upstream/master' into subtree-sync-2022…
calebcartwright Aug 7, 2022
5a1ef3c
chore: bump toolchain
calebcartwright Aug 7, 2022
437de8d
chore: disable unreachable pub lint on config items
calebcartwright Aug 7, 2022
c78ef92
chore: fix another config unreachable-pub
calebcartwright Aug 7, 2022
e041c20
Merge pull request #5487 from calebcartwright/subtree-sync-2022-08-06
calebcartwright Aug 7, 2022
a67d909
Fix some clippy issues
alex-semenyuk Aug 8, 2022
ea017d7
Backport PR #4730 (#5390)
davidBar-On Aug 9, 2022
76be14b
Do not consider method call receiver as an argument in AST.
cjgillot Aug 7, 2022
949da52
Add GitHub Action to test master rustfmt formatting vs a feature branch
ytmimi Aug 1, 2022
edb616d
errors: move translation logic into module
davidtwco Aug 10, 2022
e97825e
Shrink `ast::Attribute`.
nnethercote Aug 11, 2022
e5b5f56
Rename some things related to literals.
nnethercote Aug 1, 2022
870ed72
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
matthiaskrgr Aug 17, 2022
6884e04
Rollup merge of #100379 - davidtwco:triagebot-diag, r=Mark-Simulacrum
matthiaskrgr Aug 17, 2022
38659ec
Unicode comment align (#5505)
A-Walrus Aug 18, 2022
05a0dfe
Use `AttrVec` in more places.
nnethercote Aug 17, 2022
7852b88
Stabilize `#![feature(label_break_value)]`
jyn514 Jul 14, 2022
a5b6bc6
Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petroc…
JohnTitor Aug 24, 2022
ddda7bb
Sunset RLS
ehuss Aug 21, 2022
748b031
Stabilize GATs
jackh726 May 4, 2022
e40972e
rustfmt: BindingAnnotation change
camsteffen Aug 30, 2022
c9e47e7
Auto merge of #96709 - jackh726:gats-stabilization, r=compiler-errors
bors Sep 13, 2022
ef91154
docs: expand behavior of imports_granularity re: groups (#5543)
calebcartwright Sep 19, 2022
d71413c
Rename AssocItemKind::TyAlias to AssocItemKind::Type
compiler-errors Oct 10, 2022
7402dad
merge rustc history
RalfJung Oct 10, 2022
7cc303f
Fix unclosed HTML tag in rustfmt doc
GuillaumeGomez Oct 10, 2022
e5a0426
merge rustc history
RalfJung Oct 12, 2022
657dcf2
Implement -Ztrack-diagnostics
Oct 18, 2022
aa3ac27
merge rustc history
RalfJung Oct 21, 2022
5fee21f
Auto merge of #103217 - mejrs:track, r=eholk
bors Nov 1, 2022
eb07a5e
Remove `failure` integration test
JohnTitor Oct 24, 2022
ad9fb89
Update Git repo URLs
JohnTitor Oct 24, 2022
ee2bed9
Fix spacing
atouchet Nov 6, 2022
660e535
Introduce `ExprKind::IncludedBytes`
clubby789 Oct 31, 2022
826fb78
Use `token::Lit` in `ast::ExprKind::Lit`.
nnethercote Oct 10, 2022
4a4addc
Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, typ…
nnethercote Sep 8, 2022
1343ffd
Split `MacArgs` in two.
nnethercote Nov 18, 2022
3d44530
Fix rustfmt
estebank Nov 3, 2022
cdff11c
Rename `ast::Lit` as `ast::MetaItemLit`.
nnethercote Nov 23, 2022
c7e4abd
Rename `NestedMetaItem::[Ll]iteral` as `NestedMetaItem::[Ll]it`.
nnethercote Nov 24, 2022
749c816
Keep track of the start of the argument block of a closure
SarthakSingh31 Nov 9, 2022
46f0b38
rustc_ast_lowering: Stop lowering imports into multiple items
petrochenkov Dec 1, 2022
c91dd22
Remove `token::Lit` from `ast::MetaItemLit`.
nnethercote Nov 29, 2022
2119f7d
Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillot
matthiaskrgr Dec 3, 2022
53ca259
Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
bors Dec 12, 2022
ac8eaa1
Rename `Rptr` to `Ref` in AST and HIR
Noratrieb Dec 28, 2022
d7fa2ee
Add missing extern crate rustc_driver
bjorn3 Dec 12, 2022
664c60a
Detect closures assigned to binding in block
estebank Jan 5, 2023
8c8aa38
Change `src/test` to `tests` in source files, fix tidy and tests
albertlarsan68 Jan 5, 2023
19c2286
parse const closures
fee1-dead Dec 20, 2022
aae222c
fix: correct span for structs with const generics
calebcartwright Jan 23, 2023
e7d87ad
Merge remote-tracking branch 'upstream/master' into subtree-sync-2023…
calebcartwright Jan 24, 2023
18dd075
chore: bump toolchain
calebcartwright Jan 24, 2023
6eeb4fd
Merge pull request #5670 from calebcartwright/subtree-sync-2023-01-24
calebcartwright Jan 24, 2023
5139b14
fix: version gate changes for multiline single generic bound
calebcartwright Jan 24, 2023
1d8491b
chore: prep v1.5.2 release
calebcartwright Jan 24, 2023
8e1e67d
Merge commit '1d8491b120223272b13451fc81265aa64f7f4d5b' into sync-fro…
calebcartwright Jan 24, 2023
6bf1a87
update rustfmt subtree version in lockfile
calebcartwright Jan 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4926,7 +4926,7 @@ dependencies = [

[[package]]
name = "rustfmt-config_proc_macro"
version = "0.2.0"
version = "0.3.0"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -4936,7 +4936,7 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.5.1"
version = "1.5.2"
dependencies = [
"annotate-snippets",
"anyhow",
Expand Down
33 changes: 33 additions & 0 deletions src/tools/rustfmt/.github/workflows/check_diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Diff Check
on:
workflow_dispatch:
inputs:
clone_url:
description: 'Git url of a rustfmt fork to compare against the latest master rustfmt'
required: true
branch_name:
description: 'Name of the feature branch on the forked repo'
required: true
commit_hash:
description: 'Optional commit hash from the feature branch'
required: false
rustfmt_configs:
description: 'Optional comma separated list of rustfmt config options to pass when running the feature branch'
required: false

jobs:
diff_check:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

- 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 x86_64-unknown-linux-gnu

- name: check diff
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.rustfmt_configs }}
4 changes: 0 additions & 4 deletions src/tools/rustfmt/.github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
tempdir,
futures-rs,
rust-clippy,
failure,
]
include:
# Allowed Failures
Expand Down Expand Up @@ -63,9 +62,6 @@ jobs:
# Original comment was: temporal build failure due to breaking changes in the nightly compiler
- integration: rust-semverver
allow-failure: true
# Can be moved back to include section after https://github.com/rust-lang-nursery/failure/pull/298 is merged
- integration: failure
allow-failure: true

steps:
- name: checkout
Expand Down
28 changes: 27 additions & 1 deletion src/tools/rustfmt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

## [Unreleased]

## [1.5.2] 2023-01-24

### Fixed

- Resolve issue when comments are found within const generic defaults in unit structs [#5668](https://github.com/rust-lang/rustfmt/issues/5668)
- Resolve issue when block comments are found within trait generics [#5358](https://github.com/rust-lang/rustfmt/issues/5358)
- Correctly handle alignment of comments containing unicode characters [#5504](https://github.com/rust-lang/rustfmt/issues/5504)
- Properly indent a single generic bound that requires being written across multiple lines [#4689](https://github.com/rust-lang/rustfmt/issues/4689) (n.b. this change is version gated and will only appear when the `version` configuration option is set to `Two`)

### Changed

- Renamed `fn_args_layout` configuration option to `fn_params_layout` [#4149](https://github.com/rust-lang/rustfmt/issues/4149). Note that `fn_args_layout` has only been soft deprecated: `fn_args_layout` will continue to work without issue, but rustfmt will display a warning to encourage users to switch to the new name

### Added

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

### Misc

- rustfmt now internally supports the ability to have both stable and unstable variants of a configuration option [#5378](https://github.com/rust-lang/rustfmt/issues/5378). This ability will allow the rustfmt team to make certain configuration options available on stable toolchains more quickly because we no longer have to wait for _every_ variant to be stable-ready before stabilizing _any_ variant.

### Install/Download Options
- **rustup (nightly)** - nightly-2023-01-24
- **GitHub Release Binaries** - [Release v1.5.2](https://github.com/rust-lang/rustfmt/releases/tag/v1.5.2)
- **Build from source** - [Tag v1.5.2](https://github.com/rust-lang/rustfmt/tree/v1.5.2), see instructions for how to [install rustfmt from source][install-from-source]

## [1.5.1] 2022-06-24

**N.B** A bug was introduced in v1.5.0/nightly-2022-06-15 which modified formatting. If you happened to run rustfmt over your code with one of those ~10 nightlies it's possible you may have seen formatting changes, and you may see additional changes after this fix since that bug has now been reverted.
Expand Down Expand Up @@ -840,7 +866,7 @@ from formatting an attribute #3665
- Fix formatting of raw string literals #2983
- Handle chain with try operators with spaces #2986
- Use correct shape in Visual tuple rewriting #2987
- Impove formatting of arguments with `visual_style = "Visual"` option #2988
- Improve formatting of arguments with `visual_style = "Visual"` option #2988
- Change `print_diff` to output the correct line number 992b179
- Propagate errors about failing to rewrite a macro 6f318e3
- Handle formatting of long function signature #3010
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rustfmt/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ checksum = "fc71d2faa173b74b232dedc235e3ee1696581bb132fc116fa3626d6151a1a8fb"

[[package]]
name = "rustfmt-config_proc_macro"
version = "0.2.0"
version = "0.3.0"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -485,7 +485,7 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.5.1"
version = "1.5.2"
dependencies = [
"annotate-snippets",
"anyhow",
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rustfmt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "rustfmt-nightly"
version = "1.5.1"
version = "1.5.2"
description = "Tool to find and fix Rust formatting issues"
repository = "https://github.com/rust-lang/rustfmt"
readme = "README.md"
Expand Down Expand Up @@ -57,7 +57,7 @@ unicode-segmentation = "1.9"
unicode-width = "0.1"
unicode_categories = "0.1"

rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
rustfmt-config_proc_macro = { version = "0.3", path = "config_proc_macro" }

# A noop dependency that changes in the Rust repository, it's a bit of a hack.
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
Expand Down
185 changes: 179 additions & 6 deletions src/tools/rustfmt/Configurations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuring Rustfmt

Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file. If none of these directories contain such a file, both your home directory and a directory called `rustfmt` in your [global config directory](https://docs.rs/dirs/1.0.4/dirs/fn.config_dir.html) (e.g. `.config/rustfmt/`) are checked as well.
Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file. If none of these directories contain such a file, both your home directory and a directory called `rustfmt` in your [global config directory](https://docs.rs/dirs/4.0.0/dirs/fn.config_dir.html) (e.g. `.config/rustfmt/`) are checked as well.

A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:

Expand Down Expand Up @@ -425,7 +425,7 @@ fn example() {

## `comment_width`

Maximum length of comments. No effect unless`wrap_comments = true`.
Maximum length of comments. No effect unless `wrap_comments = true`.

- **Default value**: `80`
- **Possible values**: any positive integer
Expand Down Expand Up @@ -589,7 +589,7 @@ doesn't get ignored when aligning.
#### `0` (default):

```rust
enum Bar {
enum Foo {
A = 0,
Bb = 1,
RandomLongVariantGoesHere = 10,
Expand Down Expand Up @@ -645,7 +645,8 @@ trailing whitespaces.

## `fn_args_layout`

Control the layout of arguments in a function
This option is deprecated and has been renamed to `fn_params_layout` to better communicate that
it affects the layout of parameters in function signatures.

- **Default value**: `"Tall"`
- **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
Expand Down Expand Up @@ -753,6 +754,8 @@ trait Lorem {
}
```

See also [`fn_params_layout`](#fn_params_layout)

## `fn_call_width`

Maximum width of the args of a function call before falling back to vertical formatting.
Expand All @@ -765,6 +768,117 @@ By default this option is set as a percentage of [`max_width`](#max_width) provi

See also [`max_width`](#max_width) and [`use_small_heuristics`](#use_small_heuristics)

## `fn_params_layout`

Control the layout of parameters in function signatures.

- **Default value**: `"Tall"`
- **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
- **Stable**: Yes

#### `"Tall"` (default):

```rust
trait Lorem {
fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);

fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
// body
}

fn lorem(
ipsum: Ipsum,
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit,
);

fn lorem(
ipsum: Ipsum,
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit,
) {
// body
}
}
```

#### `"Compressed"`:

```rust
trait Lorem {
fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);

fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
// body
}

fn lorem(
ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
adipiscing: Adipiscing, elit: Elit,
);

fn lorem(
ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
adipiscing: Adipiscing, elit: Elit,
) {
// body
}
}
```

#### `"Vertical"`:

```rust
trait Lorem {
fn lorem(
ipsum: Ipsum,
dolor: Dolor,
sit: Sit,
amet: Amet,
);

fn lorem(
ipsum: Ipsum,
dolor: Dolor,
sit: Sit,
amet: Amet,
) {
// body
}

fn lorem(
ipsum: Ipsum,
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit,
);

fn lorem(
ipsum: Ipsum,
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit,
) {
// body
}
}
```


## `fn_single_line`

Put single-expression functions on a single line
Expand Down Expand Up @@ -1014,6 +1128,62 @@ macro_rules! foo {

See also [`format_macro_matchers`](#format_macro_matchers).

## `skip_macro_invocations`

Skip formatting the bodies of macro invocations with the following names.

rustfmt will not format any macro invocation for macros with names set in this list.
Including the special value "*" will prevent any macro invocations from being formatted.

Note: This option does not have any impact on how rustfmt formats macro definitions.

- **Default value**: `[]`
- **Possible values**: a list of macro name idents, `["name_0", "name_1", ..., "*"]`
- **Stable**: No (tracking issue: [#5346](https://github.com/rust-lang/rustfmt/issues/5346))

#### `[]` (default):

rustfmt will follow its standard approach to formatting macro invocations.

No macro invocations will be skipped based on their name. More information about rustfmt's standard macro invocation formatting behavior can be found in [#5437](https://github.com/rust-lang/rustfmt/discussions/5437).

```rust
lorem!(
const _: u8 = 0;
);

ipsum!(
const _: u8 = 0;
);
```

#### `["lorem"]`:

The named macro invocations will be skipped.

```rust
lorem!(
const _: u8 = 0;
);

ipsum!(
const _: u8 = 0;
);
```

#### `["*"]`:

The special selector `*` will skip all macro invocations.

```rust
lorem!(
const _: u8 = 0;
);

ipsum!(
const _: u8 = 0;
);
```

## `format_strings`

Expand Down Expand Up @@ -1687,13 +1857,16 @@ pub enum Foo {}

## `imports_granularity`

How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
Controls how imports are structured in `use` statements. Imports will be merged or split to the configured level of granularity.

Similar to other `import` related configuration options, this option operates within the bounds of user-defined groups of imports. See [`group_imports`](#group_imports) for more information on import groups.

Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments.

- **Default value**: `Preserve`
- **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One`
- **Stable**: No (tracking issue: [#4991](https://github.com/rust-lang/rustfmt/issues/4991))

Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments.

#### `Preserve` (default):

Expand Down
Loading