Skip to content

Commit

Permalink
Merge remote-tracking branch "upstream/master" into subtree-push-nigh…
Browse files Browse the repository at this point in the history
…tly-2024-06-13
  • Loading branch information
ytmimi committed Jun 13, 2024
2 parents 783a411 + c97996f commit 76cd550
Show file tree
Hide file tree
Showing 89 changed files with 1,333 additions and 221 deletions.
15 changes: 8 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

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

## [1.7.0] 2023-10-22

Expand All @@ -27,7 +28,7 @@
}
```
- Prevent ICE when formatting `vec!{}` [#5735](https://github.com/rust-lang/rustfmt/issues/5735)
- 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)
- 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)
- 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)
- 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)
```rust
Expand Down Expand Up @@ -184,7 +185,7 @@

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

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

### Fixed

Expand Down Expand Up @@ -942,7 +943,7 @@ from formatting an attribute #3665

### Fixed

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

### Changed

- Replace "--conifig-help" with "--config=help" cb10e06
- Replace "--config-help" with "--config=help" cb10e06
- Improve formatting of slice patterns #2912

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

Expand Down Expand Up @@ -1131,7 +1132,7 @@ from formatting an attribute #3665

### Changed

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

Expand Down Expand Up @@ -1195,7 +1196,7 @@ from formatting an attribute #3665
- Do not collapse block around expr with condition on match arm 5b9b7d5
- Use vertical layout for complex attributes c77708f
- Format array using heuristics for function calls 98c6f7b
- Implement stable ordering for impl items with the the following item priority: type, const, macro, then method fa80ddf
- Implement stable ordering for impl items with the following item priority: type, const, macro, then method fa80ddf
- Reorder imports by default 164cf7d
- Group `extern crate` by default 3a138a2
- Make `error_on_line_overflow` false by default f146711
Expand Down
26 changes: 16 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ generic-simd = ["bytecount/generic-simd"]
annotate-snippets = { version = "0.9", features = ["color"] }
anyhow = "1.0"
bytecount = "0.6.4"
cargo_metadata = "0.15.4"
cargo_metadata = "0.18"
clap = { version = "4.4.2", features = ["derive"] }
clap-cargo = "0.12.0"
diff = "0.1"
dirs = "4.0"
dirs = "5.0"
getopts = "0.2"
ignore = "0.4"
itertools = "0.11"
lazy_static = "1.4"
itertools = "0.12"
regex = "1.7"
serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0"
Expand Down
39 changes: 33 additions & 6 deletions 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/4.0.0/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/5.0.1/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 @@ -1050,15 +1050,25 @@ Max width for code snippets included in doc comments. Only used if [`format_code

## `format_generated_files`

Format generated files. A file is considered generated
if any of the first five lines contain a `@generated` comment marker.
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`.

By default, generated files are reformatted, i. e. `@generated` marker is ignored.
This option is currently ignored for stdin (`@generated` in stdin is ignored.)

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

## `generated_marker_line_search_limit`

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.

- **Default value**: `5`
- **Possible values**: any positive integer
- **Stable**: No (tracking issue: [#5080](https://github.com/rust-lang/rustfmt/issues/5080))

See also [format_generated_files](#format_generated_files) link here.

## `format_macro_matchers`

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

## `format_macro_bodies`

Format the bodies of macros.
Format the bodies of declarative macro definitions.

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

## `hide_parse_errors`

Do not show parse errors if the parser failed to parse files.
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`.

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

## `show_parse_errors`

Show parse errors if the parser failed to parse files.

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

## `ignore`

Skip formatting files and directories that match the specified pattern.
Expand Down Expand Up @@ -1288,6 +1306,15 @@ If you want to ignore every file under the directory where you put your rustfmt.
ignore = ["/"]
```

If you want to allow specific paths that would otherwise be ignored, prefix those paths with a `!`:

```toml
ignore = ["bar_dir/*", "!bar_dir/*/what.rs"]
```

In this case, all files under `bar_dir` will be ignored, except files like `bar_dir/sub/what.rs`
or `bar_dir/another/what.rs`.

## `imports_indent`

Indent style of imports
Expand Down Expand Up @@ -1655,7 +1682,7 @@ use core::slice;

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

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

- **Default value**: `true`
- **Possible values**: `true`, `false`
Expand Down
2 changes: 1 addition & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ example, the `issue-1111.rs` test file is configured by the file
## Debugging

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

Expand Down
2 changes: 1 addition & 1 deletion Processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In this Section, we describe how to stabilise an option of the rustfmt's configu
Open a pull request that closes the tracking issue. The tracking issue is listed beside the option in `Configurations.md`.

- Update the `Config` enum marking the option as stable.
- Update the the `Configuration.md` file marking the option as stable.
- Update the `Configuration.md` file marking the option as stable.
- Update `CHANGELOG.md` marking the option as stable.

## After the stabilisation
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ fn channel() -> String {

fn commit_hash() -> Option<String> {
Command::new("git")
.args(&["rev-parse", "--short", "HEAD"])
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|r| String::from_utf8(r.stdout).ok())
}

fn commit_date() -> Option<String> {
Command::new("git")
.args(&["log", "-1", "--date=short", "--pretty=format:�"])
.args(["log", "-1", "--date=short", "--pretty=format:�"])
.output()
.ok()
.and_then(|r| String::from_utf8(r.stdout).ok())
Expand Down
1 change: 1 addition & 0 deletions check_diff/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading

0 comments on commit 76cd550

Please sign in to comment.