Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
05a72d2
Rewrite `--print-config` integration tests
matthewhughes934 Oct 16, 2026
d7ecf4d
Update config discovery integration tests
matthewhughes934 Oct 17, 2026
a50d9a9
Allow `llm-assisted` label to be set by users without write access
jieyouxu Oct 22, 2026
fad0b13
Add test demonstrating current error leak formatting
jieyouxu Oct 16, 2026
b1c0b19
Properly reset error count for `cfg_if!`
jieyouxu Oct 16, 2026
44a8861
Merge pull request #7196 from matthewhughes934/integration-test-updates
jieyouxu Oct 22, 2026
28968c5
Merge pull request #7195 from jieyouxu/jieyouxu/cfg-if
jieyouxu Oct 22, 2026
ba09f12
Integration tests: also capture exit code
matthewhughes934 Oct 19, 2026
0772c1d
Merge pull request #7207 from jieyouxu/jieyouxu/triagebot-label
ytmimi Oct 22, 2026
4689345
test: rename multi-file `cfg_select!` tests subfolder
jieyouxu Oct 23, 2026
49c47fc
test: group `cfg_select!` related tests under subfolder
jieyouxu Oct 23, 2026
04d74ce
test: add regression test for miri between-block comment
jieyouxu Oct 23, 2026
44541eb
fix(cfg_select): don't use concise format when in-between comments exist
jieyouxu Oct 23, 2026
018f54c
fix(cfg_select): don't lose comments/attrs between `=>` and arm expr
jieyouxu Oct 23, 2026
0aff56c
fix(cfg_select): don't lose comments between predicate and `=>`
jieyouxu Oct 23, 2026
0dd546a
fix(cfg_select): don't lose comment between body and trailing comma
jieyouxu Oct 23, 2026
9ab72ab
Merge pull request #7211 from jieyouxu/jieyouxu/cfg-select-comments
jieyouxu Oct 24, 2026
a5198eb
test(cfg_select): snapshot current `control_brace_style` behavior
jieyouxu Oct 24, 2026
19cdcb6
refactor: exhaustively match on `token::LitKind`
ytmimi Oct 26, 2026
e5ad9ad
fix(cfg_select): respect `control_brace_style` config
jieyouxu Oct 24, 2026
3d87f59
test(cfg_select): add coverage for `control_brace_style` with comment…
jieyouxu Oct 25, 2026
67bfa44
test(cfg_select): add coverage for long comment before arrow
jieyouxu Oct 25, 2026
fe7d957
Merge pull request #7214 from jieyouxu/jieyouxu/cfg-select-control-br…
jieyouxu Oct 27, 2026
ecc66a8
ci: Disable credential persistence
hashcatHitman Oct 23, 2026
a754ca9
ci: Expand `github.event.inputs.commit_hash` in `env`
hashcatHitman Oct 23, 2026
2c9df22
ci: Expand `github.event.inputs.rustfmt_configs` in `env`
hashcatHitman Oct 23, 2026
ad47c3e
ci: Expand `github.event.inputs.clone_url` in `env`
hashcatHitman Oct 23, 2026
e2e3160
ci: Expand `github.event.inputs.branch_name` in `env`
hashcatHitman Oct 23, 2026
ce40bba
ci: Expand `github.event.inputs.language_edition` in `env`
hashcatHitman Oct 23, 2026
52d6915
ci: Expand `github.event.inputs.style_edition` in `env`
hashcatHitman Oct 23, 2026
9cda3d3
ci: Expand `github.event.release.tag_name` in `env`
hashcatHitman Oct 23, 2026
a16fdd3
ci: Prefer shell expansion over template expansion
hashcatHitman Oct 23, 2026
e6c6acb
ci: Expand `matrix.target` in `env`
hashcatHitman Oct 23, 2026
c136f96
ci: Expand `matrix.os` in `env`
hashcatHitman Oct 23, 2026
c47f1f6
ci: Expand `matrix.build` in `env`
hashcatHitman Oct 23, 2026
905157b
ci: Expand `matrix.integration` in `env`
hashcatHitman Oct 23, 2026
6c0248d
ci: Expand `matrix.package` in `env`
hashcatHitman Oct 23, 2026
febf7c1
ci: Expand `toJson(needs)` in `env`
hashcatHitman Oct 23, 2026
17a6414
ci: Disable all permissions by default
hashcatHitman Oct 24, 2026
1dde57f
ci: Grant minimum required permissions
hashcatHitman Oct 24, 2026
865b76d
Merge pull request #7216 from ytmimi/refactor_rewrite_literal
ytmimi Oct 27, 2026
f39d517
Integration test: assert on exit codes
matthewhughes934 Oct 19, 2026
302895a
Error on `--print-config minimal` with no output path
matthewhughes934 Oct 19, 2026
a7e179a
Remove test that writes within the repo
matthewhughes934 Oct 20, 2026
72ea442
Merge pull request #7208 from matthewhughes934/more-integration-tests
matthewhughes934 Oct 27, 2026
12839e8
Merge pull request #7212 from hashcatHitman/zizmor
ytmimi Oct 30, 2026
b7e097e
Revert "Use saturating arithmetics for `adjust_max_width`"
jieyouxu Nov 2, 2026
bfd66ed
Revert "Fixes adjustment of max_width within macros"
jieyouxu Nov 2, 2026
3db5134
Merge pull request #7222 from jieyouxu/jieyouxu/revert-macro-fmt
jieyouxu Nov 2, 2026
107a661
Prepare for merging from rust-lang/rust
jieyouxu Nov 2, 2026
977efa3
Merge ref '3e92e1a2d20b' (nightly-2026-11-02) from rust-lang/rust
jieyouxu Nov 2, 2026
0e44319
chore: prepare changelog for v1.12.0
jieyouxu Nov 2, 2026
3512466
chore: remove changelog entry that's intended to be reverted in beta
jieyouxu Nov 2, 2026
f237e20
chore: bump rustfmt version to v1.12.0
jieyouxu Nov 2, 2026
003a893
ci: remove no longer used `upload-assets` workflow
jieyouxu Nov 2, 2026
fb78ede
Merge pull request #7229 from jieyouxu/jieyouxu/remove-upload-assets
ytmimi Nov 2, 2026
0f763a0
Merge pull request #7226 from jieyouxu/subtree-pull-20261102
ytmimi Nov 3, 2026
fd17c29
Merge pull request #7227 from jieyouxu/jieyouxu/release/1.12.0
ytmimi Nov 3, 2026
bb2e461
chore: bump rustfmt version to v1.12.0 in the r-l/r workspace
ytmimi Nov 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5178,7 +5178,7 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.11.0"
version = "1.12.0"
dependencies = [
"annotate-snippets 0.12.16",
"anyhow",
Expand Down
22 changes: 15 additions & 7 deletions src/tools/rustfmt/.github/workflows/check_diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Build check_diff binary
working-directory: ./check_diff
Expand All @@ -60,19 +62,25 @@ jobs:
working-directory: ./check_diff
env:
CHECK_DIFF_LOG: info
GITHUB_EVENT_INPUTS_COMMIT_HASH: ${{ github.event.inputs.commit_hash }}
GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS: ${{ github.event.inputs.rustfmt_configs }}
GITHUB_EVENT_INPUTS_CLONE_URL: ${{ github.event.inputs.clone_url }}
GITHUB_EVENT_INPUTS_BRANCH_NAME: ${{ github.event.inputs.branch_name }}
GITHUB_EVENT_INPUTS_LANGUAGE_EDITION: ${{ github.event.inputs.language_edition }}
GITHUB_EVENT_INPUTS_STYLE_EDITION: ${{ github.event.inputs.style_edition }}
shell: bash
run: |
OPTIONS=""

if [[ -n "${{ github.event.inputs.commit_hash }}" ]]; then
OPTIONS+="--commit-hash ${{ github.event.inputs.commit_hash }} "
if [[ -n "${GITHUB_EVENT_INPUTS_COMMIT_HASH}" ]]; then
OPTIONS+="--commit-hash ${GITHUB_EVENT_INPUTS_COMMIT_HASH} "
fi

if [[ -n "${{ github.event.inputs.rustfmt_configs }}" ]]; then
OPTIONS+="--rustfmt-config ${{ github.event.inputs.rustfmt_configs }} "
if [[ -n "${GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS}" ]]; then
OPTIONS+="--rustfmt-config ${GITHUB_EVENT_INPUTS_RUSTFMT_CONFIGS} "
fi

target/release/check_diff ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} \
--edition ${{ github.event.inputs.language_edition }} \
--style-edition ${{ github.event.inputs.style_edition }} \
target/release/check_diff ${GITHUB_EVENT_INPUTS_CLONE_URL} ${GITHUB_EVENT_INPUTS_BRANCH_NAME} \
--edition ${GITHUB_EVENT_INPUTS_LANGUAGE_EDITION} \
--style-edition ${GITHUB_EVENT_INPUTS_STYLE_EDITION} \
$OPTIONS
8 changes: 7 additions & 1 deletion src/tools/rustfmt/.github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: install rustup
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
Expand All @@ -35,10 +37,14 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: install rustup
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
- name: clippy
run: cargo clippy --locked --manifest-path ${{ matrix.package }}/Cargo.toml
run: cargo clippy --locked --manifest-path "${MATRIX_PACKAGE}/Cargo.toml"
env:
MATRIX_PACKAGE: ${{ matrix.package }}

