Skip to content

Commit e3b9a83

Browse files
committed
Auto merge of #166138 - jieyouxu:subtree-push-20261118, r=ytmimi
rustfmt subtree update 2026-11-18 Subtree update of `rustfmt` to rust-lang/rustfmt@681514c. Created using https://github.com/rust-lang/josh-sync. r? @ytmimi
2 parents 65ce861 + 3bfcc4f commit e3b9a83

91 files changed

Lines changed: 1923 additions & 406 deletions

File tree

Some content is hidden

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

‎src/tools/rustfmt/.gitattributes‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
* text=auto eol=lf
22
tests/source/issue-3494/crlf.rs -text
33
tests/source/comment_crlf_newline.rs -text
4-
tests/source/configs/enum_discrim_align_threshold/40.rs -text
54
tests/target/issue-3494/crlf.rs -text
65
tests/target/comment_crlf_newline.rs -text
7-
tests/target/configs/enum_discrim_align_threshold/40.rs -text
6+
7+
tests/target/format_strings/issue-3263.rs -text
8+
tests/target/issue-3265.rs -text
9+
tests/target/issue-2810.rs -text
10+
tests/target/issue-2728.rs -text
11+
tests/target/issue-2641.rs -text
12+
tests/target/preserves_carriage_return_for_windows.rs -text

‎src/tools/rustfmt/.github/workflows/check_diff.yml‎

Lines changed: 0 additions & 86 deletions
This file was deleted.

