Skip to content

Commit 84daccd

Browse files
Merge remote-tracking branch 'origin/master' into sync-from-rust-2024-09-16
2 parents e1712ea + 5230e8f commit 84daccd

File tree

196 files changed

+4632
-1537
lines changed

Some content is hidden

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

196 files changed

+4632
-1537
lines changed

.github/workflows/check_diff.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: checkout
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- name: install rustup
2727
run: |

.github/workflows/integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464

6565
steps:
6666
- name: checkout
67-
uses: actions/checkout@v3
67+
uses: actions/checkout@v4
6868

6969
# Run build
7070
- name: install rustup

.github/workflows/linux.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
steps:
2828
- name: checkout
29-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
3030

3131
# Run build
3232
- name: install rustup

.github/workflows/mac.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
jobs:
99
test:
1010
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
11-
# macOS Catalina 10.15
1211
runs-on: macos-latest
1312
name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
1413
env:
@@ -23,7 +22,7 @@ jobs:
2322

2423
steps:
2524
- name: checkout
26-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2726

2827
# Run build
2928
- name: install rustup

.github/workflows/rustdoc_check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: rustdoc check
1212
steps:
1313
- name: checkout
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515

1616
- name: install rustup
1717
run: |

.github/workflows/upload-assets.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
target: x86_64-pc-windows-msvc
3232
runs-on: ${{ matrix.os }}
3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535

3636
# Run build
3737
- name: install rustup

.github/workflows/windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: disable git eol translation
3434
run: git config --global core.autocrlf false
3535
- name: checkout
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737

3838
# Run build
3939
- name: Install Rustup using win.rustup.rs

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
## [1.7.1] 2024-06-24
6+
57
### Fixed
68

79
- Fix an idempotency issue when rewriting where clauses in which rustfmt would continuously add a trailing comma `,` to the end of trailing line comments [#5941](https://github.com/rust-lang/rustfmt/issues/5941).
@@ -238,7 +240,7 @@
238240

239241
### Added
240242

241-
- 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)
243+
- 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)
242244

243245
### Misc
244246

Cargo.lock

-12
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
@@ -50,7 +50,7 @@ serde_json = "1.0"
5050
term = "0.7"
5151
thiserror = "1.0.40"
5252
toml = "0.7.4"
53-
tracing = "0.1.37"
53+
tracing = { version = "0.1.37", default-features = false, features = ["std"] }
5454
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
5555
unicode-segmentation = "1.9"
5656
unicode-width = "0.1"