5 changes: 4 additions & 1 deletion src/tools/rustfmt/.github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

# Run build
- name: install rustup
Expand All @@ -70,5 +72,6 @@ jobs:
- name: run integration tests
env:
TARGET: x86_64-unknown-linux-gnu
run: cargo run --locked --manifest-path ci/Cargo.toml integration ${{ matrix.integration }}
MATRIX_INTEGRATION: ${{ matrix.integration }}
run: cargo run --locked --manifest-path ci/Cargo.toml integration ${MATRIX_INTEGRATION}
continue-on-error: ${{ matrix.allow-failure == true }}
2 changes: 2 additions & 0 deletions src/tools/rustfmt/.github/workflows/rustdoc_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: install rustup
run: |
Expand Down
16 changes: 12 additions & 4 deletions src/tools/rustfmt/.github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
run: git config --global core.autocrlf false
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Install Rustup using win.rustup.rs
if: ${{ matrix.os == 'windows-latest' }}
Expand All @@ -52,7 +54,9 @@ jobs:
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none
del rustup-init.exe
rustup target add ${{ matrix.target }}
rustup target add ${env:MATRIX_TARGET}
env:
MATRIX_TARGET: ${{ matrix.target }}
shell: powershell

- name: Add mingw32 to path for i686-gnu
Expand All @@ -71,7 +75,9 @@ jobs:
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
rustup target add ${{ matrix.target }}
rustup target add ${MATRIX_TARGET}
env:
MATRIX_TARGET: ${{ matrix.target }}

