Skip to content

Commit 1ed0da9

Browse files
committed
Merge remote-tracking branch 'upstream/master' into subtree-push-nightly-2024-04-08
2 parents 31a4eae + 7289391 commit 1ed0da9

File tree

78 files changed

+884
-176
lines changed

Some content is hidden

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

78 files changed

+884
-176
lines changed

CHANGELOG.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44

5+
- Updating `dirs 4.0.0 -> 5.0.1` and `cargo_metadata 0.15.4 -> 0.18.0` [#6033] (https://github.com/rust-lang/rustfmt/issues/6033)
56

67
## [1.7.0] 2023-10-22
78

@@ -27,7 +28,7 @@
2728
}
2829
```
2930
- Prevent ICE when formatting `vec!{}` [#5735](https://github.com/rust-lang/rustfmt/issues/5735)
30-
- Prevent internal trailing whitespace error when formatting an empty `macro_rules!` defintion e.g. `macro_rules! foo {}` [#5882](https://github.com/rust-lang/rustfmt/issues/5882)
31+
- Prevent internal trailing whitespace error when formatting an empty `macro_rules!` definition e.g. `macro_rules! foo {}` [#5882](https://github.com/rust-lang/rustfmt/issues/5882)
3132
- Formatting doc comment lines that start with `.` or `)` won't be treated as ordered markdown lists because `.` or `)` must be preceded by a number to start an ordered markdown list [#5835](https://github.com/rust-lang/rustfmt/pull/5835)
3233
- Add parenthesis around closures when they're used as method receives, don't have a block body, and end with `.` [#4808](https://github.com/rust-lang/rustfmt/issues/4808)
3334
```rust
@@ -184,7 +185,7 @@
184185

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