Configurations.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ Note that this option may be soft-deprecated in the future once the [ignore](#ig
534534
Specifies which edition is used by the parser.
535535

536536
- **Default value**: `"2015"`
537-
- **Possible values**: `"2015"`, `"2018"`, `"2021"`
537+
- **Possible values**: `"2015"`, `"2018"`, `"2021"`, `"2024"`
538538
- **Stable**: Yes
539539

540540
Rustfmt is able to pick up the edition used by reading the `Cargo.toml` file if executed
@@ -2692,6 +2692,17 @@ By default this option is set as a percentage of [`max_width`](#max_width) provi
26922692

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

2695+
## `style_edition`
2696+
2697+
Controls the edition of the [Rust Style Guide] to use for formatting ([RFC 3338])
2698+
2699+
- **Default value**: `"2015"`
2700+
- **Possible values**: `"2015"`, `"2018"`, `"2021"`, `"2024"` (unstable variant)
2701+
- **Stable**: No
2702+
2703+
[Rust Style Guide]: https://doc.rust-lang.org/nightly/style-guide/
2704+
[RFC 3338]: https://rust-lang.github.io/rfcs/3338-style-evolution.html
2705+
26952706
## `tab_spaces`
26962707

26972708
Number of spaces per tab
@@ -3051,9 +3062,7 @@ fn main() {
30513062

30523063
## `version`
30533064

3054-
Which version of the formatting rules to use. `Version::One` is backwards-compatible
3055-
with Rustfmt 1.0. Other versions are only backwards compatible within a major
3056-
version number.
3065+
This option is deprecated and has been replaced by [`style_edition`](#style_edition)
30573066

30583067
- **Default value**: `One`
30593068
- **Possible values**: `One`, `Two`

Contributing.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@ If you want to test modified `cargo-fmt`, or run `rustfmt` on the whole project
109109
RUSTFMT="./target/debug/rustfmt" cargo run --bin cargo-fmt -- --manifest-path path/to/project/you/want2test/Cargo.toml
110110
```
111111

112-
### Version-gate formatting changes
112+
### Gate formatting changes
113113

114-
A change that introduces a different code-formatting should be gated on the
115-
`version` configuration. This is to ensure the formatting of the current major
116-
release is preserved, while allowing fixes to be implemented for the next
117-
release.
114+
A change that introduces a different code-formatting must be gated on the
115+
`style_edition` configuration. This is to ensure rustfmt upholds its formatting
116+
stability guarantees and adheres to the Style Edition process set in [RFC 3338]
118117

119-
This is done by conditionally guarding the change like so:
118+
This can be done by conditionally guarding the formatting change, e.g.:
120119

121120
```rust
122-
if config.version() == Version::One { // if the current major release is 1.x
121+
// if the current stable Style Edition is Edition 2024
122+
if config.style_edition() <= StyleEdition::Edition2024 {
123123
// current formatting
124124
} else {
125125
// new formatting
@@ -129,13 +129,14 @@ if config.version() == Version::One { // if the current major release is 1.x
129129
This allows the user to apply the next formatting explicitly via the
130130
configuration, while being stable by default.
131131

132-
When the next major release is done, the code block of the previous formatting
133-
can be deleted, e.g., the first block in the example above when going from `1.x`
134-
to `2.x`.
132+
This can then be enhanced as needed if and when there are
133+
new Style Editions with differing formatting prescriptions.
135134

136135
| Note: Only formatting changes with default options need to be gated. |
137136
| --- |
138137

138+
[RFC 3338]: https://rust-lang.github.io/rfcs/3338-style-evolution.html
139+
139140
### A quick tour of Rustfmt
140141

141142
Rustfmt is basically a pretty printer - that is, its mode of operation is to

build.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
// (git not installed or if this is not a git repository) just return an empty string.
2626
fn commit_info() -> String {
2727
match (channel(), commit_hash(), commit_date()) {
28-
(channel, Some(hash), Some(date)) => format!("{} ({} {})", channel, hash.trim_end(), date),
28+
(channel, Some(hash), Some(date)) => format!("{} ({} {})", channel, hash, date),
2929
_ => String::new(),
3030
}
3131
}
@@ -39,17 +39,20 @@ fn channel() -> String {
3939
}
4040

4141
fn commit_hash() -> Option<String> {
42-
Command::new("git")
43-
.args(["rev-parse", "--short", "HEAD"])
42+
let output = Command::new("git")
43+
.args(["rev-parse", "HEAD"])
4444
.output()
45-
.ok()
46-
.and_then(|r| String::from_utf8(r.stdout).ok())
45+
.ok()?;
46+
let mut stdout = output.status.success().then_some(output.stdout)?;
47+
stdout.truncate(10);
48+
String::from_utf8(stdout).ok()
4749
}
4850

4951
fn commit_date() -> Option<String> {
50-
Command::new("git")
52+
let output = Command::new("git")
5153
.args(["log", "-1", "--date=short", "--pretty=format:%cd"])
5254
.output()
53-
.ok()
54-
.and_then(|r| String::from_utf8(r.stdout).ok())
55+
.ok()?;
56+
let stdout = output.status.success().then_some(output.stdout)?;
57+
String::from_utf8(stdout).ok()
5558
}

0 commit comments

Comments
 (0)