Skip to content

Commit e7d87ad

Browse files
Merge remote-tracking branch 'upstream/master' into subtree-sync-2023-01-24
2 parents 19c2286 + aae222c commit e7d87ad

File tree

109 files changed

+2561
-185
lines changed

Some content is hidden

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

109 files changed

+2561
-185
lines changed

.github/workflows/check_diff.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Diff Check
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
clone_url:
6+
description: 'Git url of a rustfmt fork to compare against the latest master rustfmt'
7+
required: true
8+
branch_name:
9+
description: 'Name of the feature branch on the forked repo'
10+
required: true
11+
commit_hash:
12+
description: 'Optional commit hash from the feature branch'
13+
required: false
14+
rustfmt_configs:
15+
description: 'Optional comma separated list of rustfmt config options to pass when running the feature branch'
16+
required: false
17+
18+
jobs:
19+
diff_check:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: checkout
24+
uses: actions/checkout@v3
25+
26+
- name: install rustup
27+
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
31+
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.rustfmt_configs }}

.github/workflows/integration.yml

-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
tempdir,
2828
futures-rs,
2929
rust-clippy,
30-
failure,
3130
]
3231
include:
3332
# Allowed Failures
@@ -63,9 +62,6 @@ jobs:
6362
# Original comment was: temporal build failure due to breaking changes in the nightly compiler
6463
- integration: rust-semverver
6564
allow-failure: true
66-
# Can be moved back to include section after https://github.com/rust-lang-nursery/failure/pull/298 is merged
67-
- integration: failure
68-
allow-failure: true
6965

7066
steps:
7167
- name: checkout

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ from formatting an attribute #3665
840840
- Fix formatting of raw string literals #2983
841841
- Handle chain with try operators with spaces #2986
842842
- Use correct shape in Visual tuple rewriting #2987
843-
- Impove formatting of arguments with `visual_style = "Visual"` option #2988
843+
- Improve formatting of arguments with `visual_style = "Visual"` option #2988
844844
- Change `print_diff` to output the correct line number 992b179
845845
- Propagate errors about failing to rewrite a macro 6f318e3
846846
- Handle formatting of long function signature #3010

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ unicode-segmentation = "1.9"
5757
unicode-width = "0.1"
5858
unicode_categories = "0.1"
5959

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