187-
- Bumped the version for serveral dependencies. Most notably `dirs` `v2.0.1` -> `v4.0.0`. This changed the global user config directory on macOS from `$HOME/Library/Preferences` to `$HOME/Library/Application Support` [#5237](https://github.com/rust-lang/rustfmt/pull/5237)
188+
- Bumped the version for several dependencies. Most notably `dirs` `v2.0.1` -> `v4.0.0`. This changed the global user config directory on macOS from `$HOME/Library/Preferences` to `$HOME/Library/Application Support` [#5237](https://github.com/rust-lang/rustfmt/pull/5237)
188189

189190
### Fixed
190191

@@ -942,7 +943,7 @@ from formatting an attribute #3665
942943

943944
### Fixed
944945

945-
- Do not remove path disambiugator inside macro #3142
946+
- Do not remove path disambiguator inside macro #3142
946947
- Improve handling of Windows newlines #3141
947948
- Fix alignment of a struct's fields (`struct_field_align_threshold` option) with the Visual `indent_style` #3165
948949
- Fix a bug in formatting markdown lists within comments #3172
@@ -1031,7 +1032,7 @@ from formatting an attribute #3665
10311032

10321033
### Changed
10331034

1034-
- Replace '--conifig-help' with '--config=help' cb10e06
1035+
- Replace '--config-help' with '--config=help' cb10e06
10351036
- Improve formatting of slice patterns #2912
10361037

10371038
### Fixed
@@ -1075,7 +1076,7 @@ from formatting an attribute #3665
10751076
- Add max_width option for all heuristics c2ae39e
10761077
- Add config option `format_macro_matchers` to format the metavariable matching patterns in macros 79c5ee8
10771078
- Add config option `format_macro_bodies` to format the bodies of macros 79c5ee8
1078-
- Format exitential type fc307ff
1079+
- Format existential type fc307ff
10791080
- Support raw identifiers in struct expressions f121b1a
10801081
- Format Async block and async function 0b25f60
10811082

@@ -1131,7 +1132,7 @@ from formatting an attribute #3665
11311132

11321133
### Changed
11331134

1134-
- Update rustc-ap-syntax to 128.0.0 and ustc-ap-rustc_target to 128.0.0 195395f
1135+
- Update rustc-ap-syntax to 128.0.0 and rustc-ap-rustc_target to 128.0.0 195395f
11351136
- Put operands on its own line when each fits in a single line f8439ce
11361137
- Improve CLI options 55ac062 1869888 798bffb 4d9de48 eca7796 8396da1 5d9f5aa
11371138

@@ -1195,7 +1196,7 @@ from formatting an attribute #3665
11951196
- Do not collapse block around expr with condition on match arm 5b9b7d5
11961197
- Use vertical layout for complex attributes c77708f
11971198
- Format array using heuristics for function calls 98c6f7b
1198-
- Implement stable ordering for impl items with the the following item priority: type, const, macro, then method fa80ddf
1199+
- Implement stable ordering for impl items with the following item priority: type, const, macro, then method fa80ddf
11991200
- Reorder imports by default 164cf7d
12001201
- Group `extern crate` by default 3a138a2
12011202
- Make `error_on_line_overflow` false by default f146711

Cargo.lock

Lines changed: 16 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ generic-simd = ["bytecount/generic-simd"]
3636
annotate-snippets = { version = "0.9", features = ["color"] }
3737
anyhow = "1.0"
3838
bytecount = "0.6.4"
39-
cargo_metadata = "0.15.4"
39+
cargo_metadata = "0.18"
4040
clap = { version = "4.4.2", features = ["derive"] }
4141
clap-cargo = "0.12.0"
4242
diff = "0.1"
43-
dirs = "4.0"
43+
dirs = "5.0"
4444
getopts = "0.2"
4545
ignore = "0.4"
4646
itertools = "0.11"

Configurations.md

Lines changed: 24 additions & 6 deletions
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/4.0.0/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/5.0.1/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

@@ -1050,15 +1050,25 @@ Max width for code snippets included in doc comments. Only used if [`format_code
10501050

10511051
## `format_generated_files`
10521052

1053-
Format generated files. A file is considered generated
1054-
if any of the first five lines contain a `@generated` comment marker.
1053+
Format generated files. A file is considered generated if any of the first several lines contain a `@generated` comment marker. The number of lines to check is configured by `generated_marker_line_search_limit`.
1054+
10551055
By default, generated files are reformatted, i. e. `@generated` marker is ignored.
10561056
This option is currently ignored for stdin (`@generated` in stdin is ignored.)
10571057

10581058
- **Default value**: `true`
10591059
- **Possible values**: `true`, `false`
10601060
- **Stable**: No (tracking issue: [#5080](https://github.com/rust-lang/rustfmt/issues/5080))
10611061

1062+
## `generated_marker_line_search_limit`
1063+
1064+
Number of lines to check for a `@generated` pragma header, starting from the top of the file. Setting this value to `0` will treat all files as non-generated. When`format_generated_files` is `true`, this option has no effect.
1065+
1066+
- **Default value**: `5`
1067+
- **Possible values**: any positive integer
1068+
- **Stable**: No (tracking issue: [#5080](https://github.com/rust-lang/rustfmt/issues/5080))
1069+
1070+
See also [format_generated_files](#format_generated_files) link here.
1071+
10621072
## `format_macro_matchers`
10631073

10641074
Format the metavariable matching patterns in macros.
@@ -1098,7 +1108,7 @@ See also [`format_macro_bodies`](#format_macro_bodies).
10981108

10991109
## `format_macro_bodies`
11001110

1101-
Format the bodies of macros.
1111+
Format the bodies of declarative macro definitions.
11021112

11031113
- **Default value**: `true`
11041114
- **Possible values**: `true`, `false`
@@ -1248,12 +1258,20 @@ Control the case of the letters in hexadecimal literal values
12481258

12491259
## `hide_parse_errors`
12501260

1251-
Do not show parse errors if the parser failed to parse files.
1261+
This option is deprecated and has been renamed to `show_parse_errors` to avoid confusion around the double negative default of `hide_parse_errors=false`.
12521262

12531263
- **Default value**: `false`
12541264
- **Possible values**: `true`, `false`
12551265
- **Stable**: No (tracking issue: [#3390](https://github.com/rust-lang/rustfmt/issues/3390))
12561266

1267+
## `show_parse_errors`
1268+
1269+
Show parse errors if the parser failed to parse files.
1270+
1271+
- **Default value**: `true`
1272+
- **Possible values**: `true`, `false`
1273+
- **Stable**: No (tracking issue: [#5977](https://github.com/rust-lang/rustfmt/issues/5977))
1274+
12571275
## `ignore`
12581276

12591277
Skip formatting files and directories that match the specified pattern.
@@ -1655,7 +1673,7 @@ use core::slice;
16551673

16561674
Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator.
16571675

1658-
The Style Guide requires that bodies are block wrapped by default if a line break is required after the `=>`, but this option can be used to disable that behavior to prevent wrapping arm bodies in that event, so long as the body does not contain multiple statements nor line comments.
1676+
The Style Guide requires that bodies are block wrapped by default if a line break is required after the `=>`, but this option can be used to disable that behavior to prevent wrapping arm bodies in that event, so long as the body contains neither multiple statements nor line comments.
16591677

16601678
- **Default value**: `true`
16611679
- **Possible values**: `true`, `false`

Contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ example, the `issue-1111.rs` test file is configured by the file
5959
## Debugging
6060

6161
Some `rewrite_*` methods use the `debug!` macro for printing useful information.
62-
These messages can be printed by using the environment variable `RUSTFMT_LOG=rustfmt=DEBUG`.
62+
These messages can be printed by using the environment variable `RUSTFMT_LOG=debug`.
6363
These traces can be helpful in understanding which part of the code was used
6464
and get a better grasp on the execution flow.
6565

Processes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ In this Section, we describe how to stabilise an option of the rustfmt's configu
1616
Open a pull request that closes the tracking issue. The tracking issue is listed beside the option in `Configurations.md`.
1717

1818
- Update the `Config` enum marking the option as stable.
19-
- Update the the `Configuration.md` file marking the option as stable.
19+
- Update the `Configuration.md` file marking the option as stable.
2020
- Update `CHANGELOG.md` marking the option as stable.
2121

2222
## After the stabilisation

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ fn channel() -> String {
4040

4141
fn commit_hash() -> Option<String> {
4242
Command::new("git")
43-
.args(&["rev-parse", "--short", "HEAD"])
43+
.args(["rev-parse", "--short", "HEAD"])
4444
.output()
4545
.ok()
4646
.and_then(|r| String::from_utf8(r.stdout).ok())
4747
}
4848

4949
fn commit_date() -> Option<String> {
5050
Command::new("git")
51-
.args(&["log", "-1", "--date=short", "--pretty=format:%cd"])
51+
.args(["log", "-1", "--date=short", "--pretty=format:%cd"])
5252
.output()
5353
.ok()
5454
.and_then(|r| String::from_utf8(r.stdout).ok())

ci/check_diff.sh

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
set -e
44

5-
# https://github.com/rust-lang/rustfmt/issues/5675
6-
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH
7-
85
function print_usage() {
96
echo "usage check_diff REMOTE_REPO FEATURE_BRANCH [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]"
107
}
@@ -31,7 +28,7 @@ function clone_repo() {
3128
GIT_TERMINAL_PROMPT=0 git clone --quiet $1 --depth 1 $2 && cd $2
3229
}
3330

34-
# Initialize Git submoduels for the repo.
31+
# Initialize Git submodules for the repo.
3532
#
3633
# Parameters
3734
# $1: list of directories to initialize
@@ -46,7 +43,7 @@ function init_submodules() {
4643
# $2: Output file path for the diff
4744
# $3: Any additional configuration options to pass to rustfmt
4845
#
49-
# Globlas:
46+
# Globals:
5047
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
5148
function create_diff() {
5249
local config;
@@ -67,7 +64,7 @@ function create_diff() {
6764
# Parameters
6865
# $1: Name of the repository (used for logging)
6966
#
70-
# Globlas:
67+
# Globals:
7168
# $RUSFMT_BIN: Path to the rustfmt master binary. Created when running `compile_rustfmt`
7269
# $FEATURE_BIN: Path to the rustfmt feature binary. Created when running `compile_rustfmt`
7370
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
@@ -90,7 +87,7 @@ function check_diff() {
9087
)
9188

9289
if [ -z "$diff" ]; then
93-
echo "no diff detected between rustfmt and the feture branch"
90+
echo "no diff detected between rustfmt and the feature branch"
9491
return 0
9592
else
9693
echo "$diff"
@@ -104,7 +101,7 @@ function check_diff() {
104101
# Parameters:
105102
# $1: Directory where rustfmt will be cloned
106103
#
107-
# Globlas:
104+
# Globals:
108105
# $REMOTE_REPO: Clone URL to the rustfmt fork that we want to test
109106
# $FEATURE_BRANCH: Name of the feature branch
110107
# $OPTIONAL_COMMIT_HASH: Optional commit hash that will be checked out if provided
@@ -114,15 +111,42 @@ function compile_rustfmt() {
114111
git remote add feature $REMOTE_REPO
115112
git fetch feature $FEATURE_BRANCH
116113

117-
cargo build --release --bin rustfmt && cp target/release/rustfmt $1/rustfmt
114+
CARGO_VERSION=$(cargo --version)
115+
echo -e "\ncompiling with $CARGO_VERSION\n"
116+
117+
# Because we're building standalone binaries we need to set `LD_LIBRARY_PATH` so each
118+
# binary can find it's runtime dependencies. See https://github.com/rust-lang/rustfmt/issues/5675
119+
# This will prepend the `LD_LIBRARY_PATH` for the master rustfmt binary
120+
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH
121+
122+
echo "Building rustfmt from src"
123+
cargo build -q --release --bin rustfmt && cp target/release/rustfmt $1/rustfmt
124+
118125
if [ -z "$OPTIONAL_COMMIT_HASH" ] || [ "$FEATURE_BRANCH" = "$OPTIONAL_COMMIT_HASH" ]; then
119126
git switch $FEATURE_BRANCH
120127
else
121128
git switch $OPTIONAL_COMMIT_HASH --detach
122129
fi
123-
cargo build --release --bin rustfmt && cp target/release/rustfmt $1/feature_rustfmt
130+
131+
# This will prepend the `LD_LIBRARY_PATH` for the feature branch rustfmt binary.
132+
# In most cases the `LD_LIBRARY_PATH` should be the same for both rustfmt binaries that we build
133+
# in `compile_rustfmt`, however, there are scenarios where each binary has different runtime
134+
# dependencies. For example, during subtree syncs we bump the nightly toolchain required to build
135+
# rustfmt, and therefore the feature branch relies on a newer set of runtime dependencies.
136+
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH
137+
138+
echo "Building feature rustfmt from src"
139+
cargo build -q --release --bin rustfmt && cp target/release/rustfmt $1/feature_rustfmt
140+
141+
echo -e "\nRuntime dependencies for rustfmt -- LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
142+
124143
RUSFMT_BIN=$1/rustfmt
144+
RUSTFMT_VERSION=$($RUSFMT_BIN --version)
145+
echo -e "\nRUSFMT_BIN $RUSTFMT_VERSION\n"
146+
125147
FEATURE_BIN=$1/feature_rustfmt
148+
FEATURE_VERSION=$($FEATURE_BIN --version)
149+
echo -e "FEATURE_BIN $FEATURE_VERSION\n"
126150
}
127151

128152
# Check the diff for running rustfmt and the feature branch on all the .rs files in the repo.
@@ -155,7 +179,7 @@ function check_repo() {
155179
STATUSES+=($?)
156180
set -e
157181

158-
echo "removing tmp_dir $tmp_dir"
182+
echo -e "removing tmp_dir $tmp_dir\n\n"
159183
rm -rf $tmp_dir
160184
cd $WORKDIR
161185
}

intellij.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- Open Rustfmt settings (File → Settings → Languages & Frameworks → Rust → Rustfmt) and enable "Run rustfmt on Save"
2121
![run_rustfmt_on_save](https://user-images.githubusercontent.com/6505554/83944610-3468f380-a81e-11ea-9c34-0cbd18dd4969.png)
2222

23-
- IntellJ uses autosave, so now your files will always be formatted according to rustfmt. Alternatively you can use Ctrl+S to reformat file manually
23+
- IntelliJ uses autosave, so now your files will always be formatted according to rustfmt. Alternatively you can use Ctrl+S to reformat file manually
2424

2525
### Bind shortcut to "Reformat File with Rustfmt" action
2626

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-10-22"
2+
channel = "nightly-2023-12-28"
33
components = ["llvm-tools", "rustc-dev"]

0 commit comments

Comments
 (0)