# Run build
- name: Build and Test
Expand All @@ -97,6 +103,8 @@ jobs:
- name: Conclusion
run: |
# Print the dependent jobs to see them in the CI log
jq -C <<< '${{ toJson(needs) }}'
jq -C <<< "${JSON_NEEDS}"
# Check if all jobs that we depend on (in the needs array) were successful (or have been skipped).
jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< "${JSON_NEEDS}"
env:
JSON_NEEDS: ${{ toJson(needs) }}
73 changes: 0 additions & 73 deletions src/tools/rustfmt/.github/workflows/upload-assets.yml

This file was deleted.

30 changes: 27 additions & 3 deletions src/tools/rustfmt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,34 @@

## [Unreleased]

### Changed
- The unstable `required_version` configuration option now defaults to a caret (`^`) semver requirement instead of an exact match when no comparator is given, matching how Cargo treats dependency version requirements. Use the explicit `=` operator (e.g. `required_version = "=1.2.3"`) to opt back into exact matching [#6729](https://github.com/rust-lang/rustfmt/issues/6729)
<!-- These changes will be available on the stable released channel alongside Rust 1.101 -->
## [1.12.0] 2026-12-24

### Changed
- The unstable `required_version` configuration option now defaults to a caret (`^`) semver requirement instead of an exact match when no comparator is given, matching how Cargo treats dependency version requirements. Use the explicit `=` operator (e.g. `required_version = "=1.2.3"`) to opt back into exact matching [#6729](https://github.com/rust-lang/rustfmt/issues/6729) [#7048](https://github.com/rust-lang/rustfmt/pull/7048)
> [!IMPORTANT]
> Potential breaking changes:
> - When `--config-path` is a directory, rustfmt now also searches its parent directories for config files [#4660](https://github.com/rust-lang/rustfmt/issues/4660) [#7115](https://github.com/rust-lang/rustfmt/pull/7115)
> - Chains with comments now format under `use_try_shorthand=true` [#6121](https://github.com/rust-lang/rustfmt/issues/6121) [#7095](https://github.com/rust-lang/rustfmt/pull/7095)
> - Error on `--print-config minimal` with no output path [#7208](https://github.com/rust-lang/rustfmt/pull/7208)
> - Previously, this printed a warning and exited with `0`.

### Fixed
- Fix ragged statement comment wrapping under unstable option `wrap_comments=true` and `comment_width` [#7167](https://github.com/rust-lang/rustfmt/issues/7167) [#7170](https://github.com/rust-lang/rustfmt/pull/7170)
- Enforce comment width in item lists [#7174](https://github.com/rust-lang/rustfmt/pull/7174)
- Fix lookup of global config files [#7178](https://github.com/rust-lang/rustfmt/issues/7178) [#7179](https://github.com/rust-lang/rustfmt/pull/7179)
- Don't remove empty generic args when formatting in a macro context [#7136](https://github.com/rust-lang/rustfmt/issues/7136) [#7181](https://github.com/rust-lang/rustfmt/pull/7181)
- Various `cfg_select!` fixes. Note that `cfg_select!` formatting is still nightly-gated.
- Fix `cfg_select!` parser recovery handling and error count leak [#7171](https://github.com/rust-lang/rustfmt/pull/7171)
- Don't remove necessary blocks when formatting `cfg_select!` arms [#7045](https://github.com/rust-lang/rustfmt/issues/7045) [#7183](https://github.com/rust-lang/rustfmt/pull/7183)
- Prevent more comment loss in `cfg_select!` [#7209](https://github.com/rust-lang/rustfmt/issues/7209) [rust-lang/rust#164815](https://github.com/rust-lang/rust/pull/164815)
- Don't lose comments and attributes between `cfg_select!` predicates, outer/inner blocks, arm body and trailing commas [#7209](https://github.com/rust-lang/rustfmt/issues/7209) [#7211](https://github.com/rust-lang/rustfmt/pull/7211)
- Have `cfg_select!` double-brace concise formatting respect `control_brace_style` unstable option [#7214](https://github.com/rust-lang/rustfmt/pull/7214)
- Prevent rustfmt from removing expression attributes when removing nested parentheses [#7190](https://github.com/rust-lang/rustfmt/issues/7190) [#7192](https://github.com/rust-lang/rustfmt/pull/7192)
- Fix `cfg_if!` error count leaks [#7195](https://github.com/rust-lang/rustfmt/pull/7195)
- Format comments after `where` clauses using `clause_shape` budget (affecting unstable options `wrap_comments=true` and `comment_width`) [#7148](https://github.com/rust-lang/rustfmt/issues/7148) [#7156](https://github.com/rust-lang/rustfmt/pull/7156)
- Fix ICE on failure to format generics in enum [#5738](https://github.com/rust-lang/rustfmt/issues/5738) [#6137](https://github.com/rust-lang/rustfmt/issues/6137) [#6318](https://github.com/rust-lang/rustfmt/issues/6318) [#6646](https://github.com/rust-lang/rustfmt/issues/6646) [#6396](https://github.com/rust-lang/rustfmt/pull/6396)
- Avoid leaking wrapper space from doc comment code block formatting (affecting unstable options `format_code_in_doc_comments=true` and `fn_single_line=true`) [#6832](https://github.com/rust-lang/rustfmt/issues/6832) [#6851](https://github.com/rust-lang/rustfmt/pull/6851)

<!-- These changes will be available on the stable released channel alongside Rust 1.100 -->
## [1.11.0] 2026-11-12
Expand All @@ -28,7 +53,6 @@
- Correct visibility and defaultness order on associated impl type alias [#7064](https://github.com/rust-lang/rustfmt/pull/7064).
- Correctly calculate the `shape` for inline const blocks when using `style_edition=2027` [#7065](https://github.com/rust-lang/rustfmt/pull/7065).
- Prevent invalid code generation in macros that use raw identifiers [#7110](https://github.com/rust-lang/rustfmt/pull/7110).
- Prevent rustfmt from reporting on `max_width` configuration issues when formatting macros [#6651](https://github.com/rust-lang/rustfmt/pull/6651).

### Changed
- No longer apply `use_field_init_shorthand` when formatting macros [#6981](https://github.com/rust-lang/rustfmt/pull/6981).
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustfmt/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.11.0"
version = "1.12.0"
dependencies = [
"annotate-snippets",
"anyhow",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustfmt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rustfmt-nightly"
version = "1.11.0"
version = "1.12.0"
description = "Tool to find and fix Rust formatting issues"
repository = "https://github.com/rust-lang/rustfmt"
license = "Apache-2.0 OR MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustfmt/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2026-10-22"
channel = "nightly-2026-11-02"
components = ["llvm-tools", "rustc-dev"]
54 changes: 33 additions & 21 deletions src/tools/rustfmt/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,28 @@ pub enum OperationError {
/// An unknown help topic was requested.
#[error("Unknown help topic: `{0}`.")]
UnknownHelpTopic(String),
/// An unknown print-config option was requested.
#[error("Unknown print-config option: `{0}`.")]
UnknownPrintConfigTopic(String),
/// Attempt to generate a minimal config from standard input.
#[error("The `--print-config=minimal` option doesn't work with standard input.")]
MinimalPathWithStdin,
/// An io error during reading or writing.
#[error("{0}")]
IoError(IoError),
/// Attempt to use --emit with a mode which is not currently
/// supported with standard input.
#[error("Emit mode {0} not supported with standard output.")]
StdinBadEmit(EmitMode),
#[error(transparent)]
PrintConfig(PrintConfigError),
}

// Errors related to the '--print-config' option.
#[derive(Error, Debug)]
pub enum PrintConfigError {
/// An unknown print-config option was requested.
#[error("Unknown print-config option: `{0}`.")]
UnknownOption(String),
#[error("The `--print-config=minimal` option requires an output path to write to")]
MinimalPathNoPath,
/// Attempt to generate a minimal config from standard input.
#[error("The `--print-config=minimal` option doesn't work with standard input.")]
MinimalPathWithStdin,
}

impl From<IoError> for OperationError {
Expand Down Expand Up @@ -490,23 +499,24 @@ fn determine_operation(matches: &Matches) -> Result<Operation, OperationError> {
}
let mut free_matches = matches.free.iter();

let mut minimal_config_path = None;
if let Some(kind) = matches.opt_str("print-config") {
let path = free_matches.next().cloned();
match kind.as_str() {
"default" => return Ok(Operation::ConfigOutputDefault { path }),
"current" => return Ok(Operation::ConfigOutputCurrent { path }),
"minimal" => {
minimal_config_path = path;
if minimal_config_path.is_none() {
eprintln!("WARNING: PATH required for `--print-config minimal`.");
let minimal_config_path = match matches.opt_str("print-config") {
None => None,
Some(kind) => {
let path = free_matches.next().cloned();
match kind.as_str() {
"default" => return Ok(Operation::ConfigOutputDefault { path }),
"current" => return Ok(Operation::ConfigOutputCurrent { path }),
"minimal" => Some(path.ok_or(OperationError::PrintConfig(
PrintConfigError::MinimalPathNoPath,
))?),
_ => {
return Err(OperationError::PrintConfig(
PrintConfigError::UnknownOption(kind),
));
}
}
_ => {
return Err(OperationError::UnknownPrintConfigTopic(kind));
}
}
}
};

if matches.opt_present("version") {
return Ok(Operation::Version);
Expand All @@ -524,7 +534,9 @@ fn determine_operation(matches: &Matches) -> Result<Operation, OperationError> {
// if no file argument is supplied, read from stdin
if files.is_empty() {
if minimal_config_path.is_some() {
return Err(OperationError::MinimalPathWithStdin);
return Err(OperationError::PrintConfig(
PrintConfigError::MinimalPathWithStdin,
));
}
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;
Expand Down
Loading
Loading