6262
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
6363
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`

Configurations.md

+179-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuring Rustfmt
22

3-
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.
3+
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.
44

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

@@ -425,7 +425,7 @@ fn example() {
425425

426426
## `comment_width`
427427

428-
Maximum length of comments. No effect unless`wrap_comments = true`.
428+
Maximum length of comments. No effect unless `wrap_comments = true`.
429429

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

591591
```rust
592-
enum Bar {
592+
enum Foo {
593593
A = 0,
594594
Bb = 1,
595595
RandomLongVariantGoesHere = 10,
@@ -645,7 +645,8 @@ trailing whitespaces.
645645

646646
## `fn_args_layout`
647647

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

650651
- **Default value**: `"Tall"`
651652
- **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
@@ -753,6 +754,8 @@ trait Lorem {
753754
}
754755
```
755756

757+
See also [`fn_params_layout`](#fn_params_layout)
758+
756759
## `fn_call_width`
757760

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

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

771+
## `fn_params_layout`
772+
773+
Control the layout of parameters in function signatures.
774+
775+
- **Default value**: `"Tall"`
776+
- **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
777+
- **Stable**: Yes
778+
779+
#### `"Tall"` (default):
780+
781+
```rust
782+
trait Lorem {
783+
fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
784+
785+
fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
786+
// body
787+
}
788+
789+
fn lorem(
790+
ipsum: Ipsum,
791+
dolor: Dolor,
792+
sit: Sit,
793+
amet: Amet,
794+
consectetur: Consectetur,
795+
adipiscing: Adipiscing,
796+
elit: Elit,
797+
);
798+
799+
fn lorem(
800+
ipsum: Ipsum,
801+
dolor: Dolor,
802+
sit: Sit,
803+
amet: Amet,
804+
consectetur: Consectetur,
805+
adipiscing: Adipiscing,
806+
elit: Elit,
807+
) {
808+
// body
809+
}
810+
}
811+
```
812+
813+
#### `"Compressed"`:
814+
815+
```rust
816+
trait Lorem {
817+
fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
818+
819+
fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
820+
// body
821+
}
822+
823+
fn lorem(
824+
ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
825+
adipiscing: Adipiscing, elit: Elit,
826+
);
827+
828+
fn lorem(
829+
ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
830+
adipiscing: Adipiscing, elit: Elit,
831+
) {
832+
// body
833+
}
834+
}
835+
```
836+
837+
#### `"Vertical"`:
838+
839+
```rust
840+
trait Lorem {
841+
fn lorem(
842+
ipsum: Ipsum,
843+
dolor: Dolor,
844+
sit: Sit,
845+
amet: Amet,
846+
);
847+
848+
fn lorem(
849+
ipsum: Ipsum,
850+
dolor: Dolor,
851+
sit: Sit,
852+
amet: Amet,
853+
) {
854+
// body
855+
}
856+
857+
fn lorem(
858+
ipsum: Ipsum,
859+
dolor: Dolor,
860+
sit: Sit,
861+
amet: Amet,
862+
consectetur: Consectetur,
863+
adipiscing: Adipiscing,
864+
elit: Elit,
865+
);
866+
867+
fn lorem(
868+
ipsum: Ipsum,
869+
dolor: Dolor,
870+
sit: Sit,
871+
amet: Amet,
872+
consectetur: Consectetur,
873+
adipiscing: Adipiscing,
874+
elit: Elit,
875+
) {
876+
// body
877+
}
878+
}
879+
```
880+
881+
768882
## `fn_single_line`
769883

770884
Put single-expression functions on a single line
@@ -1014,6 +1128,62 @@ macro_rules! foo {
10141128

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

1131+
## `skip_macro_invocations`
1132+
1133+
Skip formatting the bodies of macro invocations with the following names.
1134+
1135+
rustfmt will not format any macro invocation for macros with names set in this list.
1136+
Including the special value "*" will prevent any macro invocations from being formatted.
1137+
1138+
Note: This option does not have any impact on how rustfmt formats macro definitions.
1139+
1140+
- **Default value**: `[]`
1141+
- **Possible values**: a list of macro name idents, `["name_0", "name_1", ..., "*"]`
1142+
- **Stable**: No (tracking issue: [#5346](https://github.com/rust-lang/rustfmt/issues/5346))
1143+
1144+
#### `[]` (default):
1145+
1146+
rustfmt will follow its standard approach to formatting macro invocations.
1147+
1148+
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).
1149+
1150+
```rust
1151+
lorem!(
1152+
const _: u8 = 0;
1153+
);
1154+
1155+
ipsum!(
1156+
const _: u8 = 0;
1157+
);
1158+
```
1159+
1160+
#### `["lorem"]`:
1161+
1162+
The named macro invocations will be skipped.
1163+
1164+
```rust
1165+
lorem!(
1166+
const _: u8 = 0;
1167+
);
1168+
1169+
ipsum!(
1170+
const _: u8 = 0;
1171+
);
1172+
```
1173+
1174+
#### `["*"]`:
1175+
1176+
The special selector `*` will skip all macro invocations.
1177+
1178+
```rust
1179+
lorem!(
1180+
const _: u8 = 0;
1181+
);
1182+
1183+
ipsum!(
1184+
const _: u8 = 0;
1185+
);
1186+
```
10171187

10181188
## `format_strings`
10191189

@@ -1687,13 +1857,16 @@ pub enum Foo {}
16871857

16881858
## `imports_granularity`
16891859

1690-
How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
1860+
Controls how imports are structured in `use` statements. Imports will be merged or split to the configured level of granularity.
1861+
1862+
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.
1863+
1864+
Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments.
16911865

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

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

16981871
#### `Preserve` (default):
16991872

Processes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This document outlines processes regarding management of rustfmt.
22

33
# Stabilising an Option
44

5-
In this Section, we describe how to stabilise an option of the rustfmt's configration.
5+
In this Section, we describe how to stabilise an option of the rustfmt's configuration.
66

77
## Conditions
88

ci/build_and_test.bat

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set "RUSTFLAGS=-D warnings"
2+
set "RUSTFMT_CI=1"
23

34
:: Print version information
45
rustc -Vv || exit /b 1

ci/build_and_test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -euo pipefail
44

55
export RUSTFLAGS="-D warnings"
6+
export RUSTFMT_CI=1
67

78
# Print version information
89
rustc -Vv

0 commit comments

Comments
 (0)