Skip to content

Commit ba832a9

Browse files
authored
Merge branch 'master' into issue-6013
2 parents 09590ef + 202fa22 commit ba832a9

Some content is hidden

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

55 files changed

+580
-91
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: 14 additions & 7 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: 14 additions & 4 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.
@@ -1663,7 +1673,7 @@ use core::slice;
16631673

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

1666-
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.
16671677

16681678
- **Default value**: `true`
16691679
- **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

ci/check_diff.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function clone_repo() {
2828
GIT_TERMINAL_PROMPT=0 git clone --quiet $1 --depth 1 $2 && cd $2
2929
}
3030

31-
# Initialize Git submoduels for the repo.
31+
# Initialize Git submodules for the repo.
3232
#
3333
# Parameters
3434
# $1: list of directories to initialize
@@ -43,7 +43,7 @@ function init_submodules() {
4343
# $2: Output file path for the diff
4444
# $3: Any additional configuration options to pass to rustfmt
4545
#
46-
# Globlas:
46+
# Globals:
4747
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
4848
function create_diff() {
4949
local config;
@@ -64,7 +64,7 @@ function create_diff() {
6464
# Parameters
6565
# $1: Name of the repository (used for logging)
6666
#
67-
# Globlas:
67+
# Globals:
6868
# $RUSFMT_BIN: Path to the rustfmt master binary. Created when running `compile_rustfmt`
6969
# $FEATURE_BIN: Path to the rustfmt feature binary. Created when running `compile_rustfmt`
7070
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
@@ -101,7 +101,7 @@ function check_diff() {
101101
# Parameters:
102102
# $1: Directory where rustfmt will be cloned
103103
#
104-
# Globlas:
104+
# Globals:
105105
# $REMOTE_REPO: Clone URL to the rustfmt fork that we want to test
106106
# $FEATURE_BRANCH: Name of the feature branch
107107
# $OPTIONAL_COMMIT_HASH: Optional commit hash that will be checked out if provided
@@ -111,8 +111,8 @@ function compile_rustfmt() {
111111
git remote add feature $REMOTE_REPO
112112
git fetch feature $FEATURE_BRANCH
113113

114-
CARGO_VERSON=$(cargo --version)
115-
echo -e "\ncompiling with $CARGO_VERSON\n"
114+
CARGO_VERSION=$(cargo --version)
115+
echo -e "\ncompiling with $CARGO_VERSION\n"
116116

117117
# Because we're building standalone binaries we need to set `LD_LIBRARY_PATH` so each
118118
# binary can find it's runtime dependencies. See https://github.com/rust-lang/rustfmt/issues/5675

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

src/cargo-fmt/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub struct Opts {
6161

6262
/// Options passed to rustfmt
6363
// 'raw = true' to make `--` explicit.
64-
#[arg(name = "rustfmt_options", raw = true)]
64+
#[arg(id = "rustfmt_options", raw = true)]
6565
rustfmt_options: Vec<String>,
6666

6767
/// Format all packages, and also their local path-based dependencies
@@ -209,9 +209,8 @@ fn convert_message_format_to_rustfmt_args(
209209
fn print_usage_to_stderr(reason: &str) {
210210
eprintln!("{reason}");
211211
let app = Opts::command();
212-
app.after_help("")
213-
.write_help(&mut io::stderr())
214-
.expect("failed to write to stderr");
212+
let help = app.after_help("").render_help();
213+
eprintln!("{help}");
215214
}
216215

217216
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

src/comment.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub(crate) fn combine_strs_with_missing_comments(
205205

206206
// We have a missing comment between the first expression and the second expression.
207207

208-
// Peek the the original source code and find out whether there is a newline between the first
208+
// Peek the original source code and find out whether there is a newline between the first
209209
// expression and the second expression or the missing comment. We will preserve the original
210210
// layout whenever possible.
211211
let original_snippet = context.snippet(span);
@@ -663,7 +663,7 @@ impl<'a> CommentRewrite<'a> {
663663
}
664664

665665
/// Check if any characters were written to the result buffer after the start of the comment.
666-
/// when calling [`CommentRewrite::new()`] the result buffer is initiazlied with the opening
666+
/// when calling [`CommentRewrite::new()`] the result buffer is initialized with the opening
667667
/// characters for the comment.
668668
fn buffer_contains_comment(&self) -> bool {
669669
// if self.result.len() < self.opener.len() then an empty comment is in the buffer
@@ -1260,15 +1260,15 @@ pub(crate) enum FullCodeCharKind {
12601260
InComment,
12611261
/// Last character of a comment, '\n' for a line comment, '/' for a block comment.
12621262
EndComment,
1263-
/// Start of a mutlitine string inside a comment
1263+
/// Start of a multiline string inside a comment
12641264
StartStringCommented,
1265-
/// End of a mutlitine string inside a comment
1265+
/// End of a multiline string inside a comment
12661266
EndStringCommented,
12671267
/// Inside a commented string
12681268
InStringCommented,
1269-
/// Start of a mutlitine string
1269+
/// Start of a multiline string
12701270
StartString,
1271-
/// End of a mutlitine string
1271+
/// End of a multiline string
12721272
EndString,
12731273
/// Inside a string.
12741274
InString,

0 commit comments

Comments
 (0)