‎src/tools/rustfmt/.github/workflows/clippy.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
matrix:
3232
package:
3333
- . # rustfmt
34-
- check_diff
3534
- ci
3635
- config_proc_macro
36+
- diff_check
3737
steps:
3838
- name: checkout
3939
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Diff Check (Custom)
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
clone_url:
6+
description: 'Git url of a rustfmt fork to compare against the latest rustfmt'
7+
required: true
8+
branch_name:
9+
description: 'Name of the feature branch on the forked repo'
10+
required: true
11+
language_edition:
12+
description: 'Rust language `edition` used to parse code'
13+
required: true
14+
default: 2015
15+
type: choice
16+
options:
17+
- 2015
18+
- 2018
19+
- 2021
20+
- 2024
21+
style_edition:
22+
description: 'rustfmt `style_edition` used when formatting code.'
23+
required: true
24+
default: 2021
25+
type: choice
26+
options:
27+
- 2021 # 2015, 2018, and 2021 are all formatted the same since `style_edition` was added between 2021 and 2024
28+
- 2024
29+
commit_hash:
30+
description: 'Optional commit hash from the feature branch'
31+
required: false
32+
rustfmt_configs:
33+
description: 'Optional comma separated list of rustfmt config options to pass when running the feature branch'
34+
required: false
35+
release_channel:
36+
description: 'Configure which release channel to use when compiling rustfmt'
37+
default: stable
38+
type: choice
39+
options:
40+
- stable
41+
- beta
42+
- nightly
43+
44+
permissions:
45+
contents: read
46+
47+
jobs:
48+
diff_check:
49+
name: "Diff Check {Edition ${{ inputs.language_edition }}, Style Edition ${{ inputs.style_edition }}}"
50+
uses: $/.github/workflows/diff_check_common.yml
51+
with:
52+
clone_url: ${{ inputs.clone_url }}
53+
branch_name: ${{ inputs.branch_name }}
54+
language_edition: ${{ inputs.language_edition }}
55+
style_edition: ${{ inputs.style_edition }}
56+
commit_hash: ${{ inputs.commit_hash }}
57+
rustfmt_configs: ${{ inputs.rustfmt_configs }}
58+
release_channel: ${{ inputs.release_channel }}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Diff Check (Common)
2+
on:
3+
workflow_call:
4+
inputs:
5+
clone_url:
6+
description: 'Git url of a rustfmt fork to compare against the latest rustfmt'
7+
type: string
8+
required: true
9+
branch_name:
10+
description: 'Name of the feature branch on the forked repo'
11+
type: string
12+
required: true
13+
language_edition:
14+
description: 'Rust language `edition` used to parse code'
15+
type: string
16+
required: true
17+
style_edition:
18+
description: 'rustfmt `style_edition` used when formatting code.'
19+
type: string
20+
required: true
21+
commit_hash:
22+
description: 'Optional commit hash from the feature branch'
23+
type: string
24+
required: false
25+
rustfmt_configs:
26+
description: 'Optional comma separated list of rustfmt config options to pass when running the feature branch'
27+
type: string
28+
required: false
29+
release_channel:
30+
description: 'Configure which release channel to use when compiling rustfmt'
31+
type: string
32+
required: false
33+
default: stable
34+
result_artifact:
35+
description: 'Upload job status as an artifact with the given name (if set)'
36+
type: string
37+
required: false
38+
default: ''
39+
40+
permissions:
41+
contents: read
42+
43+
jobs:
44+
diff_check:
45+
name: "Diff Check {Edition ${{ inputs.language_edition }}, Style Edition ${{ inputs.style_edition }}}"
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: checkout
50+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
51+
with:
52+
persist-credentials: false
53+
54+
- name: Build diff_check binary
55+
working-directory: ./diff_check
56+
run: cargo build --release --locked
57+
58+
- name: Run Diff Check
59+
working-directory: ./diff_check
60+
env:
61+
DIFF_CHECK_LOG: info
62+
GITHUB_EVENT_INPUTS_COMMIT_HASH: ${{ inputs.commit_hash }}
63+
GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS: ${{ inputs.rustfmt_configs }}
64+
GITHUB_EVENT_INPUTS_CLONE_URL: ${{ inputs.clone_url }}
65+
GITHUB_EVENT_INPUTS_BRANCH_NAME: ${{ inputs.branch_name }}
66+
GITHUB_EVENT_INPUTS_LANGUAGE_EDITION: ${{ inputs.language_edition }}
67+
GITHUB_EVENT_INPUTS_STYLE_EDITION: ${{ inputs.style_edition }}
68+
GITHUB_EVENT_INPUTS_RELEASE_CHANNEL: ${{ inputs.release_channel }}
69+
shell: bash
70+
run: |
71+
OPTIONS=()
72+
73+
if [[ -n "${GITHUB_EVENT_INPUTS_COMMIT_HASH}" ]]; then
74+
OPTIONS+=(--commit-hash "${GITHUB_EVENT_INPUTS_COMMIT_HASH}")
75+
fi
76+
77+
if [[ -n "${GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS}" ]]; then
78+
OPTIONS+=(--rustfmt-config "${GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS}")
79+
fi
80+
81+
target/release/diff_check \
82+
"${GITHUB_EVENT_INPUTS_CLONE_URL}" \
83+
"${GITHUB_EVENT_INPUTS_BRANCH_NAME}" \
84+
--edition "${GITHUB_EVENT_INPUTS_LANGUAGE_EDITION}" \
85+
--style-edition "${GITHUB_EVENT_INPUTS_STYLE_EDITION}" \
86+
--release-channel "${GITHUB_EVENT_INPUTS_RELEASE_CHANNEL}" \
87+
"${OPTIONS[@]}"
88+
89+
# A matrix of reusable workflow jobs give only one combined outcome, so we
90+
# need to track outcome of individual matrix jobs.
91+
- name: Record result
92+
if: ${{ always() && inputs.result_artifact != '' }}
93+
env:
94+
JOB_STATUS: ${{ job.status }}
95+
run: echo "${JOB_STATUS}" > "${RUNNER_TEMP}/result.txt"
96+
97+
- name: Upload result
98+
if: ${{ always() && inputs.result_artifact != '' }}
99+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
100+
with:
101+
name: ${{ inputs.result_artifact }}
102+
path: ${{ runner.temp }}/result.txt
103+
retention-days: 1
104+
# Allow overwriting so that rerunning a matrix job can upload artifact
105+
# with same name.
106+
overwrite: true
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Diff Check (Preset)
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
clone_url:
6+
description: 'Git url of a rustfmt fork to compare against the latest 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+
release_channel:
18+
description: 'Configure which release channel to use when compiling rustfmt'
19+
default: stable
20+
type: choice
21+
options:
22+
- stable
23+
- beta
24+
- nightly
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
diff_check:
31+
name: "Diff Check {Edition ${{ matrix.language_edition }}, Style Edition ${{ matrix.style_edition }}}"
32+
strategy:
33+
# We want to run each matrix job to conclusion so we get a full table.
34+
fail-fast: false
35+
# By default, we want to run Diff Check against Edition `{CURRENT - 1,
36+
# CURRENT}` x Style Edition `{CURRENT - 1, CURRENT}` as a preset.
37+
#
38+
# Update the matrix once a new language edition / new style edition is
39+
# stable. Keep in sync with "Write summary" step below.
40+
matrix:
41+
language_edition: ['2021', '2024']
42+
style_edition: ['2021', '2024']
43+
uses: $/.github/workflows/diff_check_common.yml
44+
with:
45+
clone_url: ${{ inputs.clone_url }}
46+
branch_name: ${{ inputs.branch_name }}
47+
commit_hash: ${{ inputs.commit_hash }}
48+
language_edition: ${{ matrix.language_edition }}
49+
style_edition: ${{ matrix.style_edition }}
50+
rustfmt_configs: ${{ inputs.rustfmt_configs }}
51+
release_channel: ${{ inputs.release_channel }}
52+
result_artifact: diff-check-result-ed${{ matrix.language_edition }}-se${{ matrix.style_edition }}
53+
54+
summary:
55+
name: "Render Diff Check matrix summary"
56+
needs: diff_check
57+
if: ${{ always() }}
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Download results
62+
# Note that no artifact exists if all matrix jobs were cancelled early.
63+
continue-on-error: true
64+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
65+
with:
66+
pattern: diff-check-result-*
67+
path: ${{ runner.temp }}/results
68+
69+
- name: Write summary
70+
env:
71+
CLONE_URL: ${{ inputs.clone_url }}
72+
BRANCH_NAME: ${{ inputs.branch_name }}
73+
COMMIT_HASH: ${{ inputs.commit_hash }}
74+
RUSTFMT_CONFIGS: ${{ inputs.rustfmt_configs }}
75+
RELEASE_CHANNEL: ${{ inputs.release_channel }}
76+
shell: bash
77+
run: |
78+
results_dir="${RUNNER_TEMP}/results"
79+
{
80+
echo "## Diff Check (Preset)"
81+
echo
82+
echo "- Repo: \`${CLONE_URL}\`"
83+
echo "- Branch: \`${BRANCH_NAME}\`"
84+
echo "- Commit: \`${COMMIT_HASH:-branch tip}\`"
85+
echo "- Release channel: \`${RELEASE_CHANNEL}\`"
86+
echo "- rustfmt configs: \`${RUSTFMT_CONFIGS:-none}\`"
87+
echo
88+
echo "| Language Edition | Style Edition | Result |"
89+
echo "|---|---|---|"
90+
# Keep in sync with the `diff_check` matrix.
91+
for language_edition in 2021 2024; do
92+
for style in 2021 2024; do
93+
file="${results_dir}/diff-check-result-ed${language_edition}-se${style}/result.txt"
94+
status=""
95+
[[ -f "${file}" ]] && status=$(< "${file}")
96+
case "${status}" in
97+
success) result="✅" ;;
98+
failure) result="❌" ;;
99+
cancelled) result="CANCELLED" ;;
100+
*) result="NO RESULT" ;;
101+
esac
102+
echo "| ${language_edition} | ${style} | ${result} |"
103+
done
104+
done
105+
} >> "${GITHUB_STEP_SUMMARY}"

‎src/tools/rustfmt/.github/workflows/rustdoc_check.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
run: |
2121
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
2222
sh rustup-init.sh -y --default-toolchain none
23+
rustup toolchain install
2324
rustup target add x86_64-unknown-linux-gnu
2425
2526
- name: document rustfmt

0 commit comments

Comments
 (0)